documentation.d.ts 3.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779
  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. /**
  7757. * Creates a cube texture from an array of image urls
  7758. * @param files defines an array of image urls
  7759. * @param scene defines the hosting scene
  7760. * @param noMipmap specifies if mip maps are not used
  7761. * @returns a cube texture
  7762. */
  7763. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7764. /**
  7765. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7766. * @param url defines the url of the prefiltered texture
  7767. * @param scene defines the scene the texture is attached to
  7768. * @param forcedExtension defines the extension of the file if different from the url
  7769. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7770. * @return the prefiltered texture
  7771. */
  7772. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7773. /**
  7774. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7775. * as prefiltered data.
  7776. * @param rootUrl defines the url of the texture or the root name of the six images
  7777. * @param null defines the scene or engine the texture is attached to
  7778. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7779. * @param noMipmap defines if mipmaps should be created or not
  7780. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7781. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7782. * @param onError defines a callback triggered in case of error during load
  7783. * @param format defines the internal format to use for the texture once loaded
  7784. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7785. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7786. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7787. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7788. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7789. * @return the cube texture
  7790. */
  7791. 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);
  7792. /**
  7793. * Get the current class name of the texture useful for serialization or dynamic coding.
  7794. * @returns "CubeTexture"
  7795. */
  7796. getClassName(): string;
  7797. /**
  7798. * Update the url (and optional buffer) of this texture if url was null during construction.
  7799. * @param url the url of the texture
  7800. * @param forcedExtension defines the extension to use
  7801. * @param onLoad callback called when the texture is loaded (defaults to null)
  7802. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7803. */
  7804. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7805. /**
  7806. * Delays loading of the cube texture
  7807. * @param forcedExtension defines the extension to use
  7808. */
  7809. delayLoad(forcedExtension?: string): void;
  7810. /**
  7811. * Returns the reflection texture matrix
  7812. * @returns the reflection texture matrix
  7813. */
  7814. getReflectionTextureMatrix(): Matrix;
  7815. /**
  7816. * Sets the reflection texture matrix
  7817. * @param value Reflection texture matrix
  7818. */
  7819. setReflectionTextureMatrix(value: Matrix): void;
  7820. /**
  7821. * Parses text to create a cube texture
  7822. * @param parsedTexture define the serialized text to read from
  7823. * @param scene defines the hosting scene
  7824. * @param rootUrl defines the root url of the cube texture
  7825. * @returns a cube texture
  7826. */
  7827. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7828. /**
  7829. * Makes a clone, or deep copy, of the cube texture
  7830. * @returns a new cube texture
  7831. */
  7832. clone(): CubeTexture;
  7833. }
  7834. }
  7835. declare module BABYLON {
  7836. /**
  7837. * Manages the defines for the Material
  7838. */
  7839. export class MaterialDefines {
  7840. /** @hidden */
  7841. protected _keys: string[];
  7842. private _isDirty;
  7843. /** @hidden */
  7844. _renderId: number;
  7845. /** @hidden */
  7846. _areLightsDirty: boolean;
  7847. /** @hidden */
  7848. _areLightsDisposed: boolean;
  7849. /** @hidden */
  7850. _areAttributesDirty: boolean;
  7851. /** @hidden */
  7852. _areTexturesDirty: boolean;
  7853. /** @hidden */
  7854. _areFresnelDirty: boolean;
  7855. /** @hidden */
  7856. _areMiscDirty: boolean;
  7857. /** @hidden */
  7858. _areImageProcessingDirty: boolean;
  7859. /** @hidden */
  7860. _normals: boolean;
  7861. /** @hidden */
  7862. _uvs: boolean;
  7863. /** @hidden */
  7864. _needNormals: boolean;
  7865. /** @hidden */
  7866. _needUVs: boolean;
  7867. [id: string]: any;
  7868. /**
  7869. * Specifies if the material needs to be re-calculated
  7870. */
  7871. get isDirty(): boolean;
  7872. /**
  7873. * Marks the material to indicate that it has been re-calculated
  7874. */
  7875. markAsProcessed(): void;
  7876. /**
  7877. * Marks the material to indicate that it needs to be re-calculated
  7878. */
  7879. markAsUnprocessed(): void;
  7880. /**
  7881. * Marks the material to indicate all of its defines need to be re-calculated
  7882. */
  7883. markAllAsDirty(): void;
  7884. /**
  7885. * Marks the material to indicate that image processing needs to be re-calculated
  7886. */
  7887. markAsImageProcessingDirty(): void;
  7888. /**
  7889. * Marks the material to indicate the lights need to be re-calculated
  7890. * @param disposed Defines whether the light is dirty due to dispose or not
  7891. */
  7892. markAsLightDirty(disposed?: boolean): void;
  7893. /**
  7894. * Marks the attribute state as changed
  7895. */
  7896. markAsAttributesDirty(): void;
  7897. /**
  7898. * Marks the texture state as changed
  7899. */
  7900. markAsTexturesDirty(): void;
  7901. /**
  7902. * Marks the fresnel state as changed
  7903. */
  7904. markAsFresnelDirty(): void;
  7905. /**
  7906. * Marks the misc state as changed
  7907. */
  7908. markAsMiscDirty(): void;
  7909. /**
  7910. * Rebuilds the material defines
  7911. */
  7912. rebuild(): void;
  7913. /**
  7914. * Specifies if two material defines are equal
  7915. * @param other - A material define instance to compare to
  7916. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7917. */
  7918. isEqual(other: MaterialDefines): boolean;
  7919. /**
  7920. * Clones this instance's defines to another instance
  7921. * @param other - material defines to clone values to
  7922. */
  7923. cloneTo(other: MaterialDefines): void;
  7924. /**
  7925. * Resets the material define values
  7926. */
  7927. reset(): void;
  7928. /**
  7929. * Converts the material define values to a string
  7930. * @returns - String of material define information
  7931. */
  7932. toString(): string;
  7933. }
  7934. }
  7935. declare module BABYLON {
  7936. /**
  7937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7939. * 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;
  7940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7941. */
  7942. export class ColorCurves {
  7943. private _dirty;
  7944. private _tempColor;
  7945. private _globalCurve;
  7946. private _highlightsCurve;
  7947. private _midtonesCurve;
  7948. private _shadowsCurve;
  7949. private _positiveCurve;
  7950. private _negativeCurve;
  7951. private _globalHue;
  7952. private _globalDensity;
  7953. private _globalSaturation;
  7954. private _globalExposure;
  7955. /**
  7956. * Gets the global Hue value.
  7957. * 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).
  7958. */
  7959. get globalHue(): number;
  7960. /**
  7961. * Sets the global Hue value.
  7962. * 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).
  7963. */
  7964. set globalHue(value: number);
  7965. /**
  7966. * Gets the global Density value.
  7967. * 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.
  7968. * Values less than zero provide a filter of opposite hue.
  7969. */
  7970. get globalDensity(): number;
  7971. /**
  7972. * Sets 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. set globalDensity(value: number);
  7977. /**
  7978. * Gets the global Saturation value.
  7979. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7980. */
  7981. get globalSaturation(): number;
  7982. /**
  7983. * Sets the global Saturation value.
  7984. * 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.
  7985. */
  7986. set globalSaturation(value: number);
  7987. /**
  7988. * Gets the global Exposure value.
  7989. * 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.
  7990. */
  7991. get globalExposure(): number;
  7992. /**
  7993. * Sets the global Exposure value.
  7994. * 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.
  7995. */
  7996. set globalExposure(value: number);
  7997. private _highlightsHue;
  7998. private _highlightsDensity;
  7999. private _highlightsSaturation;
  8000. private _highlightsExposure;
  8001. /**
  8002. * Gets the highlights Hue value.
  8003. * 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).
  8004. */
  8005. get highlightsHue(): number;
  8006. /**
  8007. * Sets the highlights Hue value.
  8008. * 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).
  8009. */
  8010. set highlightsHue(value: number);
  8011. /**
  8012. * Gets the highlights Density value.
  8013. * 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.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. get highlightsDensity(): number;
  8017. /**
  8018. * Sets 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. set highlightsDensity(value: number);
  8023. /**
  8024. * Gets the highlights Saturation value.
  8025. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8026. */
  8027. get highlightsSaturation(): number;
  8028. /**
  8029. * Sets the highlights Saturation value.
  8030. * 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.
  8031. */
  8032. set highlightsSaturation(value: number);
  8033. /**
  8034. * Gets the highlights Exposure value.
  8035. * 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.
  8036. */
  8037. get highlightsExposure(): number;
  8038. /**
  8039. * Sets the highlights Exposure value.
  8040. * 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.
  8041. */
  8042. set highlightsExposure(value: number);
  8043. private _midtonesHue;
  8044. private _midtonesDensity;
  8045. private _midtonesSaturation;
  8046. private _midtonesExposure;
  8047. /**
  8048. * Gets the midtones Hue value.
  8049. * 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).
  8050. */
  8051. get midtonesHue(): number;
  8052. /**
  8053. * Sets the midtones Hue value.
  8054. * 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).
  8055. */
  8056. set midtonesHue(value: number);
  8057. /**
  8058. * Gets the midtones Density value.
  8059. * 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.
  8060. * Values less than zero provide a filter of opposite hue.
  8061. */
  8062. get midtonesDensity(): number;
  8063. /**
  8064. * Sets 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. set midtonesDensity(value: number);
  8069. /**
  8070. * Gets the midtones Saturation value.
  8071. * 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.
  8072. */
  8073. get midtonesSaturation(): number;
  8074. /**
  8075. * Sets the midtones Saturation value.
  8076. * 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.
  8077. */
  8078. set midtonesSaturation(value: number);
  8079. /**
  8080. * Gets the midtones Exposure value.
  8081. * 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.
  8082. */
  8083. get midtonesExposure(): number;
  8084. /**
  8085. * Sets the midtones Exposure value.
  8086. * 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.
  8087. */
  8088. set midtonesExposure(value: number);
  8089. private _shadowsHue;
  8090. private _shadowsDensity;
  8091. private _shadowsSaturation;
  8092. private _shadowsExposure;
  8093. /**
  8094. * Gets the shadows Hue value.
  8095. * 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).
  8096. */
  8097. get shadowsHue(): number;
  8098. /**
  8099. * Sets the shadows Hue value.
  8100. * 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).
  8101. */
  8102. set shadowsHue(value: number);
  8103. /**
  8104. * Gets the shadows Density value.
  8105. * 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.
  8106. * Values less than zero provide a filter of opposite hue.
  8107. */
  8108. get shadowsDensity(): number;
  8109. /**
  8110. * Sets 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. set shadowsDensity(value: number);
  8115. /**
  8116. * Gets the shadows Saturation value.
  8117. * 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.
  8118. */
  8119. get shadowsSaturation(): number;
  8120. /**
  8121. * Sets the shadows Saturation value.
  8122. * 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.
  8123. */
  8124. set shadowsSaturation(value: number);
  8125. /**
  8126. * Gets the shadows Exposure value.
  8127. * 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.
  8128. */
  8129. get shadowsExposure(): number;
  8130. /**
  8131. * Sets the shadows Exposure value.
  8132. * 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.
  8133. */
  8134. set shadowsExposure(value: number);
  8135. /**
  8136. * Returns the class name
  8137. * @returns The class name
  8138. */
  8139. getClassName(): string;
  8140. /**
  8141. * Binds the color curves to the shader.
  8142. * @param colorCurves The color curve to bind
  8143. * @param effect The effect to bind to
  8144. * @param positiveUniform The positive uniform shader parameter
  8145. * @param neutralUniform The neutral uniform shader parameter
  8146. * @param negativeUniform The negative uniform shader parameter
  8147. */
  8148. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8149. /**
  8150. * Prepare the list of uniforms associated with the ColorCurves effects.
  8151. * @param uniformsList The list of uniforms used in the effect
  8152. */
  8153. static PrepareUniforms(uniformsList: string[]): void;
  8154. /**
  8155. * Returns color grading data based on a hue, density, saturation and exposure value.
  8156. * @param filterHue The hue of the color filter.
  8157. * @param filterDensity The density of the color filter.
  8158. * @param saturation The saturation.
  8159. * @param exposure The exposure.
  8160. * @param result The result data container.
  8161. */
  8162. private getColorGradingDataToRef;
  8163. /**
  8164. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8165. * @param value The input slider value in range [-100,100].
  8166. * @returns Adjusted value.
  8167. */
  8168. private static applyColorGradingSliderNonlinear;
  8169. /**
  8170. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8171. * @param hue The hue (H) input.
  8172. * @param saturation The saturation (S) input.
  8173. * @param brightness The brightness (B) input.
  8174. * @result An RGBA color represented as Vector4.
  8175. */
  8176. private static fromHSBToRef;
  8177. /**
  8178. * Returns a value clamped between min and max
  8179. * @param value The value to clamp
  8180. * @param min The minimum of value
  8181. * @param max The maximum of value
  8182. * @returns The clamped value.
  8183. */
  8184. private static clamp;
  8185. /**
  8186. * Clones the current color curve instance.
  8187. * @return The cloned curves
  8188. */
  8189. clone(): ColorCurves;
  8190. /**
  8191. * Serializes the current color curve instance to a json representation.
  8192. * @return a JSON representation
  8193. */
  8194. serialize(): any;
  8195. /**
  8196. * Parses the color curve from a json representation.
  8197. * @param source the JSON source to parse
  8198. * @return The parsed curves
  8199. */
  8200. static Parse(source: any): ColorCurves;
  8201. }
  8202. }
  8203. declare module BABYLON {
  8204. /**
  8205. * Interface to follow in your material defines to integrate easily the
  8206. * Image proccessing functions.
  8207. * @hidden
  8208. */
  8209. export interface IImageProcessingConfigurationDefines {
  8210. IMAGEPROCESSING: boolean;
  8211. VIGNETTE: boolean;
  8212. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8213. VIGNETTEBLENDMODEOPAQUE: boolean;
  8214. TONEMAPPING: boolean;
  8215. TONEMAPPING_ACES: boolean;
  8216. CONTRAST: boolean;
  8217. EXPOSURE: boolean;
  8218. COLORCURVES: boolean;
  8219. COLORGRADING: boolean;
  8220. COLORGRADING3D: boolean;
  8221. SAMPLER3DGREENDEPTH: boolean;
  8222. SAMPLER3DBGRMAP: boolean;
  8223. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8224. }
  8225. /**
  8226. * @hidden
  8227. */
  8228. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8229. IMAGEPROCESSING: boolean;
  8230. VIGNETTE: boolean;
  8231. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8232. VIGNETTEBLENDMODEOPAQUE: boolean;
  8233. TONEMAPPING: boolean;
  8234. TONEMAPPING_ACES: boolean;
  8235. CONTRAST: boolean;
  8236. COLORCURVES: boolean;
  8237. COLORGRADING: boolean;
  8238. COLORGRADING3D: boolean;
  8239. SAMPLER3DGREENDEPTH: boolean;
  8240. SAMPLER3DBGRMAP: boolean;
  8241. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8242. EXPOSURE: boolean;
  8243. constructor();
  8244. }
  8245. /**
  8246. * This groups together the common properties used for image processing either in direct forward pass
  8247. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8248. * or not.
  8249. */
  8250. export class ImageProcessingConfiguration {
  8251. /**
  8252. * Default tone mapping applied in BabylonJS.
  8253. */
  8254. static readonly TONEMAPPING_STANDARD: number;
  8255. /**
  8256. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8257. * to other engines rendering to increase portability.
  8258. */
  8259. static readonly TONEMAPPING_ACES: number;
  8260. /**
  8261. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8262. */
  8263. colorCurves: Nullable<ColorCurves>;
  8264. private _colorCurvesEnabled;
  8265. /**
  8266. * Gets wether the color curves effect is enabled.
  8267. */
  8268. get colorCurvesEnabled(): boolean;
  8269. /**
  8270. * Sets wether the color curves effect is enabled.
  8271. */
  8272. set colorCurvesEnabled(value: boolean);
  8273. private _colorGradingTexture;
  8274. /**
  8275. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8276. */
  8277. get colorGradingTexture(): Nullable<BaseTexture>;
  8278. /**
  8279. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8280. */
  8281. set colorGradingTexture(value: Nullable<BaseTexture>);
  8282. private _colorGradingEnabled;
  8283. /**
  8284. * Gets wether the color grading effect is enabled.
  8285. */
  8286. get colorGradingEnabled(): boolean;
  8287. /**
  8288. * Sets wether the color grading effect is enabled.
  8289. */
  8290. set colorGradingEnabled(value: boolean);
  8291. private _colorGradingWithGreenDepth;
  8292. /**
  8293. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8294. */
  8295. get colorGradingWithGreenDepth(): boolean;
  8296. /**
  8297. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8298. */
  8299. set colorGradingWithGreenDepth(value: boolean);
  8300. private _colorGradingBGR;
  8301. /**
  8302. * Gets wether the color grading texture contains BGR values.
  8303. */
  8304. get colorGradingBGR(): boolean;
  8305. /**
  8306. * Sets wether the color grading texture contains BGR values.
  8307. */
  8308. set colorGradingBGR(value: boolean);
  8309. /** @hidden */
  8310. _exposure: number;
  8311. /**
  8312. * Gets the Exposure used in the effect.
  8313. */
  8314. get exposure(): number;
  8315. /**
  8316. * Sets the Exposure used in the effect.
  8317. */
  8318. set exposure(value: number);
  8319. private _toneMappingEnabled;
  8320. /**
  8321. * Gets wether the tone mapping effect is enabled.
  8322. */
  8323. get toneMappingEnabled(): boolean;
  8324. /**
  8325. * Sets wether the tone mapping effect is enabled.
  8326. */
  8327. set toneMappingEnabled(value: boolean);
  8328. private _toneMappingType;
  8329. /**
  8330. * Gets the type of tone mapping effect.
  8331. */
  8332. get toneMappingType(): number;
  8333. /**
  8334. * Sets the type of tone mapping effect used in BabylonJS.
  8335. */
  8336. set toneMappingType(value: number);
  8337. protected _contrast: number;
  8338. /**
  8339. * Gets the contrast used in the effect.
  8340. */
  8341. get contrast(): number;
  8342. /**
  8343. * Sets the contrast used in the effect.
  8344. */
  8345. set contrast(value: number);
  8346. /**
  8347. * Vignette stretch size.
  8348. */
  8349. vignetteStretch: number;
  8350. /**
  8351. * Vignette centre X Offset.
  8352. */
  8353. vignetteCentreX: number;
  8354. /**
  8355. * Vignette centre Y Offset.
  8356. */
  8357. vignetteCentreY: number;
  8358. /**
  8359. * Vignette weight or intensity of the vignette effect.
  8360. */
  8361. vignetteWeight: number;
  8362. /**
  8363. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8364. * if vignetteEnabled is set to true.
  8365. */
  8366. vignetteColor: Color4;
  8367. /**
  8368. * Camera field of view used by the Vignette effect.
  8369. */
  8370. vignetteCameraFov: number;
  8371. private _vignetteBlendMode;
  8372. /**
  8373. * Gets the vignette blend mode allowing different kind of effect.
  8374. */
  8375. get vignetteBlendMode(): number;
  8376. /**
  8377. * Sets the vignette blend mode allowing different kind of effect.
  8378. */
  8379. set vignetteBlendMode(value: number);
  8380. private _vignetteEnabled;
  8381. /**
  8382. * Gets wether the vignette effect is enabled.
  8383. */
  8384. get vignetteEnabled(): boolean;
  8385. /**
  8386. * Sets wether the vignette effect is enabled.
  8387. */
  8388. set vignetteEnabled(value: boolean);
  8389. private _applyByPostProcess;
  8390. /**
  8391. * Gets wether the image processing is applied through a post process or not.
  8392. */
  8393. get applyByPostProcess(): boolean;
  8394. /**
  8395. * Sets wether the image processing is applied through a post process or not.
  8396. */
  8397. set applyByPostProcess(value: boolean);
  8398. private _isEnabled;
  8399. /**
  8400. * Gets wether the image processing is enabled or not.
  8401. */
  8402. get isEnabled(): boolean;
  8403. /**
  8404. * Sets wether the image processing is enabled or not.
  8405. */
  8406. set isEnabled(value: boolean);
  8407. /**
  8408. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8409. */
  8410. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8411. /**
  8412. * Method called each time the image processing information changes requires to recompile the effect.
  8413. */
  8414. protected _updateParameters(): void;
  8415. /**
  8416. * Gets the current class name.
  8417. * @return "ImageProcessingConfiguration"
  8418. */
  8419. getClassName(): string;
  8420. /**
  8421. * Prepare the list of uniforms associated with the Image Processing effects.
  8422. * @param uniforms The list of uniforms used in the effect
  8423. * @param defines the list of defines currently in use
  8424. */
  8425. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8426. /**
  8427. * Prepare the list of samplers associated with the Image Processing effects.
  8428. * @param samplersList The list of uniforms used in the effect
  8429. * @param defines the list of defines currently in use
  8430. */
  8431. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8432. /**
  8433. * Prepare the list of defines associated to the shader.
  8434. * @param defines the list of defines to complete
  8435. * @param forPostProcess Define if we are currently in post process mode or not
  8436. */
  8437. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8438. /**
  8439. * Returns true if all the image processing information are ready.
  8440. * @returns True if ready, otherwise, false
  8441. */
  8442. isReady(): boolean;
  8443. /**
  8444. * Binds the image processing to the shader.
  8445. * @param effect The effect to bind to
  8446. * @param overrideAspectRatio Override the aspect ratio of the effect
  8447. */
  8448. bind(effect: Effect, overrideAspectRatio?: number): void;
  8449. /**
  8450. * Clones the current image processing instance.
  8451. * @return The cloned image processing
  8452. */
  8453. clone(): ImageProcessingConfiguration;
  8454. /**
  8455. * Serializes the current image processing instance to a json representation.
  8456. * @return a JSON representation
  8457. */
  8458. serialize(): any;
  8459. /**
  8460. * Parses the image processing from a json representation.
  8461. * @param source the JSON source to parse
  8462. * @return The parsed image processing
  8463. */
  8464. static Parse(source: any): ImageProcessingConfiguration;
  8465. private static _VIGNETTEMODE_MULTIPLY;
  8466. private static _VIGNETTEMODE_OPAQUE;
  8467. /**
  8468. * Used to apply the vignette as a mix with the pixel color.
  8469. */
  8470. static get VIGNETTEMODE_MULTIPLY(): number;
  8471. /**
  8472. * Used to apply the vignette as a replacement of the pixel color.
  8473. */
  8474. static get VIGNETTEMODE_OPAQUE(): number;
  8475. }
  8476. }
  8477. declare module BABYLON {
  8478. /** @hidden */
  8479. export var postprocessVertexShader: {
  8480. name: string;
  8481. shader: string;
  8482. };
  8483. }
  8484. declare module BABYLON {
  8485. interface ThinEngine {
  8486. /**
  8487. * Creates a new render target texture
  8488. * @param size defines the size of the texture
  8489. * @param options defines the options used to create the texture
  8490. * @returns a new render target texture stored in an InternalTexture
  8491. */
  8492. createRenderTargetTexture(size: number | {
  8493. width: number;
  8494. height: number;
  8495. layers?: number;
  8496. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8497. /**
  8498. * Creates a depth stencil texture.
  8499. * This is only available in WebGL 2 or with the depth texture extension available.
  8500. * @param size The size of face edge in the texture.
  8501. * @param options The options defining the texture.
  8502. * @returns The texture
  8503. */
  8504. createDepthStencilTexture(size: number | {
  8505. width: number;
  8506. height: number;
  8507. layers?: number;
  8508. }, options: DepthTextureCreationOptions): InternalTexture;
  8509. /** @hidden */
  8510. _createDepthStencilTexture(size: number | {
  8511. width: number;
  8512. height: number;
  8513. layers?: number;
  8514. }, options: DepthTextureCreationOptions): InternalTexture;
  8515. }
  8516. }
  8517. declare module BABYLON {
  8518. /**
  8519. * Defines the kind of connection point for node based material
  8520. */
  8521. export enum NodeMaterialBlockConnectionPointTypes {
  8522. /** Float */
  8523. Float = 1,
  8524. /** Int */
  8525. Int = 2,
  8526. /** Vector2 */
  8527. Vector2 = 4,
  8528. /** Vector3 */
  8529. Vector3 = 8,
  8530. /** Vector4 */
  8531. Vector4 = 16,
  8532. /** Color3 */
  8533. Color3 = 32,
  8534. /** Color4 */
  8535. Color4 = 64,
  8536. /** Matrix */
  8537. Matrix = 128,
  8538. /** Custom object */
  8539. Object = 256,
  8540. /** Detect type based on connection */
  8541. AutoDetect = 1024,
  8542. /** Output type that will be defined by input type */
  8543. BasedOnInput = 2048
  8544. }
  8545. }
  8546. declare module BABYLON {
  8547. /**
  8548. * Enum used to define the target of a block
  8549. */
  8550. export enum NodeMaterialBlockTargets {
  8551. /** Vertex shader */
  8552. Vertex = 1,
  8553. /** Fragment shader */
  8554. Fragment = 2,
  8555. /** Neutral */
  8556. Neutral = 4,
  8557. /** Vertex and Fragment */
  8558. VertexAndFragment = 3
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /**
  8563. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8564. */
  8565. export enum NodeMaterialBlockConnectionPointMode {
  8566. /** Value is an uniform */
  8567. Uniform = 0,
  8568. /** Value is a mesh attribute */
  8569. Attribute = 1,
  8570. /** Value is a varying between vertex and fragment shaders */
  8571. Varying = 2,
  8572. /** Mode is undefined */
  8573. Undefined = 3
  8574. }
  8575. }
  8576. declare module BABYLON {
  8577. /**
  8578. * Enum used to define system values e.g. values automatically provided by the system
  8579. */
  8580. export enum NodeMaterialSystemValues {
  8581. /** World */
  8582. World = 1,
  8583. /** View */
  8584. View = 2,
  8585. /** Projection */
  8586. Projection = 3,
  8587. /** ViewProjection */
  8588. ViewProjection = 4,
  8589. /** WorldView */
  8590. WorldView = 5,
  8591. /** WorldViewProjection */
  8592. WorldViewProjection = 6,
  8593. /** CameraPosition */
  8594. CameraPosition = 7,
  8595. /** Fog Color */
  8596. FogColor = 8,
  8597. /** Delta time */
  8598. DeltaTime = 9
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /** Defines supported spaces */
  8603. export enum Space {
  8604. /** Local (object) space */
  8605. LOCAL = 0,
  8606. /** World space */
  8607. WORLD = 1,
  8608. /** Bone space */
  8609. BONE = 2
  8610. }
  8611. /** Defines the 3 main axes */
  8612. export class Axis {
  8613. /** X axis */
  8614. static X: Vector3;
  8615. /** Y axis */
  8616. static Y: Vector3;
  8617. /** Z axis */
  8618. static Z: Vector3;
  8619. }
  8620. }
  8621. declare module BABYLON {
  8622. /**
  8623. * Represents a camera frustum
  8624. */
  8625. export class Frustum {
  8626. /**
  8627. * Gets the planes representing the frustum
  8628. * @param transform matrix to be applied to the returned planes
  8629. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8630. */
  8631. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8632. /**
  8633. * Gets the near frustum plane transformed by the transform matrix
  8634. * @param transform transformation matrix to be applied to the resulting frustum plane
  8635. * @param frustumPlane the resuling frustum plane
  8636. */
  8637. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8638. /**
  8639. * Gets the far 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 GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8644. /**
  8645. * Gets the left 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 GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8650. /**
  8651. * Gets the right 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 GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8656. /**
  8657. * Gets the top 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 GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8662. /**
  8663. * Gets the bottom 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 GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8668. /**
  8669. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8670. * @param transform transformation matrix to be applied to the resulting frustum planes
  8671. * @param frustumPlanes the resuling frustum planes
  8672. */
  8673. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8674. }
  8675. }
  8676. declare module BABYLON {
  8677. /**
  8678. * Interface for the size containing width and height
  8679. */
  8680. export interface ISize {
  8681. /**
  8682. * Width
  8683. */
  8684. width: number;
  8685. /**
  8686. * Heighht
  8687. */
  8688. height: number;
  8689. }
  8690. /**
  8691. * Size containing widht and height
  8692. */
  8693. export class Size implements ISize {
  8694. /**
  8695. * Width
  8696. */
  8697. width: number;
  8698. /**
  8699. * Height
  8700. */
  8701. height: number;
  8702. /**
  8703. * Creates a Size object from the given width and height (floats).
  8704. * @param width width of the new size
  8705. * @param height height of the new size
  8706. */
  8707. constructor(width: number, height: number);
  8708. /**
  8709. * Returns a string with the Size width and height
  8710. * @returns a string with the Size width and height
  8711. */
  8712. toString(): string;
  8713. /**
  8714. * "Size"
  8715. * @returns the string "Size"
  8716. */
  8717. getClassName(): string;
  8718. /**
  8719. * Returns the Size hash code.
  8720. * @returns a hash code for a unique width and height
  8721. */
  8722. getHashCode(): number;
  8723. /**
  8724. * Updates the current size from the given one.
  8725. * @param src the given size
  8726. */
  8727. copyFrom(src: Size): void;
  8728. /**
  8729. * Updates in place the current Size from the given floats.
  8730. * @param width width of the new size
  8731. * @param height height of the new size
  8732. * @returns the updated Size.
  8733. */
  8734. copyFromFloats(width: number, height: number): Size;
  8735. /**
  8736. * Updates in place the current Size from the given floats.
  8737. * @param width width to set
  8738. * @param height height to set
  8739. * @returns the updated Size.
  8740. */
  8741. set(width: number, height: number): Size;
  8742. /**
  8743. * Multiplies the width and height by numbers
  8744. * @param w factor to multiple the width by
  8745. * @param h factor to multiple the height by
  8746. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8747. */
  8748. multiplyByFloats(w: number, h: number): Size;
  8749. /**
  8750. * Clones the size
  8751. * @returns a new Size copied from the given one.
  8752. */
  8753. clone(): Size;
  8754. /**
  8755. * True if the current Size and the given one width and height are strictly equal.
  8756. * @param other the other size to compare against
  8757. * @returns True if the current Size and the given one width and height are strictly equal.
  8758. */
  8759. equals(other: Size): boolean;
  8760. /**
  8761. * The surface of the Size : width * height (float).
  8762. */
  8763. get surface(): number;
  8764. /**
  8765. * Create a new size of zero
  8766. * @returns a new Size set to (0.0, 0.0)
  8767. */
  8768. static Zero(): Size;
  8769. /**
  8770. * Sums the width and height of two sizes
  8771. * @param otherSize size to add to this size
  8772. * @returns a new Size set as the addition result of the current Size and the given one.
  8773. */
  8774. add(otherSize: Size): Size;
  8775. /**
  8776. * Subtracts the width and height of two
  8777. * @param otherSize size to subtract to this size
  8778. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8779. */
  8780. subtract(otherSize: Size): Size;
  8781. /**
  8782. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8783. * @param start starting size to lerp between
  8784. * @param end end size to lerp between
  8785. * @param amount amount to lerp between the start and end values
  8786. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8787. */
  8788. static Lerp(start: Size, end: Size, amount: number): Size;
  8789. }
  8790. }
  8791. declare module BABYLON {
  8792. /**
  8793. * Contains position and normal vectors for a vertex
  8794. */
  8795. export class PositionNormalVertex {
  8796. /** the position of the vertex (defaut: 0,0,0) */
  8797. position: Vector3;
  8798. /** the normal of the vertex (defaut: 0,1,0) */
  8799. normal: Vector3;
  8800. /**
  8801. * Creates a PositionNormalVertex
  8802. * @param position the position of the vertex (defaut: 0,0,0)
  8803. * @param normal the normal of the vertex (defaut: 0,1,0)
  8804. */
  8805. constructor(
  8806. /** the position of the vertex (defaut: 0,0,0) */
  8807. position?: Vector3,
  8808. /** the normal of the vertex (defaut: 0,1,0) */
  8809. normal?: Vector3);
  8810. /**
  8811. * Clones the PositionNormalVertex
  8812. * @returns the cloned PositionNormalVertex
  8813. */
  8814. clone(): PositionNormalVertex;
  8815. }
  8816. /**
  8817. * Contains position, normal and uv vectors for a vertex
  8818. */
  8819. export class PositionNormalTextureVertex {
  8820. /** the position of the vertex (defaut: 0,0,0) */
  8821. position: Vector3;
  8822. /** the normal of the vertex (defaut: 0,1,0) */
  8823. normal: Vector3;
  8824. /** the uv of the vertex (default: 0,0) */
  8825. uv: Vector2;
  8826. /**
  8827. * Creates a PositionNormalTextureVertex
  8828. * @param position the position of the vertex (defaut: 0,0,0)
  8829. * @param normal the normal of the vertex (defaut: 0,1,0)
  8830. * @param uv the uv of the vertex (default: 0,0)
  8831. */
  8832. constructor(
  8833. /** the position of the vertex (defaut: 0,0,0) */
  8834. position?: Vector3,
  8835. /** the normal of the vertex (defaut: 0,1,0) */
  8836. normal?: Vector3,
  8837. /** the uv of the vertex (default: 0,0) */
  8838. uv?: Vector2);
  8839. /**
  8840. * Clones the PositionNormalTextureVertex
  8841. * @returns the cloned PositionNormalTextureVertex
  8842. */
  8843. clone(): PositionNormalTextureVertex;
  8844. }
  8845. }
  8846. declare module BABYLON {
  8847. /**
  8848. * Enum defining the type of animations supported by InputBlock
  8849. */
  8850. export enum AnimatedInputBlockTypes {
  8851. /** No animation */
  8852. None = 0,
  8853. /** Time based animation. Will only work for floats */
  8854. Time = 1
  8855. }
  8856. }
  8857. declare module BABYLON {
  8858. /**
  8859. * Interface describing all the common properties and methods a shadow light needs to implement.
  8860. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8861. * as well as binding the different shadow properties to the effects.
  8862. */
  8863. export interface IShadowLight extends Light {
  8864. /**
  8865. * The light id in the scene (used in scene.findLighById for instance)
  8866. */
  8867. id: string;
  8868. /**
  8869. * The position the shdow will be casted from.
  8870. */
  8871. position: Vector3;
  8872. /**
  8873. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8874. */
  8875. direction: Vector3;
  8876. /**
  8877. * The transformed position. Position of the light in world space taking parenting in account.
  8878. */
  8879. transformedPosition: Vector3;
  8880. /**
  8881. * The transformed direction. Direction of the light in world space taking parenting in account.
  8882. */
  8883. transformedDirection: Vector3;
  8884. /**
  8885. * The friendly name of the light in the scene.
  8886. */
  8887. name: string;
  8888. /**
  8889. * Defines the shadow projection clipping minimum z value.
  8890. */
  8891. shadowMinZ: number;
  8892. /**
  8893. * Defines the shadow projection clipping maximum z value.
  8894. */
  8895. shadowMaxZ: number;
  8896. /**
  8897. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8898. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8899. */
  8900. computeTransformedInformation(): boolean;
  8901. /**
  8902. * Gets the scene the light belongs to.
  8903. * @returns The scene
  8904. */
  8905. getScene(): Scene;
  8906. /**
  8907. * Callback defining a custom Projection Matrix Builder.
  8908. * This can be used to override the default projection matrix computation.
  8909. */
  8910. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8911. /**
  8912. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8913. * @param matrix The materix to updated with the projection information
  8914. * @param viewMatrix The transform matrix of the light
  8915. * @param renderList The list of mesh to render in the map
  8916. * @returns The current light
  8917. */
  8918. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8919. /**
  8920. * Gets the current depth scale used in ESM.
  8921. * @returns The scale
  8922. */
  8923. getDepthScale(): number;
  8924. /**
  8925. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8926. * @returns true if a cube texture needs to be use
  8927. */
  8928. needCube(): boolean;
  8929. /**
  8930. * Detects if the projection matrix requires to be recomputed this frame.
  8931. * @returns true if it requires to be recomputed otherwise, false.
  8932. */
  8933. needProjectionMatrixCompute(): boolean;
  8934. /**
  8935. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8936. */
  8937. forceProjectionMatrixCompute(): void;
  8938. /**
  8939. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8940. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8941. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8942. */
  8943. getShadowDirection(faceIndex?: number): Vector3;
  8944. /**
  8945. * Gets the minZ used for shadow according to both the scene and the light.
  8946. * @param activeCamera The camera we are returning the min for
  8947. * @returns the depth min z
  8948. */
  8949. getDepthMinZ(activeCamera: Camera): number;
  8950. /**
  8951. * Gets the maxZ used for shadow according to both the scene and the light.
  8952. * @param activeCamera The camera we are returning the max for
  8953. * @returns the depth max z
  8954. */
  8955. getDepthMaxZ(activeCamera: Camera): number;
  8956. }
  8957. /**
  8958. * Base implementation IShadowLight
  8959. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8960. */
  8961. export abstract class ShadowLight extends Light implements IShadowLight {
  8962. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8963. protected _position: Vector3;
  8964. protected _setPosition(value: Vector3): void;
  8965. /**
  8966. * Sets the position the shadow will be casted from. Also use as the light position for both
  8967. * point and spot lights.
  8968. */
  8969. get position(): Vector3;
  8970. /**
  8971. * Sets the position the shadow will be casted from. Also use as the light position for both
  8972. * point and spot lights.
  8973. */
  8974. set position(value: Vector3);
  8975. protected _direction: Vector3;
  8976. protected _setDirection(value: Vector3): void;
  8977. /**
  8978. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8979. * Also use as the light direction on spot and directional lights.
  8980. */
  8981. get direction(): Vector3;
  8982. /**
  8983. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8984. * Also use as the light direction on spot and directional lights.
  8985. */
  8986. set direction(value: Vector3);
  8987. protected _shadowMinZ: number;
  8988. /**
  8989. * Gets the shadow projection clipping minimum z value.
  8990. */
  8991. get shadowMinZ(): number;
  8992. /**
  8993. * Sets the shadow projection clipping minimum z value.
  8994. */
  8995. set shadowMinZ(value: number);
  8996. protected _shadowMaxZ: number;
  8997. /**
  8998. * Sets the shadow projection clipping maximum z value.
  8999. */
  9000. get shadowMaxZ(): number;
  9001. /**
  9002. * Gets the shadow projection clipping maximum z value.
  9003. */
  9004. set shadowMaxZ(value: number);
  9005. /**
  9006. * Callback defining a custom Projection Matrix Builder.
  9007. * This can be used to override the default projection matrix computation.
  9008. */
  9009. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9010. /**
  9011. * The transformed position. Position of the light in world space taking parenting in account.
  9012. */
  9013. transformedPosition: Vector3;
  9014. /**
  9015. * The transformed direction. Direction of the light in world space taking parenting in account.
  9016. */
  9017. transformedDirection: Vector3;
  9018. private _needProjectionMatrixCompute;
  9019. /**
  9020. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9021. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9022. */
  9023. computeTransformedInformation(): boolean;
  9024. /**
  9025. * Return the depth scale used for the shadow map.
  9026. * @returns the depth scale.
  9027. */
  9028. getDepthScale(): number;
  9029. /**
  9030. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9031. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9032. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9033. */
  9034. getShadowDirection(faceIndex?: number): Vector3;
  9035. /**
  9036. * Returns the ShadowLight absolute position in the World.
  9037. * @returns the position vector in world space
  9038. */
  9039. getAbsolutePosition(): Vector3;
  9040. /**
  9041. * Sets the ShadowLight direction toward the passed target.
  9042. * @param target The point to target in local space
  9043. * @returns the updated ShadowLight direction
  9044. */
  9045. setDirectionToTarget(target: Vector3): Vector3;
  9046. /**
  9047. * Returns the light rotation in euler definition.
  9048. * @returns the x y z rotation in local space.
  9049. */
  9050. getRotation(): Vector3;
  9051. /**
  9052. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9053. * @returns true if a cube texture needs to be use
  9054. */
  9055. needCube(): boolean;
  9056. /**
  9057. * Detects if the projection matrix requires to be recomputed this frame.
  9058. * @returns true if it requires to be recomputed otherwise, false.
  9059. */
  9060. needProjectionMatrixCompute(): boolean;
  9061. /**
  9062. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9063. */
  9064. forceProjectionMatrixCompute(): void;
  9065. /** @hidden */
  9066. _initCache(): void;
  9067. /** @hidden */
  9068. _isSynchronized(): boolean;
  9069. /**
  9070. * Computes the world matrix of the node
  9071. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9072. * @returns the world matrix
  9073. */
  9074. computeWorldMatrix(force?: boolean): Matrix;
  9075. /**
  9076. * Gets the minZ used for shadow according to both the scene and the light.
  9077. * @param activeCamera The camera we are returning the min for
  9078. * @returns the depth min z
  9079. */
  9080. getDepthMinZ(activeCamera: Camera): number;
  9081. /**
  9082. * Gets the maxZ used for shadow according to both the scene and the light.
  9083. * @param activeCamera The camera we are returning the max for
  9084. * @returns the depth max z
  9085. */
  9086. getDepthMaxZ(activeCamera: Camera): number;
  9087. /**
  9088. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9089. * @param matrix The materix to updated with the projection information
  9090. * @param viewMatrix The transform matrix of the light
  9091. * @param renderList The list of mesh to render in the map
  9092. * @returns The current light
  9093. */
  9094. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9095. }
  9096. }
  9097. declare module BABYLON {
  9098. /** @hidden */
  9099. export var packingFunctions: {
  9100. name: string;
  9101. shader: string;
  9102. };
  9103. }
  9104. declare module BABYLON {
  9105. /** @hidden */
  9106. export var bayerDitherFunctions: {
  9107. name: string;
  9108. shader: string;
  9109. };
  9110. }
  9111. declare module BABYLON {
  9112. /** @hidden */
  9113. export var shadowMapFragmentDeclaration: {
  9114. name: string;
  9115. shader: string;
  9116. };
  9117. }
  9118. declare module BABYLON {
  9119. /** @hidden */
  9120. export var clipPlaneFragmentDeclaration: {
  9121. name: string;
  9122. shader: string;
  9123. };
  9124. }
  9125. declare module BABYLON {
  9126. /** @hidden */
  9127. export var clipPlaneFragment: {
  9128. name: string;
  9129. shader: string;
  9130. };
  9131. }
  9132. declare module BABYLON {
  9133. /** @hidden */
  9134. export var shadowMapFragment: {
  9135. name: string;
  9136. shader: string;
  9137. };
  9138. }
  9139. declare module BABYLON {
  9140. /** @hidden */
  9141. export var shadowMapPixelShader: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module BABYLON {
  9147. /** @hidden */
  9148. export var bonesDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module BABYLON {
  9154. /** @hidden */
  9155. export var morphTargetsVertexGlobalDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module BABYLON {
  9161. /** @hidden */
  9162. export var morphTargetsVertexDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module BABYLON {
  9168. /** @hidden */
  9169. export var instancesDeclaration: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module BABYLON {
  9175. /** @hidden */
  9176. export var helperFunctions: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var shadowMapVertexDeclaration: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var clipPlaneVertexDeclaration: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var morphTargetsVertex: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var instancesVertex: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var bonesVertex: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapVertexNormalBias: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapVertexMetric: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var clipPlaneVertex: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var shadowMapVertexShader: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var depthBoxBlurPixelShader: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var shadowMapFragmentSoftTransparentShadow: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /**
  9260. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9261. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9262. */
  9263. export class EffectFallbacks implements IEffectFallbacks {
  9264. private _defines;
  9265. private _currentRank;
  9266. private _maxRank;
  9267. private _mesh;
  9268. /**
  9269. * Removes the fallback from the bound mesh.
  9270. */
  9271. unBindMesh(): void;
  9272. /**
  9273. * Adds a fallback on the specified property.
  9274. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9275. * @param define The name of the define in the shader
  9276. */
  9277. addFallback(rank: number, define: string): void;
  9278. /**
  9279. * Sets the mesh to use CPU skinning when needing to fallback.
  9280. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9281. * @param mesh The mesh to use the fallbacks.
  9282. */
  9283. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9284. /**
  9285. * Checks to see if more fallbacks are still availible.
  9286. */
  9287. get hasMoreFallbacks(): boolean;
  9288. /**
  9289. * Removes the defines that should be removed when falling back.
  9290. * @param currentDefines defines the current define statements for the shader.
  9291. * @param effect defines the current effect we try to compile
  9292. * @returns The resulting defines with defines of the current rank removed.
  9293. */
  9294. reduce(currentDefines: string, effect: Effect): string;
  9295. }
  9296. }
  9297. declare module BABYLON {
  9298. /**
  9299. * Interface used to define Action
  9300. */
  9301. export interface IAction {
  9302. /**
  9303. * Trigger for the action
  9304. */
  9305. trigger: number;
  9306. /** Options of the trigger */
  9307. triggerOptions: any;
  9308. /**
  9309. * Gets the trigger parameters
  9310. * @returns the trigger parameters
  9311. */
  9312. getTriggerParameter(): any;
  9313. /**
  9314. * Internal only - executes current action event
  9315. * @hidden
  9316. */
  9317. _executeCurrent(evt?: ActionEvent): void;
  9318. /**
  9319. * Serialize placeholder for child classes
  9320. * @param parent of child
  9321. * @returns the serialized object
  9322. */
  9323. serialize(parent: any): any;
  9324. /**
  9325. * Internal only
  9326. * @hidden
  9327. */
  9328. _prepare(): void;
  9329. /**
  9330. * Internal only - manager for action
  9331. * @hidden
  9332. */
  9333. _actionManager: AbstractActionManager;
  9334. /**
  9335. * Adds action to chain of actions, may be a DoNothingAction
  9336. * @param action defines the next action to execute
  9337. * @returns The action passed in
  9338. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9339. */
  9340. then(action: IAction): IAction;
  9341. }
  9342. /**
  9343. * The action to be carried out following a trigger
  9344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9345. */
  9346. export class Action implements IAction {
  9347. /** the trigger, with or without parameters, for the action */
  9348. triggerOptions: any;
  9349. /**
  9350. * Trigger for the action
  9351. */
  9352. trigger: number;
  9353. /**
  9354. * Internal only - manager for action
  9355. * @hidden
  9356. */
  9357. _actionManager: ActionManager;
  9358. private _nextActiveAction;
  9359. private _child;
  9360. private _condition?;
  9361. private _triggerParameter;
  9362. /**
  9363. * An event triggered prior to action being executed.
  9364. */
  9365. onBeforeExecuteObservable: Observable<Action>;
  9366. /**
  9367. * Creates a new Action
  9368. * @param triggerOptions the trigger, with or without parameters, for the action
  9369. * @param condition an optional determinant of action
  9370. */
  9371. constructor(
  9372. /** the trigger, with or without parameters, for the action */
  9373. triggerOptions: any, condition?: Condition);
  9374. /**
  9375. * Internal only
  9376. * @hidden
  9377. */
  9378. _prepare(): void;
  9379. /**
  9380. * Gets the trigger parameters
  9381. * @returns the trigger parameters
  9382. */
  9383. getTriggerParameter(): any;
  9384. /**
  9385. * Internal only - executes current action event
  9386. * @hidden
  9387. */
  9388. _executeCurrent(evt?: ActionEvent): void;
  9389. /**
  9390. * Execute placeholder for child classes
  9391. * @param evt optional action event
  9392. */
  9393. execute(evt?: ActionEvent): void;
  9394. /**
  9395. * Skips to next active action
  9396. */
  9397. skipToNextActiveAction(): void;
  9398. /**
  9399. * Adds action to chain of actions, may be a DoNothingAction
  9400. * @param action defines the next action to execute
  9401. * @returns The action passed in
  9402. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9403. */
  9404. then(action: Action): Action;
  9405. /**
  9406. * Internal only
  9407. * @hidden
  9408. */
  9409. _getProperty(propertyPath: string): string;
  9410. /**
  9411. * Internal only
  9412. * @hidden
  9413. */
  9414. _getEffectiveTarget(target: any, propertyPath: string): any;
  9415. /**
  9416. * Serialize placeholder for child classes
  9417. * @param parent of child
  9418. * @returns the serialized object
  9419. */
  9420. serialize(parent: any): any;
  9421. /**
  9422. * Internal only called by serialize
  9423. * @hidden
  9424. */
  9425. protected _serialize(serializedAction: any, parent?: any): any;
  9426. /**
  9427. * Internal only
  9428. * @hidden
  9429. */
  9430. static _SerializeValueAsString: (value: any) => string;
  9431. /**
  9432. * Internal only
  9433. * @hidden
  9434. */
  9435. static _GetTargetProperty: (target: Node | Scene) => {
  9436. name: string;
  9437. targetType: string;
  9438. value: string;
  9439. };
  9440. }
  9441. }
  9442. declare module BABYLON {
  9443. /**
  9444. * A Condition applied to an Action
  9445. */
  9446. export class Condition {
  9447. /**
  9448. * Internal only - manager for action
  9449. * @hidden
  9450. */
  9451. _actionManager: ActionManager;
  9452. /**
  9453. * Internal only
  9454. * @hidden
  9455. */
  9456. _evaluationId: number;
  9457. /**
  9458. * Internal only
  9459. * @hidden
  9460. */
  9461. _currentResult: boolean;
  9462. /**
  9463. * Creates a new Condition
  9464. * @param actionManager the manager of the action the condition is applied to
  9465. */
  9466. constructor(actionManager: ActionManager);
  9467. /**
  9468. * Check if the current condition is valid
  9469. * @returns a boolean
  9470. */
  9471. isValid(): boolean;
  9472. /**
  9473. * Internal only
  9474. * @hidden
  9475. */
  9476. _getProperty(propertyPath: string): string;
  9477. /**
  9478. * Internal only
  9479. * @hidden
  9480. */
  9481. _getEffectiveTarget(target: any, propertyPath: string): any;
  9482. /**
  9483. * Serialize placeholder for child classes
  9484. * @returns the serialized object
  9485. */
  9486. serialize(): any;
  9487. /**
  9488. * Internal only
  9489. * @hidden
  9490. */
  9491. protected _serialize(serializedCondition: any): any;
  9492. }
  9493. /**
  9494. * Defines specific conditional operators as extensions of Condition
  9495. */
  9496. export class ValueCondition extends Condition {
  9497. /** path to specify the property of the target the conditional operator uses */
  9498. propertyPath: string;
  9499. /** the value compared by the conditional operator against the current value of the property */
  9500. value: any;
  9501. /** the conditional operator, default ValueCondition.IsEqual */
  9502. operator: number;
  9503. /**
  9504. * Internal only
  9505. * @hidden
  9506. */
  9507. private static _IsEqual;
  9508. /**
  9509. * Internal only
  9510. * @hidden
  9511. */
  9512. private static _IsDifferent;
  9513. /**
  9514. * Internal only
  9515. * @hidden
  9516. */
  9517. private static _IsGreater;
  9518. /**
  9519. * Internal only
  9520. * @hidden
  9521. */
  9522. private static _IsLesser;
  9523. /**
  9524. * returns the number for IsEqual
  9525. */
  9526. static get IsEqual(): number;
  9527. /**
  9528. * Returns the number for IsDifferent
  9529. */
  9530. static get IsDifferent(): number;
  9531. /**
  9532. * Returns the number for IsGreater
  9533. */
  9534. static get IsGreater(): number;
  9535. /**
  9536. * Returns the number for IsLesser
  9537. */
  9538. static get IsLesser(): number;
  9539. /**
  9540. * Internal only The action manager for the condition
  9541. * @hidden
  9542. */
  9543. _actionManager: ActionManager;
  9544. /**
  9545. * Internal only
  9546. * @hidden
  9547. */
  9548. private _target;
  9549. /**
  9550. * Internal only
  9551. * @hidden
  9552. */
  9553. private _effectiveTarget;
  9554. /**
  9555. * Internal only
  9556. * @hidden
  9557. */
  9558. private _property;
  9559. /**
  9560. * Creates a new ValueCondition
  9561. * @param actionManager manager for the action the condition applies to
  9562. * @param target for the action
  9563. * @param propertyPath path to specify the property of the target the conditional operator uses
  9564. * @param value the value compared by the conditional operator against the current value of the property
  9565. * @param operator the conditional operator, default ValueCondition.IsEqual
  9566. */
  9567. constructor(actionManager: ActionManager, target: any,
  9568. /** path to specify the property of the target the conditional operator uses */
  9569. propertyPath: string,
  9570. /** the value compared by the conditional operator against the current value of the property */
  9571. value: any,
  9572. /** the conditional operator, default ValueCondition.IsEqual */
  9573. operator?: number);
  9574. /**
  9575. * Compares the given value with the property value for the specified conditional operator
  9576. * @returns the result of the comparison
  9577. */
  9578. isValid(): boolean;
  9579. /**
  9580. * Serialize the ValueCondition into a JSON compatible object
  9581. * @returns serialization object
  9582. */
  9583. serialize(): any;
  9584. /**
  9585. * Gets the name of the conditional operator for the ValueCondition
  9586. * @param operator the conditional operator
  9587. * @returns the name
  9588. */
  9589. static GetOperatorName(operator: number): string;
  9590. }
  9591. /**
  9592. * Defines a predicate condition as an extension of Condition
  9593. */
  9594. export class PredicateCondition extends Condition {
  9595. /** defines the predicate function used to validate the condition */
  9596. predicate: () => boolean;
  9597. /**
  9598. * Internal only - manager for action
  9599. * @hidden
  9600. */
  9601. _actionManager: ActionManager;
  9602. /**
  9603. * Creates a new PredicateCondition
  9604. * @param actionManager manager for the action the condition applies to
  9605. * @param predicate defines the predicate function used to validate the condition
  9606. */
  9607. constructor(actionManager: ActionManager,
  9608. /** defines the predicate function used to validate the condition */
  9609. predicate: () => boolean);
  9610. /**
  9611. * @returns the validity of the predicate condition
  9612. */
  9613. isValid(): boolean;
  9614. }
  9615. /**
  9616. * Defines a state condition as an extension of Condition
  9617. */
  9618. export class StateCondition extends Condition {
  9619. /** Value to compare with target state */
  9620. value: string;
  9621. /**
  9622. * Internal only - manager for action
  9623. * @hidden
  9624. */
  9625. _actionManager: ActionManager;
  9626. /**
  9627. * Internal only
  9628. * @hidden
  9629. */
  9630. private _target;
  9631. /**
  9632. * Creates a new StateCondition
  9633. * @param actionManager manager for the action the condition applies to
  9634. * @param target of the condition
  9635. * @param value to compare with target state
  9636. */
  9637. constructor(actionManager: ActionManager, target: any,
  9638. /** Value to compare with target state */
  9639. value: string);
  9640. /**
  9641. * Gets a boolean indicating if the current condition is met
  9642. * @returns the validity of the state
  9643. */
  9644. isValid(): boolean;
  9645. /**
  9646. * Serialize the StateCondition into a JSON compatible object
  9647. * @returns serialization object
  9648. */
  9649. serialize(): any;
  9650. }
  9651. }
  9652. declare module BABYLON {
  9653. /**
  9654. * This defines an action responsible to toggle a boolean once triggered.
  9655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9656. */
  9657. export class SwitchBooleanAction extends Action {
  9658. /**
  9659. * The path to the boolean property in the target object
  9660. */
  9661. propertyPath: string;
  9662. private _target;
  9663. private _effectiveTarget;
  9664. private _property;
  9665. /**
  9666. * Instantiate the action
  9667. * @param triggerOptions defines the trigger options
  9668. * @param target defines the object containing the boolean
  9669. * @param propertyPath defines the path to the boolean property in the target object
  9670. * @param condition defines the trigger related conditions
  9671. */
  9672. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9673. /** @hidden */
  9674. _prepare(): void;
  9675. /**
  9676. * Execute the action toggle the boolean value.
  9677. */
  9678. execute(): void;
  9679. /**
  9680. * Serializes the actions and its related information.
  9681. * @param parent defines the object to serialize in
  9682. * @returns the serialized object
  9683. */
  9684. serialize(parent: any): any;
  9685. }
  9686. /**
  9687. * This defines an action responsible to set a the state field of the target
  9688. * to a desired value once triggered.
  9689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9690. */
  9691. export class SetStateAction extends Action {
  9692. /**
  9693. * The value to store in the state field.
  9694. */
  9695. value: string;
  9696. private _target;
  9697. /**
  9698. * Instantiate the action
  9699. * @param triggerOptions defines the trigger options
  9700. * @param target defines the object containing the state property
  9701. * @param value defines the value to store in the state field
  9702. * @param condition defines the trigger related conditions
  9703. */
  9704. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9705. /**
  9706. * Execute the action and store the value on the target state property.
  9707. */
  9708. execute(): void;
  9709. /**
  9710. * Serializes the actions and its related information.
  9711. * @param parent defines the object to serialize in
  9712. * @returns the serialized object
  9713. */
  9714. serialize(parent: any): any;
  9715. }
  9716. /**
  9717. * This defines an action responsible to set a property of the target
  9718. * to a desired value once triggered.
  9719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9720. */
  9721. export class SetValueAction extends Action {
  9722. /**
  9723. * The path of the property to set in the target.
  9724. */
  9725. propertyPath: string;
  9726. /**
  9727. * The value to set in the property
  9728. */
  9729. value: any;
  9730. private _target;
  9731. private _effectiveTarget;
  9732. private _property;
  9733. /**
  9734. * Instantiate the action
  9735. * @param triggerOptions defines the trigger options
  9736. * @param target defines the object containing the property
  9737. * @param propertyPath defines the path of the property to set in the target
  9738. * @param value defines the value to set in the property
  9739. * @param condition defines the trigger related conditions
  9740. */
  9741. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9742. /** @hidden */
  9743. _prepare(): void;
  9744. /**
  9745. * Execute the action and set the targetted property to the desired value.
  9746. */
  9747. execute(): void;
  9748. /**
  9749. * Serializes the actions and its related information.
  9750. * @param parent defines the object to serialize in
  9751. * @returns the serialized object
  9752. */
  9753. serialize(parent: any): any;
  9754. }
  9755. /**
  9756. * This defines an action responsible to increment the target value
  9757. * to a desired value once triggered.
  9758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9759. */
  9760. export class IncrementValueAction extends Action {
  9761. /**
  9762. * The path of the property to increment in the target.
  9763. */
  9764. propertyPath: string;
  9765. /**
  9766. * The value we should increment the property by.
  9767. */
  9768. value: any;
  9769. private _target;
  9770. private _effectiveTarget;
  9771. private _property;
  9772. /**
  9773. * Instantiate the action
  9774. * @param triggerOptions defines the trigger options
  9775. * @param target defines the object containing the property
  9776. * @param propertyPath defines the path of the property to increment in the target
  9777. * @param value defines the value value we should increment the property by
  9778. * @param condition defines the trigger related conditions
  9779. */
  9780. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9781. /** @hidden */
  9782. _prepare(): void;
  9783. /**
  9784. * Execute the action and increment the target of the value amount.
  9785. */
  9786. execute(): void;
  9787. /**
  9788. * Serializes the actions and its related information.
  9789. * @param parent defines the object to serialize in
  9790. * @returns the serialized object
  9791. */
  9792. serialize(parent: any): any;
  9793. }
  9794. /**
  9795. * This defines an action responsible to start an animation once triggered.
  9796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9797. */
  9798. export class PlayAnimationAction extends Action {
  9799. /**
  9800. * Where the animation should start (animation frame)
  9801. */
  9802. from: number;
  9803. /**
  9804. * Where the animation should stop (animation frame)
  9805. */
  9806. to: number;
  9807. /**
  9808. * Define if the animation should loop or stop after the first play.
  9809. */
  9810. loop?: boolean;
  9811. private _target;
  9812. /**
  9813. * Instantiate the action
  9814. * @param triggerOptions defines the trigger options
  9815. * @param target defines the target animation or animation name
  9816. * @param from defines from where the animation should start (animation frame)
  9817. * @param end defines where the animation should stop (animation frame)
  9818. * @param loop defines if the animation should loop or stop after the first play
  9819. * @param condition defines the trigger related conditions
  9820. */
  9821. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9822. /** @hidden */
  9823. _prepare(): void;
  9824. /**
  9825. * Execute the action and play the animation.
  9826. */
  9827. execute(): void;
  9828. /**
  9829. * Serializes the actions and its related information.
  9830. * @param parent defines the object to serialize in
  9831. * @returns the serialized object
  9832. */
  9833. serialize(parent: any): any;
  9834. }
  9835. /**
  9836. * This defines an action responsible to stop an animation once triggered.
  9837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9838. */
  9839. export class StopAnimationAction extends Action {
  9840. private _target;
  9841. /**
  9842. * Instantiate the action
  9843. * @param triggerOptions defines the trigger options
  9844. * @param target defines the target animation or animation name
  9845. * @param condition defines the trigger related conditions
  9846. */
  9847. constructor(triggerOptions: any, target: any, condition?: Condition);
  9848. /** @hidden */
  9849. _prepare(): void;
  9850. /**
  9851. * Execute the action and stop the animation.
  9852. */
  9853. execute(): void;
  9854. /**
  9855. * Serializes the actions and its related information.
  9856. * @param parent defines the object to serialize in
  9857. * @returns the serialized object
  9858. */
  9859. serialize(parent: any): any;
  9860. }
  9861. /**
  9862. * This defines an action responsible that does nothing once triggered.
  9863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9864. */
  9865. export class DoNothingAction extends Action {
  9866. /**
  9867. * Instantiate the action
  9868. * @param triggerOptions defines the trigger options
  9869. * @param condition defines the trigger related conditions
  9870. */
  9871. constructor(triggerOptions?: any, condition?: Condition);
  9872. /**
  9873. * Execute the action and do nothing.
  9874. */
  9875. execute(): void;
  9876. /**
  9877. * Serializes the actions and its related information.
  9878. * @param parent defines the object to serialize in
  9879. * @returns the serialized object
  9880. */
  9881. serialize(parent: any): any;
  9882. }
  9883. /**
  9884. * This defines an action responsible to trigger several actions once triggered.
  9885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9886. */
  9887. export class CombineAction extends Action {
  9888. /**
  9889. * The list of aggregated animations to run.
  9890. */
  9891. children: Action[];
  9892. /**
  9893. * Instantiate the action
  9894. * @param triggerOptions defines the trigger options
  9895. * @param children defines the list of aggregated animations to run
  9896. * @param condition defines the trigger related conditions
  9897. */
  9898. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9899. /** @hidden */
  9900. _prepare(): void;
  9901. /**
  9902. * Execute the action and executes all the aggregated actions.
  9903. */
  9904. execute(evt: ActionEvent): void;
  9905. /**
  9906. * Serializes the actions and its related information.
  9907. * @param parent defines the object to serialize in
  9908. * @returns the serialized object
  9909. */
  9910. serialize(parent: any): any;
  9911. }
  9912. /**
  9913. * This defines an action responsible to run code (external event) once triggered.
  9914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9915. */
  9916. export class ExecuteCodeAction extends Action {
  9917. /**
  9918. * The callback function to run.
  9919. */
  9920. func: (evt: ActionEvent) => void;
  9921. /**
  9922. * Instantiate the action
  9923. * @param triggerOptions defines the trigger options
  9924. * @param func defines the callback function to run
  9925. * @param condition defines the trigger related conditions
  9926. */
  9927. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9928. /**
  9929. * Execute the action and run the attached code.
  9930. */
  9931. execute(evt: ActionEvent): void;
  9932. }
  9933. /**
  9934. * This defines an action responsible to set the parent property of the target once triggered.
  9935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9936. */
  9937. export class SetParentAction extends Action {
  9938. private _parent;
  9939. private _target;
  9940. /**
  9941. * Instantiate the action
  9942. * @param triggerOptions defines the trigger options
  9943. * @param target defines the target containing the parent property
  9944. * @param parent defines from where the animation should start (animation frame)
  9945. * @param condition defines the trigger related conditions
  9946. */
  9947. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9948. /** @hidden */
  9949. _prepare(): void;
  9950. /**
  9951. * Execute the action and set the parent property.
  9952. */
  9953. execute(): void;
  9954. /**
  9955. * Serializes the actions and its related information.
  9956. * @param parent defines the object to serialize in
  9957. * @returns the serialized object
  9958. */
  9959. serialize(parent: any): any;
  9960. }
  9961. }
  9962. declare module BABYLON {
  9963. /**
  9964. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9965. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9967. */
  9968. export class ActionManager extends AbstractActionManager {
  9969. /**
  9970. * Nothing
  9971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9972. */
  9973. static readonly NothingTrigger: number;
  9974. /**
  9975. * On pick
  9976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9977. */
  9978. static readonly OnPickTrigger: number;
  9979. /**
  9980. * On left pick
  9981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9982. */
  9983. static readonly OnLeftPickTrigger: number;
  9984. /**
  9985. * On right pick
  9986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9987. */
  9988. static readonly OnRightPickTrigger: number;
  9989. /**
  9990. * On center pick
  9991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9992. */
  9993. static readonly OnCenterPickTrigger: number;
  9994. /**
  9995. * On pick down
  9996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9997. */
  9998. static readonly OnPickDownTrigger: number;
  9999. /**
  10000. * On double pick
  10001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10002. */
  10003. static readonly OnDoublePickTrigger: number;
  10004. /**
  10005. * On pick up
  10006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10007. */
  10008. static readonly OnPickUpTrigger: number;
  10009. /**
  10010. * On pick out.
  10011. * This trigger will only be raised if you also declared a OnPickDown
  10012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10013. */
  10014. static readonly OnPickOutTrigger: number;
  10015. /**
  10016. * On long press
  10017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10018. */
  10019. static readonly OnLongPressTrigger: number;
  10020. /**
  10021. * On pointer over
  10022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10023. */
  10024. static readonly OnPointerOverTrigger: number;
  10025. /**
  10026. * On pointer out
  10027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10028. */
  10029. static readonly OnPointerOutTrigger: number;
  10030. /**
  10031. * On every frame
  10032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10033. */
  10034. static readonly OnEveryFrameTrigger: number;
  10035. /**
  10036. * On intersection enter
  10037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10038. */
  10039. static readonly OnIntersectionEnterTrigger: number;
  10040. /**
  10041. * On intersection exit
  10042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10043. */
  10044. static readonly OnIntersectionExitTrigger: number;
  10045. /**
  10046. * On key down
  10047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10048. */
  10049. static readonly OnKeyDownTrigger: number;
  10050. /**
  10051. * On key up
  10052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10053. */
  10054. static readonly OnKeyUpTrigger: number;
  10055. private _scene;
  10056. /**
  10057. * Creates a new action manager
  10058. * @param scene defines the hosting scene
  10059. */
  10060. constructor(scene: Scene);
  10061. /**
  10062. * Releases all associated resources
  10063. */
  10064. dispose(): void;
  10065. /**
  10066. * Gets hosting scene
  10067. * @returns the hosting scene
  10068. */
  10069. getScene(): Scene;
  10070. /**
  10071. * Does this action manager handles actions of any of the given triggers
  10072. * @param triggers defines the triggers to be tested
  10073. * @return a boolean indicating whether one (or more) of the triggers is handled
  10074. */
  10075. hasSpecificTriggers(triggers: number[]): boolean;
  10076. /**
  10077. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10078. * speed.
  10079. * @param triggerA defines the trigger to be tested
  10080. * @param triggerB defines the trigger to be tested
  10081. * @return a boolean indicating whether one (or more) of the triggers is handled
  10082. */
  10083. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10084. /**
  10085. * Does this action manager handles actions of a given trigger
  10086. * @param trigger defines the trigger to be tested
  10087. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10088. * @return whether the trigger is handled
  10089. */
  10090. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10091. /**
  10092. * Does this action manager has pointer triggers
  10093. */
  10094. get hasPointerTriggers(): boolean;
  10095. /**
  10096. * Does this action manager has pick triggers
  10097. */
  10098. get hasPickTriggers(): boolean;
  10099. /**
  10100. * Registers an action to this action manager
  10101. * @param action defines the action to be registered
  10102. * @return the action amended (prepared) after registration
  10103. */
  10104. registerAction(action: IAction): Nullable<IAction>;
  10105. /**
  10106. * Unregisters an action to this action manager
  10107. * @param action defines the action to be unregistered
  10108. * @return a boolean indicating whether the action has been unregistered
  10109. */
  10110. unregisterAction(action: IAction): Boolean;
  10111. /**
  10112. * Process a specific trigger
  10113. * @param trigger defines the trigger to process
  10114. * @param evt defines the event details to be processed
  10115. */
  10116. processTrigger(trigger: number, evt?: IActionEvent): void;
  10117. /** @hidden */
  10118. _getEffectiveTarget(target: any, propertyPath: string): any;
  10119. /** @hidden */
  10120. _getProperty(propertyPath: string): string;
  10121. /**
  10122. * Serialize this manager to a JSON object
  10123. * @param name defines the property name to store this manager
  10124. * @returns a JSON representation of this manager
  10125. */
  10126. serialize(name: string): any;
  10127. /**
  10128. * Creates a new ActionManager from a JSON data
  10129. * @param parsedActions defines the JSON data to read from
  10130. * @param object defines the hosting mesh
  10131. * @param scene defines the hosting scene
  10132. */
  10133. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10134. /**
  10135. * Get a trigger name by index
  10136. * @param trigger defines the trigger index
  10137. * @returns a trigger name
  10138. */
  10139. static GetTriggerName(trigger: number): string;
  10140. }
  10141. }
  10142. declare module BABYLON {
  10143. /**
  10144. * Class used to represent a sprite
  10145. * @see http://doc.babylonjs.com/babylon101/sprites
  10146. */
  10147. export class Sprite implements IAnimatable {
  10148. /** defines the name */
  10149. name: string;
  10150. /** Gets or sets the current world position */
  10151. position: Vector3;
  10152. /** Gets or sets the main color */
  10153. color: Color4;
  10154. /** Gets or sets the width */
  10155. width: number;
  10156. /** Gets or sets the height */
  10157. height: number;
  10158. /** Gets or sets rotation angle */
  10159. angle: number;
  10160. /** Gets or sets the cell index in the sprite sheet */
  10161. cellIndex: number;
  10162. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10163. cellRef: string;
  10164. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10165. invertU: boolean;
  10166. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10167. invertV: boolean;
  10168. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10169. disposeWhenFinishedAnimating: boolean;
  10170. /** Gets the list of attached animations */
  10171. animations: Nullable<Array<Animation>>;
  10172. /** Gets or sets a boolean indicating if the sprite can be picked */
  10173. isPickable: boolean;
  10174. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10175. useAlphaForPicking: boolean;
  10176. /** @hidden */
  10177. _xOffset: number;
  10178. /** @hidden */
  10179. _yOffset: number;
  10180. /** @hidden */
  10181. _xSize: number;
  10182. /** @hidden */
  10183. _ySize: number;
  10184. /**
  10185. * Gets or sets the associated action manager
  10186. */
  10187. actionManager: Nullable<ActionManager>;
  10188. /**
  10189. * An event triggered when the control has been disposed
  10190. */
  10191. onDisposeObservable: Observable<Sprite>;
  10192. private _animationStarted;
  10193. private _loopAnimation;
  10194. private _fromIndex;
  10195. private _toIndex;
  10196. private _delay;
  10197. private _direction;
  10198. private _manager;
  10199. private _time;
  10200. private _onAnimationEnd;
  10201. /**
  10202. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10203. */
  10204. isVisible: boolean;
  10205. /**
  10206. * Gets or sets the sprite size
  10207. */
  10208. get size(): number;
  10209. set size(value: number);
  10210. /**
  10211. * Returns a boolean indicating if the animation is started
  10212. */
  10213. get animationStarted(): boolean;
  10214. /**
  10215. * Gets or sets the unique id of the sprite
  10216. */
  10217. uniqueId: number;
  10218. /**
  10219. * Gets the manager of this sprite
  10220. */
  10221. get manager(): ISpriteManager;
  10222. /**
  10223. * Creates a new Sprite
  10224. * @param name defines the name
  10225. * @param manager defines the manager
  10226. */
  10227. constructor(
  10228. /** defines the name */
  10229. name: string, manager: ISpriteManager);
  10230. /**
  10231. * Returns the string "Sprite"
  10232. * @returns "Sprite"
  10233. */
  10234. getClassName(): string;
  10235. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10236. get fromIndex(): number;
  10237. set fromIndex(value: number);
  10238. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10239. get toIndex(): number;
  10240. set toIndex(value: number);
  10241. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10242. get loopAnimation(): boolean;
  10243. set loopAnimation(value: boolean);
  10244. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10245. get delay(): number;
  10246. set delay(value: number);
  10247. /**
  10248. * Starts an animation
  10249. * @param from defines the initial key
  10250. * @param to defines the end key
  10251. * @param loop defines if the animation must loop
  10252. * @param delay defines the start delay (in ms)
  10253. * @param onAnimationEnd defines a callback to call when animation ends
  10254. */
  10255. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10256. /** Stops current animation (if any) */
  10257. stopAnimation(): void;
  10258. /** @hidden */
  10259. _animate(deltaTime: number): void;
  10260. /** Release associated resources */
  10261. dispose(): void;
  10262. /**
  10263. * Serializes the sprite to a JSON object
  10264. * @returns the JSON object
  10265. */
  10266. serialize(): any;
  10267. /**
  10268. * Parses a JSON object to create a new sprite
  10269. * @param parsedSprite The JSON object to parse
  10270. * @param manager defines the hosting manager
  10271. * @returns the new sprite
  10272. */
  10273. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10274. }
  10275. }
  10276. declare module BABYLON {
  10277. /**
  10278. * Information about the result of picking within a scene
  10279. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10280. */
  10281. export class PickingInfo {
  10282. /** @hidden */
  10283. _pickingUnavailable: boolean;
  10284. /**
  10285. * If the pick collided with an object
  10286. */
  10287. hit: boolean;
  10288. /**
  10289. * Distance away where the pick collided
  10290. */
  10291. distance: number;
  10292. /**
  10293. * The location of pick collision
  10294. */
  10295. pickedPoint: Nullable<Vector3>;
  10296. /**
  10297. * The mesh corresponding the the pick collision
  10298. */
  10299. pickedMesh: Nullable<AbstractMesh>;
  10300. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10301. bu: number;
  10302. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10303. bv: number;
  10304. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10305. faceId: number;
  10306. /** Id of the the submesh that was picked */
  10307. subMeshId: number;
  10308. /** If a sprite was picked, this will be the sprite the pick collided with */
  10309. pickedSprite: Nullable<Sprite>;
  10310. /**
  10311. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10312. */
  10313. originMesh: Nullable<AbstractMesh>;
  10314. /**
  10315. * The ray that was used to perform the picking.
  10316. */
  10317. ray: Nullable<Ray>;
  10318. /**
  10319. * Gets the normal correspodning to the face the pick collided with
  10320. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10321. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10322. * @returns The normal correspodning to the face the pick collided with
  10323. */
  10324. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10325. /**
  10326. * Gets the texture coordinates of where the pick occured
  10327. * @returns the vector containing the coordnates of the texture
  10328. */
  10329. getTextureCoordinates(): Nullable<Vector2>;
  10330. }
  10331. }
  10332. declare module BABYLON {
  10333. /**
  10334. * Class representing a ray with position and direction
  10335. */
  10336. export class Ray {
  10337. /** origin point */
  10338. origin: Vector3;
  10339. /** direction */
  10340. direction: Vector3;
  10341. /** length of the ray */
  10342. length: number;
  10343. private static readonly TmpVector3;
  10344. private _tmpRay;
  10345. /**
  10346. * Creates a new ray
  10347. * @param origin origin point
  10348. * @param direction direction
  10349. * @param length length of the ray
  10350. */
  10351. constructor(
  10352. /** origin point */
  10353. origin: Vector3,
  10354. /** direction */
  10355. direction: Vector3,
  10356. /** length of the ray */
  10357. length?: number);
  10358. /**
  10359. * Checks if the ray intersects a box
  10360. * This does not account for the ray lenght by design to improve perfs.
  10361. * @param minimum bound of the box
  10362. * @param maximum bound of the box
  10363. * @param intersectionTreshold extra extend to be added to the box in all direction
  10364. * @returns if the box was hit
  10365. */
  10366. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10367. /**
  10368. * Checks if the ray intersects a box
  10369. * This does not account for the ray lenght by design to improve perfs.
  10370. * @param box the bounding box to check
  10371. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10372. * @returns if the box was hit
  10373. */
  10374. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10375. /**
  10376. * If the ray hits a sphere
  10377. * @param sphere the bounding sphere to check
  10378. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10379. * @returns true if it hits the sphere
  10380. */
  10381. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10382. /**
  10383. * If the ray hits a triange
  10384. * @param vertex0 triangle vertex
  10385. * @param vertex1 triangle vertex
  10386. * @param vertex2 triangle vertex
  10387. * @returns intersection information if hit
  10388. */
  10389. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10390. /**
  10391. * Checks if ray intersects a plane
  10392. * @param plane the plane to check
  10393. * @returns the distance away it was hit
  10394. */
  10395. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10396. /**
  10397. * Calculate the intercept of a ray on a given axis
  10398. * @param axis to check 'x' | 'y' | 'z'
  10399. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10400. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10401. */
  10402. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10403. /**
  10404. * Checks if ray intersects a mesh
  10405. * @param mesh the mesh to check
  10406. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10407. * @returns picking info of the intersecton
  10408. */
  10409. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10410. /**
  10411. * Checks if ray intersects a mesh
  10412. * @param meshes the meshes to check
  10413. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10414. * @param results array to store result in
  10415. * @returns Array of picking infos
  10416. */
  10417. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10418. private _comparePickingInfo;
  10419. private static smallnum;
  10420. private static rayl;
  10421. /**
  10422. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10423. * @param sega the first point of the segment to test the intersection against
  10424. * @param segb the second point of the segment to test the intersection against
  10425. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10426. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10427. */
  10428. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10429. /**
  10430. * Update the ray from viewport position
  10431. * @param x position
  10432. * @param y y position
  10433. * @param viewportWidth viewport width
  10434. * @param viewportHeight viewport height
  10435. * @param world world matrix
  10436. * @param view view matrix
  10437. * @param projection projection matrix
  10438. * @returns this ray updated
  10439. */
  10440. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10441. /**
  10442. * Creates a ray with origin and direction of 0,0,0
  10443. * @returns the new ray
  10444. */
  10445. static Zero(): Ray;
  10446. /**
  10447. * Creates a new ray from screen space and viewport
  10448. * @param x position
  10449. * @param y y position
  10450. * @param viewportWidth viewport width
  10451. * @param viewportHeight viewport height
  10452. * @param world world matrix
  10453. * @param view view matrix
  10454. * @param projection projection matrix
  10455. * @returns new ray
  10456. */
  10457. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10458. /**
  10459. * 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
  10460. * transformed to the given world matrix.
  10461. * @param origin The origin point
  10462. * @param end The end point
  10463. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10464. * @returns the new ray
  10465. */
  10466. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10467. /**
  10468. * Transforms a ray by a matrix
  10469. * @param ray ray to transform
  10470. * @param matrix matrix to apply
  10471. * @returns the resulting new ray
  10472. */
  10473. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10474. /**
  10475. * Transforms a ray by a matrix
  10476. * @param ray ray to transform
  10477. * @param matrix matrix to apply
  10478. * @param result ray to store result in
  10479. */
  10480. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10481. /**
  10482. * Unproject a ray from screen space to object space
  10483. * @param sourceX defines the screen space x coordinate to use
  10484. * @param sourceY defines the screen space y coordinate to use
  10485. * @param viewportWidth defines the current width of the viewport
  10486. * @param viewportHeight defines the current height of the viewport
  10487. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10488. * @param view defines the view matrix to use
  10489. * @param projection defines the projection matrix to use
  10490. */
  10491. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10492. }
  10493. /**
  10494. * Type used to define predicate used to select faces when a mesh intersection is detected
  10495. */
  10496. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10497. interface Scene {
  10498. /** @hidden */
  10499. _tempPickingRay: Nullable<Ray>;
  10500. /** @hidden */
  10501. _cachedRayForTransform: Ray;
  10502. /** @hidden */
  10503. _pickWithRayInverseMatrix: Matrix;
  10504. /** @hidden */
  10505. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10506. /** @hidden */
  10507. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10508. }
  10509. }
  10510. declare module BABYLON {
  10511. /**
  10512. * Groups all the scene component constants in one place to ease maintenance.
  10513. * @hidden
  10514. */
  10515. export class SceneComponentConstants {
  10516. static readonly NAME_EFFECTLAYER: string;
  10517. static readonly NAME_LAYER: string;
  10518. static readonly NAME_LENSFLARESYSTEM: string;
  10519. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10520. static readonly NAME_PARTICLESYSTEM: string;
  10521. static readonly NAME_GAMEPAD: string;
  10522. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10523. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10524. static readonly NAME_DEPTHRENDERER: string;
  10525. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10526. static readonly NAME_SPRITE: string;
  10527. static readonly NAME_OUTLINERENDERER: string;
  10528. static readonly NAME_PROCEDURALTEXTURE: string;
  10529. static readonly NAME_SHADOWGENERATOR: string;
  10530. static readonly NAME_OCTREE: string;
  10531. static readonly NAME_PHYSICSENGINE: string;
  10532. static readonly NAME_AUDIO: string;
  10533. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10534. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10535. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10536. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10537. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10538. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10539. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10540. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10541. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10542. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10543. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10544. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10545. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10546. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10547. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10548. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10549. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10550. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10551. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10552. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10553. static readonly STEP_AFTERRENDER_AUDIO: number;
  10554. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10555. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10556. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10557. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10558. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10559. static readonly STEP_POINTERMOVE_SPRITE: number;
  10560. static readonly STEP_POINTERDOWN_SPRITE: number;
  10561. static readonly STEP_POINTERUP_SPRITE: number;
  10562. }
  10563. /**
  10564. * This represents a scene component.
  10565. *
  10566. * This is used to decouple the dependency the scene is having on the different workloads like
  10567. * layers, post processes...
  10568. */
  10569. export interface ISceneComponent {
  10570. /**
  10571. * The name of the component. Each component must have a unique name.
  10572. */
  10573. name: string;
  10574. /**
  10575. * The scene the component belongs to.
  10576. */
  10577. scene: Scene;
  10578. /**
  10579. * Register the component to one instance of a scene.
  10580. */
  10581. register(): void;
  10582. /**
  10583. * Rebuilds the elements related to this component in case of
  10584. * context lost for instance.
  10585. */
  10586. rebuild(): void;
  10587. /**
  10588. * Disposes the component and the associated ressources.
  10589. */
  10590. dispose(): void;
  10591. }
  10592. /**
  10593. * This represents a SERIALIZABLE scene component.
  10594. *
  10595. * This extends Scene Component to add Serialization methods on top.
  10596. */
  10597. export interface ISceneSerializableComponent extends ISceneComponent {
  10598. /**
  10599. * Adds all the elements from the container to the scene
  10600. * @param container the container holding the elements
  10601. */
  10602. addFromContainer(container: AbstractScene): void;
  10603. /**
  10604. * Removes all the elements in the container from the scene
  10605. * @param container contains the elements to remove
  10606. * @param dispose if the removed element should be disposed (default: false)
  10607. */
  10608. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10609. /**
  10610. * Serializes the component data to the specified json object
  10611. * @param serializationObject The object to serialize to
  10612. */
  10613. serialize(serializationObject: any): void;
  10614. }
  10615. /**
  10616. * Strong typing of a Mesh related stage step action
  10617. */
  10618. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10619. /**
  10620. * Strong typing of a Evaluate Sub Mesh related stage step action
  10621. */
  10622. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10623. /**
  10624. * Strong typing of a Active Mesh related stage step action
  10625. */
  10626. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10627. /**
  10628. * Strong typing of a Camera related stage step action
  10629. */
  10630. export type CameraStageAction = (camera: Camera) => void;
  10631. /**
  10632. * Strong typing of a Camera Frame buffer related stage step action
  10633. */
  10634. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10635. /**
  10636. * Strong typing of a Render Target related stage step action
  10637. */
  10638. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10639. /**
  10640. * Strong typing of a RenderingGroup related stage step action
  10641. */
  10642. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10643. /**
  10644. * Strong typing of a Mesh Render related stage step action
  10645. */
  10646. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10647. /**
  10648. * Strong typing of a simple stage step action
  10649. */
  10650. export type SimpleStageAction = () => void;
  10651. /**
  10652. * Strong typing of a render target action.
  10653. */
  10654. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10655. /**
  10656. * Strong typing of a pointer move action.
  10657. */
  10658. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10659. /**
  10660. * Strong typing of a pointer up/down action.
  10661. */
  10662. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10663. /**
  10664. * Representation of a stage in the scene (Basically a list of ordered steps)
  10665. * @hidden
  10666. */
  10667. export class Stage<T extends Function> extends Array<{
  10668. index: number;
  10669. component: ISceneComponent;
  10670. action: T;
  10671. }> {
  10672. /**
  10673. * Hide ctor from the rest of the world.
  10674. * @param items The items to add.
  10675. */
  10676. private constructor();
  10677. /**
  10678. * Creates a new Stage.
  10679. * @returns A new instance of a Stage
  10680. */
  10681. static Create<T extends Function>(): Stage<T>;
  10682. /**
  10683. * Registers a step in an ordered way in the targeted stage.
  10684. * @param index Defines the position to register the step in
  10685. * @param component Defines the component attached to the step
  10686. * @param action Defines the action to launch during the step
  10687. */
  10688. registerStep(index: number, component: ISceneComponent, action: T): void;
  10689. /**
  10690. * Clears all the steps from the stage.
  10691. */
  10692. clear(): void;
  10693. }
  10694. }
  10695. declare module BABYLON {
  10696. interface Scene {
  10697. /** @hidden */
  10698. _pointerOverSprite: Nullable<Sprite>;
  10699. /** @hidden */
  10700. _pickedDownSprite: Nullable<Sprite>;
  10701. /** @hidden */
  10702. _tempSpritePickingRay: Nullable<Ray>;
  10703. /**
  10704. * All of the sprite managers added to this scene
  10705. * @see http://doc.babylonjs.com/babylon101/sprites
  10706. */
  10707. spriteManagers: Array<ISpriteManager>;
  10708. /**
  10709. * An event triggered when sprites rendering is about to start
  10710. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10711. */
  10712. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10713. /**
  10714. * An event triggered when sprites rendering is done
  10715. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10716. */
  10717. onAfterSpritesRenderingObservable: Observable<Scene>;
  10718. /** @hidden */
  10719. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10720. /** Launch a ray to try to pick a sprite in the scene
  10721. * @param x position on screen
  10722. * @param y position on screen
  10723. * @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
  10724. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10725. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10726. * @returns a PickingInfo
  10727. */
  10728. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10729. /** Use the given ray to pick a sprite in the scene
  10730. * @param ray The ray (in world space) to use to pick meshes
  10731. * @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
  10732. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10733. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10734. * @returns a PickingInfo
  10735. */
  10736. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10737. /** @hidden */
  10738. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10739. /** Launch a ray to try to pick sprites in the scene
  10740. * @param x position on screen
  10741. * @param y position on screen
  10742. * @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
  10743. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10744. * @returns a PickingInfo array
  10745. */
  10746. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10747. /** Use the given ray to pick sprites in the scene
  10748. * @param ray The ray (in world space) to use to pick meshes
  10749. * @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
  10750. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10751. * @returns a PickingInfo array
  10752. */
  10753. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10754. /**
  10755. * Force the sprite under the pointer
  10756. * @param sprite defines the sprite to use
  10757. */
  10758. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10759. /**
  10760. * Gets the sprite under the pointer
  10761. * @returns a Sprite or null if no sprite is under the pointer
  10762. */
  10763. getPointerOverSprite(): Nullable<Sprite>;
  10764. }
  10765. /**
  10766. * Defines the sprite scene component responsible to manage sprites
  10767. * in a given scene.
  10768. */
  10769. export class SpriteSceneComponent implements ISceneComponent {
  10770. /**
  10771. * The component name helpfull to identify the component in the list of scene components.
  10772. */
  10773. readonly name: string;
  10774. /**
  10775. * The scene the component belongs to.
  10776. */
  10777. scene: Scene;
  10778. /** @hidden */
  10779. private _spritePredicate;
  10780. /**
  10781. * Creates a new instance of the component for the given scene
  10782. * @param scene Defines the scene to register the component in
  10783. */
  10784. constructor(scene: Scene);
  10785. /**
  10786. * Registers the component in a given scene
  10787. */
  10788. register(): void;
  10789. /**
  10790. * Rebuilds the elements related to this component in case of
  10791. * context lost for instance.
  10792. */
  10793. rebuild(): void;
  10794. /**
  10795. * Disposes the component and the associated ressources.
  10796. */
  10797. dispose(): void;
  10798. private _pickSpriteButKeepRay;
  10799. private _pointerMove;
  10800. private _pointerDown;
  10801. private _pointerUp;
  10802. }
  10803. }
  10804. declare module BABYLON {
  10805. /** @hidden */
  10806. export var fogFragmentDeclaration: {
  10807. name: string;
  10808. shader: string;
  10809. };
  10810. }
  10811. declare module BABYLON {
  10812. /** @hidden */
  10813. export var fogFragment: {
  10814. name: string;
  10815. shader: string;
  10816. };
  10817. }
  10818. declare module BABYLON {
  10819. /** @hidden */
  10820. export var spritesPixelShader: {
  10821. name: string;
  10822. shader: string;
  10823. };
  10824. }
  10825. declare module BABYLON {
  10826. /** @hidden */
  10827. export var fogVertexDeclaration: {
  10828. name: string;
  10829. shader: string;
  10830. };
  10831. }
  10832. declare module BABYLON {
  10833. /** @hidden */
  10834. export var spritesVertexShader: {
  10835. name: string;
  10836. shader: string;
  10837. };
  10838. }
  10839. declare module BABYLON {
  10840. /**
  10841. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10842. */
  10843. export interface ISpriteManager extends IDisposable {
  10844. /**
  10845. * Gets manager's name
  10846. */
  10847. name: string;
  10848. /**
  10849. * Restricts the camera to viewing objects with the same layerMask.
  10850. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10851. */
  10852. layerMask: number;
  10853. /**
  10854. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10855. */
  10856. isPickable: boolean;
  10857. /**
  10858. * Gets the hosting scene
  10859. */
  10860. scene: Scene;
  10861. /**
  10862. * Specifies the rendering group id for this mesh (0 by default)
  10863. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10864. */
  10865. renderingGroupId: number;
  10866. /**
  10867. * Defines the list of sprites managed by the manager.
  10868. */
  10869. sprites: Array<Sprite>;
  10870. /**
  10871. * Gets or sets the spritesheet texture
  10872. */
  10873. texture: Texture;
  10874. /** Defines the default width of a cell in the spritesheet */
  10875. cellWidth: number;
  10876. /** Defines the default height of a cell in the spritesheet */
  10877. cellHeight: number;
  10878. /**
  10879. * Tests the intersection of a sprite with a specific ray.
  10880. * @param ray The ray we are sending to test the collision
  10881. * @param camera The camera space we are sending rays in
  10882. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10883. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10884. * @returns picking info or null.
  10885. */
  10886. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10887. /**
  10888. * Intersects the sprites with a ray
  10889. * @param ray defines the ray to intersect with
  10890. * @param camera defines the current active camera
  10891. * @param predicate defines a predicate used to select candidate sprites
  10892. * @returns null if no hit or a PickingInfo array
  10893. */
  10894. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10895. /**
  10896. * Renders the list of sprites on screen.
  10897. */
  10898. render(): void;
  10899. }
  10900. /**
  10901. * Class used to manage multiple sprites on the same spritesheet
  10902. * @see http://doc.babylonjs.com/babylon101/sprites
  10903. */
  10904. export class SpriteManager implements ISpriteManager {
  10905. /** defines the manager's name */
  10906. name: string;
  10907. /** Define the Url to load snippets */
  10908. static SnippetUrl: string;
  10909. /** Snippet ID if the manager was created from the snippet server */
  10910. snippetId: string;
  10911. /** Gets the list of sprites */
  10912. sprites: Sprite[];
  10913. /** Gets or sets the rendering group id (0 by default) */
  10914. renderingGroupId: number;
  10915. /** Gets or sets camera layer mask */
  10916. layerMask: number;
  10917. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10918. fogEnabled: boolean;
  10919. /** Gets or sets a boolean indicating if the sprites are pickable */
  10920. isPickable: boolean;
  10921. /** Defines the default width of a cell in the spritesheet */
  10922. cellWidth: number;
  10923. /** Defines the default height of a cell in the spritesheet */
  10924. cellHeight: number;
  10925. /** Associative array from JSON sprite data file */
  10926. private _cellData;
  10927. /** Array of sprite names from JSON sprite data file */
  10928. private _spriteMap;
  10929. /** True when packed cell data from JSON file is ready*/
  10930. private _packedAndReady;
  10931. private _textureContent;
  10932. /**
  10933. * An event triggered when the manager is disposed.
  10934. */
  10935. onDisposeObservable: Observable<SpriteManager>;
  10936. private _onDisposeObserver;
  10937. /**
  10938. * Callback called when the manager is disposed
  10939. */
  10940. set onDispose(callback: () => void);
  10941. private _capacity;
  10942. private _fromPacked;
  10943. private _spriteTexture;
  10944. private _epsilon;
  10945. private _scene;
  10946. private _vertexData;
  10947. private _buffer;
  10948. private _vertexBuffers;
  10949. private _indexBuffer;
  10950. private _effectBase;
  10951. private _effectFog;
  10952. /**
  10953. * Gets or sets the unique id of the sprite
  10954. */
  10955. uniqueId: number;
  10956. /**
  10957. * Gets the array of sprites
  10958. */
  10959. get children(): Sprite[];
  10960. /**
  10961. * Gets the hosting scene
  10962. */
  10963. get scene(): Scene;
  10964. /**
  10965. * Gets the capacity of the manager
  10966. */
  10967. get capacity(): number;
  10968. /**
  10969. * Gets or sets the spritesheet texture
  10970. */
  10971. get texture(): Texture;
  10972. set texture(value: Texture);
  10973. private _blendMode;
  10974. /**
  10975. * Blend mode use to render the particle, it can be any of
  10976. * the static Constants.ALPHA_x properties provided in this class.
  10977. * Default value is Constants.ALPHA_COMBINE
  10978. */
  10979. get blendMode(): number;
  10980. set blendMode(blendMode: number);
  10981. /** Disables writing to the depth buffer when rendering the sprites.
  10982. * It can be handy to disable depth writing when using textures without alpha channel
  10983. * and setting some specific blend modes.
  10984. */
  10985. disableDepthWrite: boolean;
  10986. /**
  10987. * Creates a new sprite manager
  10988. * @param name defines the manager's name
  10989. * @param imgUrl defines the sprite sheet url
  10990. * @param capacity defines the maximum allowed number of sprites
  10991. * @param cellSize defines the size of a sprite cell
  10992. * @param scene defines the hosting scene
  10993. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10994. * @param samplingMode defines the smapling mode to use with spritesheet
  10995. * @param fromPacked set to false; do not alter
  10996. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10997. */
  10998. constructor(
  10999. /** defines the manager's name */
  11000. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11001. /**
  11002. * Returns the string "SpriteManager"
  11003. * @returns "SpriteManager"
  11004. */
  11005. getClassName(): string;
  11006. private _makePacked;
  11007. private _appendSpriteVertex;
  11008. private _checkTextureAlpha;
  11009. /**
  11010. * Intersects the sprites with a ray
  11011. * @param ray defines the ray to intersect with
  11012. * @param camera defines the current active camera
  11013. * @param predicate defines a predicate used to select candidate sprites
  11014. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11015. * @returns null if no hit or a PickingInfo
  11016. */
  11017. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11018. /**
  11019. * Intersects the sprites with a ray
  11020. * @param ray defines the ray to intersect with
  11021. * @param camera defines the current active camera
  11022. * @param predicate defines a predicate used to select candidate sprites
  11023. * @returns null if no hit or a PickingInfo array
  11024. */
  11025. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11026. /**
  11027. * Render all child sprites
  11028. */
  11029. render(): void;
  11030. /**
  11031. * Release associated resources
  11032. */
  11033. dispose(): void;
  11034. /**
  11035. * Serializes the sprite manager to a JSON object
  11036. * @param serializeTexture defines if the texture must be serialized as well
  11037. * @returns the JSON object
  11038. */
  11039. serialize(serializeTexture?: boolean): any;
  11040. /**
  11041. * Parses a JSON object to create a new sprite manager.
  11042. * @param parsedManager The JSON object to parse
  11043. * @param scene The scene to create the sprite managerin
  11044. * @param rootUrl The root url to use to load external dependencies like texture
  11045. * @returns the new sprite manager
  11046. */
  11047. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11048. /**
  11049. * Creates a sprite manager from a snippet saved by the sprite editor
  11050. * @param snippetId defines the snippet to load
  11051. * @param scene defines the hosting scene
  11052. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11053. * @returns a promise that will resolve to the new sprite manager
  11054. */
  11055. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11056. }
  11057. }
  11058. declare module BABYLON {
  11059. /** Interface used by value gradients (color, factor, ...) */
  11060. export interface IValueGradient {
  11061. /**
  11062. * Gets or sets the gradient value (between 0 and 1)
  11063. */
  11064. gradient: number;
  11065. }
  11066. /** Class used to store color4 gradient */
  11067. export class ColorGradient implements IValueGradient {
  11068. /**
  11069. * Gets or sets the gradient value (between 0 and 1)
  11070. */
  11071. gradient: number;
  11072. /**
  11073. * Gets or sets first associated color
  11074. */
  11075. color1: Color4;
  11076. /**
  11077. * Gets or sets second associated color
  11078. */
  11079. color2?: Color4 | undefined;
  11080. /**
  11081. * Creates a new color4 gradient
  11082. * @param gradient gets or sets the gradient value (between 0 and 1)
  11083. * @param color1 gets or sets first associated color
  11084. * @param color2 gets or sets first second color
  11085. */
  11086. constructor(
  11087. /**
  11088. * Gets or sets the gradient value (between 0 and 1)
  11089. */
  11090. gradient: number,
  11091. /**
  11092. * Gets or sets first associated color
  11093. */
  11094. color1: Color4,
  11095. /**
  11096. * Gets or sets second associated color
  11097. */
  11098. color2?: Color4 | undefined);
  11099. /**
  11100. * Will get a color picked randomly between color1 and color2.
  11101. * If color2 is undefined then color1 will be used
  11102. * @param result defines the target Color4 to store the result in
  11103. */
  11104. getColorToRef(result: Color4): void;
  11105. }
  11106. /** Class used to store color 3 gradient */
  11107. export class Color3Gradient implements IValueGradient {
  11108. /**
  11109. * Gets or sets the gradient value (between 0 and 1)
  11110. */
  11111. gradient: number;
  11112. /**
  11113. * Gets or sets the associated color
  11114. */
  11115. color: Color3;
  11116. /**
  11117. * Creates a new color3 gradient
  11118. * @param gradient gets or sets the gradient value (between 0 and 1)
  11119. * @param color gets or sets associated color
  11120. */
  11121. constructor(
  11122. /**
  11123. * Gets or sets the gradient value (between 0 and 1)
  11124. */
  11125. gradient: number,
  11126. /**
  11127. * Gets or sets the associated color
  11128. */
  11129. color: Color3);
  11130. }
  11131. /** Class used to store factor gradient */
  11132. export class FactorGradient implements IValueGradient {
  11133. /**
  11134. * Gets or sets the gradient value (between 0 and 1)
  11135. */
  11136. gradient: number;
  11137. /**
  11138. * Gets or sets first associated factor
  11139. */
  11140. factor1: number;
  11141. /**
  11142. * Gets or sets second associated factor
  11143. */
  11144. factor2?: number | undefined;
  11145. /**
  11146. * Creates a new factor gradient
  11147. * @param gradient gets or sets the gradient value (between 0 and 1)
  11148. * @param factor1 gets or sets first associated factor
  11149. * @param factor2 gets or sets second associated factor
  11150. */
  11151. constructor(
  11152. /**
  11153. * Gets or sets the gradient value (between 0 and 1)
  11154. */
  11155. gradient: number,
  11156. /**
  11157. * Gets or sets first associated factor
  11158. */
  11159. factor1: number,
  11160. /**
  11161. * Gets or sets second associated factor
  11162. */
  11163. factor2?: number | undefined);
  11164. /**
  11165. * Will get a number picked randomly between factor1 and factor2.
  11166. * If factor2 is undefined then factor1 will be used
  11167. * @returns the picked number
  11168. */
  11169. getFactor(): number;
  11170. }
  11171. /**
  11172. * Helper used to simplify some generic gradient tasks
  11173. */
  11174. export class GradientHelper {
  11175. /**
  11176. * Gets the current gradient from an array of IValueGradient
  11177. * @param ratio defines the current ratio to get
  11178. * @param gradients defines the array of IValueGradient
  11179. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11180. */
  11181. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11182. }
  11183. }
  11184. declare module BABYLON {
  11185. interface ThinEngine {
  11186. /**
  11187. * Creates a dynamic texture
  11188. * @param width defines the width of the texture
  11189. * @param height defines the height of the texture
  11190. * @param generateMipMaps defines if the engine should generate the mip levels
  11191. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11192. * @returns the dynamic texture inside an InternalTexture
  11193. */
  11194. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11195. /**
  11196. * Update the content of a dynamic texture
  11197. * @param texture defines the texture to update
  11198. * @param canvas defines the canvas containing the source
  11199. * @param invertY defines if data must be stored with Y axis inverted
  11200. * @param premulAlpha defines if alpha is stored as premultiplied
  11201. * @param format defines the format of the data
  11202. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11203. */
  11204. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11205. }
  11206. }
  11207. declare module BABYLON {
  11208. /**
  11209. * Helper class used to generate a canvas to manipulate images
  11210. */
  11211. export class CanvasGenerator {
  11212. /**
  11213. * Create a new canvas (or offscreen canvas depending on the context)
  11214. * @param width defines the expected width
  11215. * @param height defines the expected height
  11216. * @return a new canvas or offscreen canvas
  11217. */
  11218. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11219. }
  11220. }
  11221. declare module BABYLON {
  11222. /**
  11223. * A class extending Texture allowing drawing on a texture
  11224. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11225. */
  11226. export class DynamicTexture extends Texture {
  11227. private _generateMipMaps;
  11228. private _canvas;
  11229. private _context;
  11230. /**
  11231. * Creates a DynamicTexture
  11232. * @param name defines the name of the texture
  11233. * @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
  11234. * @param scene defines the scene where you want the texture
  11235. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11236. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11237. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11238. */
  11239. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11240. /**
  11241. * Get the current class name of the texture useful for serialization or dynamic coding.
  11242. * @returns "DynamicTexture"
  11243. */
  11244. getClassName(): string;
  11245. /**
  11246. * Gets the current state of canRescale
  11247. */
  11248. get canRescale(): boolean;
  11249. private _recreate;
  11250. /**
  11251. * Scales the texture
  11252. * @param ratio the scale factor to apply to both width and height
  11253. */
  11254. scale(ratio: number): void;
  11255. /**
  11256. * Resizes the texture
  11257. * @param width the new width
  11258. * @param height the new height
  11259. */
  11260. scaleTo(width: number, height: number): void;
  11261. /**
  11262. * Gets the context of the canvas used by the texture
  11263. * @returns the canvas context of the dynamic texture
  11264. */
  11265. getContext(): CanvasRenderingContext2D;
  11266. /**
  11267. * Clears the texture
  11268. */
  11269. clear(): void;
  11270. /**
  11271. * Updates the texture
  11272. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11273. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11274. */
  11275. update(invertY?: boolean, premulAlpha?: boolean): void;
  11276. /**
  11277. * Draws text onto the texture
  11278. * @param text defines the text to be drawn
  11279. * @param x defines the placement of the text from the left
  11280. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11281. * @param font defines the font to be used with font-style, font-size, font-name
  11282. * @param color defines the color used for the text
  11283. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11284. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11285. * @param update defines whether texture is immediately update (default is true)
  11286. */
  11287. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11288. /**
  11289. * Clones the texture
  11290. * @returns the clone of the texture.
  11291. */
  11292. clone(): DynamicTexture;
  11293. /**
  11294. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11295. * @returns a serialized dynamic texture object
  11296. */
  11297. serialize(): any;
  11298. /** @hidden */
  11299. _rebuild(): void;
  11300. }
  11301. }
  11302. declare module BABYLON {
  11303. interface ThinEngine {
  11304. /**
  11305. * Creates a raw texture
  11306. * @param data defines the data to store in the texture
  11307. * @param width defines the width of the texture
  11308. * @param height defines the height of the texture
  11309. * @param format defines the format of the data
  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 (Texture.NEAREST_SAMPLINGMODE by default)
  11313. * @param compression defines the compression used (null by default)
  11314. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11315. * @returns the raw texture inside an InternalTexture
  11316. */
  11317. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11318. /**
  11319. * Update a raw texture
  11320. * @param texture defines the texture to update
  11321. * @param data defines the data to store in the texture
  11322. * @param format defines the format of the data
  11323. * @param invertY defines if data must be stored with Y axis inverted
  11324. */
  11325. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11326. /**
  11327. * Update a raw texture
  11328. * @param texture defines the texture to update
  11329. * @param data defines the data to store in the texture
  11330. * @param format defines the format of the data
  11331. * @param invertY defines if data must be stored with Y axis inverted
  11332. * @param compression defines the compression used (null by default)
  11333. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11334. */
  11335. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11336. /**
  11337. * Creates a new raw cube texture
  11338. * @param data defines the array of data to use to create each face
  11339. * @param size defines the size of the textures
  11340. * @param format defines the format of the data
  11341. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11342. * @param generateMipMaps defines if the engine should generate the mip levels
  11343. * @param invertY defines if data must be stored with Y axis inverted
  11344. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11345. * @param compression defines the compression used (null by default)
  11346. * @returns the cube texture as an InternalTexture
  11347. */
  11348. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11349. /**
  11350. * Update a raw cube texture
  11351. * @param texture defines the texture to udpdate
  11352. * @param data defines the data to store
  11353. * @param format defines the data format
  11354. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11355. * @param invertY defines if data must be stored with Y axis inverted
  11356. */
  11357. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11358. /**
  11359. * Update a raw cube texture
  11360. * @param texture defines the texture to udpdate
  11361. * @param data defines the data to store
  11362. * @param format defines the data format
  11363. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11364. * @param invertY defines if data must be stored with Y axis inverted
  11365. * @param compression defines the compression used (null by default)
  11366. */
  11367. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11368. /**
  11369. * Update a raw cube texture
  11370. * @param texture defines the texture to udpdate
  11371. * @param data defines the data to store
  11372. * @param format defines the data format
  11373. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11374. * @param invertY defines if data must be stored with Y axis inverted
  11375. * @param compression defines the compression used (null by default)
  11376. * @param level defines which level of the texture to update
  11377. */
  11378. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11379. /**
  11380. * Creates a new raw cube texture from a specified url
  11381. * @param url defines the url where the data is located
  11382. * @param scene defines the current scene
  11383. * @param size defines the size of the textures
  11384. * @param format defines the format of the data
  11385. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11386. * @param noMipmap defines if the engine should avoid generating the mip levels
  11387. * @param callback defines a callback used to extract texture data from loaded data
  11388. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11389. * @param onLoad defines a callback called when texture is loaded
  11390. * @param onError defines a callback called if there is an error
  11391. * @returns the cube texture as an InternalTexture
  11392. */
  11393. 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;
  11394. /**
  11395. * Creates a new raw cube texture from a specified url
  11396. * @param url defines the url where the data is located
  11397. * @param scene defines the current scene
  11398. * @param size defines the size of the textures
  11399. * @param format defines the format of the data
  11400. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11401. * @param noMipmap defines if the engine should avoid generating the mip levels
  11402. * @param callback defines a callback used to extract texture data from loaded data
  11403. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11404. * @param onLoad defines a callback called when texture is loaded
  11405. * @param onError defines a callback called if there is an error
  11406. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11407. * @param invertY defines if data must be stored with Y axis inverted
  11408. * @returns the cube texture as an InternalTexture
  11409. */
  11410. 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;
  11411. /**
  11412. * Creates a new raw 3D texture
  11413. * @param data defines the data used to create the texture
  11414. * @param width defines the width of the texture
  11415. * @param height defines the height of the texture
  11416. * @param depth defines the depth of the texture
  11417. * @param format defines the format of the texture
  11418. * @param generateMipMaps defines if the engine must generate mip levels
  11419. * @param invertY defines if data must be stored with Y axis inverted
  11420. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11421. * @param compression defines the compressed used (can be null)
  11422. * @param textureType defines the compressed used (can be null)
  11423. * @returns a new raw 3D texture (stored in an InternalTexture)
  11424. */
  11425. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11426. /**
  11427. * Update a raw 3D texture
  11428. * @param texture defines the texture to update
  11429. * @param data defines the data to store
  11430. * @param format defines the data format
  11431. * @param invertY defines if data must be stored with Y axis inverted
  11432. */
  11433. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11434. /**
  11435. * Update a raw 3D texture
  11436. * @param texture defines the texture to update
  11437. * @param data defines the data to store
  11438. * @param format defines the data format
  11439. * @param invertY defines if data must be stored with Y axis inverted
  11440. * @param compression defines the used compression (can be null)
  11441. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11442. */
  11443. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11444. /**
  11445. * Creates a new raw 2D array texture
  11446. * @param data defines the data used to create the texture
  11447. * @param width defines the width of the texture
  11448. * @param height defines the height of the texture
  11449. * @param depth defines the number of layers of the texture
  11450. * @param format defines the format of the texture
  11451. * @param generateMipMaps defines if the engine must generate mip levels
  11452. * @param invertY defines if data must be stored with Y axis inverted
  11453. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11454. * @param compression defines the compressed used (can be null)
  11455. * @param textureType defines the compressed used (can be null)
  11456. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11457. */
  11458. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11459. /**
  11460. * Update a raw 2D array texture
  11461. * @param texture defines the texture to update
  11462. * @param data defines the data to store
  11463. * @param format defines the data format
  11464. * @param invertY defines if data must be stored with Y axis inverted
  11465. */
  11466. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11467. /**
  11468. * Update a raw 2D array texture
  11469. * @param texture defines the texture to update
  11470. * @param data defines the data to store
  11471. * @param format defines the data format
  11472. * @param invertY defines if data must be stored with Y axis inverted
  11473. * @param compression defines the used compression (can be null)
  11474. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11475. */
  11476. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11477. }
  11478. }
  11479. declare module BABYLON {
  11480. /**
  11481. * Raw texture can help creating a texture directly from an array of data.
  11482. * This can be super useful if you either get the data from an uncompressed source or
  11483. * if you wish to create your texture pixel by pixel.
  11484. */
  11485. export class RawTexture extends Texture {
  11486. /**
  11487. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11488. */
  11489. format: number;
  11490. /**
  11491. * Instantiates a new RawTexture.
  11492. * Raw texture can help creating a texture directly from an array of data.
  11493. * This can be super useful if you either get the data from an uncompressed source or
  11494. * if you wish to create your texture pixel by pixel.
  11495. * @param data define the array of data to use to create the texture
  11496. * @param width define the width of the texture
  11497. * @param height define the height of the texture
  11498. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11499. * @param scene define the scene the texture belongs to
  11500. * @param generateMipMaps define whether mip maps should be generated or not
  11501. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11502. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11503. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11504. */
  11505. constructor(data: ArrayBufferView, width: number, height: number,
  11506. /**
  11507. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11508. */
  11509. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11510. /**
  11511. * Updates the texture underlying data.
  11512. * @param data Define the new data of the texture
  11513. */
  11514. update(data: ArrayBufferView): void;
  11515. /**
  11516. * Creates a luminance texture from some data.
  11517. * @param data Define the texture data
  11518. * @param width Define the width of the texture
  11519. * @param height Define the height of the texture
  11520. * @param scene Define the scene the texture belongs to
  11521. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11524. * @returns the luminance texture
  11525. */
  11526. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11527. /**
  11528. * Creates a luminance alpha texture from some data.
  11529. * @param data Define the texture data
  11530. * @param width Define the width of the texture
  11531. * @param height Define the height of the texture
  11532. * @param scene Define the scene the texture belongs to
  11533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11536. * @returns the luminance alpha texture
  11537. */
  11538. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11539. /**
  11540. * Creates an alpha texture from some data.
  11541. * @param data Define the texture data
  11542. * @param width Define the width of the texture
  11543. * @param height Define the height of the texture
  11544. * @param scene Define the scene the texture belongs to
  11545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11548. * @returns the alpha texture
  11549. */
  11550. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11551. /**
  11552. * Creates a RGB texture from some data.
  11553. * @param data Define the texture data
  11554. * @param width Define the width of the texture
  11555. * @param height Define the height of the texture
  11556. * @param scene Define the scene the texture belongs to
  11557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11560. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11561. * @returns the RGB alpha texture
  11562. */
  11563. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11564. /**
  11565. * Creates a RGBA texture from some data.
  11566. * @param data Define the texture data
  11567. * @param width Define the width of the texture
  11568. * @param height Define the height of the texture
  11569. * @param scene Define the scene the texture belongs to
  11570. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11571. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11572. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11573. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11574. * @returns the RGBA texture
  11575. */
  11576. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11577. /**
  11578. * Creates a R texture from some data.
  11579. * @param data Define the texture data
  11580. * @param width Define the width of the texture
  11581. * @param height Define the height of the texture
  11582. * @param scene Define the scene the texture belongs to
  11583. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11584. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11585. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11586. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11587. * @returns the R texture
  11588. */
  11589. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11590. }
  11591. }
  11592. declare module BABYLON {
  11593. interface AbstractScene {
  11594. /**
  11595. * The list of procedural textures added to the scene
  11596. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11597. */
  11598. proceduralTextures: Array<ProceduralTexture>;
  11599. }
  11600. /**
  11601. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11602. * in a given scene.
  11603. */
  11604. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11605. /**
  11606. * The component name helpfull to identify the component in the list of scene components.
  11607. */
  11608. readonly name: string;
  11609. /**
  11610. * The scene the component belongs to.
  11611. */
  11612. scene: Scene;
  11613. /**
  11614. * Creates a new instance of the component for the given scene
  11615. * @param scene Defines the scene to register the component in
  11616. */
  11617. constructor(scene: Scene);
  11618. /**
  11619. * Registers the component in a given scene
  11620. */
  11621. register(): void;
  11622. /**
  11623. * Rebuilds the elements related to this component in case of
  11624. * context lost for instance.
  11625. */
  11626. rebuild(): void;
  11627. /**
  11628. * Disposes the component and the associated ressources.
  11629. */
  11630. dispose(): void;
  11631. private _beforeClear;
  11632. }
  11633. }
  11634. declare module BABYLON {
  11635. interface ThinEngine {
  11636. /**
  11637. * Creates a new render target cube texture
  11638. * @param size defines the size of the texture
  11639. * @param options defines the options used to create the texture
  11640. * @returns a new render target cube texture stored in an InternalTexture
  11641. */
  11642. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11643. }
  11644. }
  11645. declare module BABYLON {
  11646. /** @hidden */
  11647. export var proceduralVertexShader: {
  11648. name: string;
  11649. shader: string;
  11650. };
  11651. }
  11652. declare module BABYLON {
  11653. /**
  11654. * 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.
  11655. * This is the base class of any Procedural texture and contains most of the shareable code.
  11656. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11657. */
  11658. export class ProceduralTexture extends Texture {
  11659. isCube: boolean;
  11660. /**
  11661. * Define if the texture is enabled or not (disabled texture will not render)
  11662. */
  11663. isEnabled: boolean;
  11664. /**
  11665. * Define if the texture must be cleared before rendering (default is true)
  11666. */
  11667. autoClear: boolean;
  11668. /**
  11669. * Callback called when the texture is generated
  11670. */
  11671. onGenerated: () => void;
  11672. /**
  11673. * Event raised when the texture is generated
  11674. */
  11675. onGeneratedObservable: Observable<ProceduralTexture>;
  11676. /** @hidden */
  11677. _generateMipMaps: boolean;
  11678. /** @hidden **/
  11679. _effect: Effect;
  11680. /** @hidden */
  11681. _textures: {
  11682. [key: string]: Texture;
  11683. };
  11684. /** @hidden */
  11685. protected _fallbackTexture: Nullable<Texture>;
  11686. private _size;
  11687. private _currentRefreshId;
  11688. private _frameId;
  11689. private _refreshRate;
  11690. private _vertexBuffers;
  11691. private _indexBuffer;
  11692. private _uniforms;
  11693. private _samplers;
  11694. private _fragment;
  11695. private _floats;
  11696. private _ints;
  11697. private _floatsArrays;
  11698. private _colors3;
  11699. private _colors4;
  11700. private _vectors2;
  11701. private _vectors3;
  11702. private _matrices;
  11703. private _fallbackTextureUsed;
  11704. private _fullEngine;
  11705. private _cachedDefines;
  11706. private _contentUpdateId;
  11707. private _contentData;
  11708. /**
  11709. * Instantiates a new procedural texture.
  11710. * 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.
  11711. * This is the base class of any Procedural texture and contains most of the shareable code.
  11712. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11713. * @param name Define the name of the texture
  11714. * @param size Define the size of the texture to create
  11715. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11716. * @param scene Define the scene the texture belongs to
  11717. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11718. * @param generateMipMaps Define if the texture should creates mip maps or not
  11719. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11720. */
  11721. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11722. /**
  11723. * The effect that is created when initializing the post process.
  11724. * @returns The created effect corresponding the the postprocess.
  11725. */
  11726. getEffect(): Effect;
  11727. /**
  11728. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11729. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11730. */
  11731. getContent(): Nullable<ArrayBufferView>;
  11732. private _createIndexBuffer;
  11733. /** @hidden */
  11734. _rebuild(): void;
  11735. /**
  11736. * Resets the texture in order to recreate its associated resources.
  11737. * This can be called in case of context loss
  11738. */
  11739. reset(): void;
  11740. protected _getDefines(): string;
  11741. /**
  11742. * Is the texture ready to be used ? (rendered at least once)
  11743. * @returns true if ready, otherwise, false.
  11744. */
  11745. isReady(): boolean;
  11746. /**
  11747. * Resets the refresh counter of the texture and start bak from scratch.
  11748. * Could be useful to regenerate the texture if it is setup to render only once.
  11749. */
  11750. resetRefreshCounter(): void;
  11751. /**
  11752. * Set the fragment shader to use in order to render the texture.
  11753. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11754. */
  11755. setFragment(fragment: any): void;
  11756. /**
  11757. * Define the refresh rate of the texture or the rendering frequency.
  11758. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11759. */
  11760. get refreshRate(): number;
  11761. set refreshRate(value: number);
  11762. /** @hidden */
  11763. _shouldRender(): boolean;
  11764. /**
  11765. * Get the size the texture is rendering at.
  11766. * @returns the size (texture is always squared)
  11767. */
  11768. getRenderSize(): number;
  11769. /**
  11770. * Resize the texture to new value.
  11771. * @param size Define the new size the texture should have
  11772. * @param generateMipMaps Define whether the new texture should create mip maps
  11773. */
  11774. resize(size: number, generateMipMaps: boolean): void;
  11775. private _checkUniform;
  11776. /**
  11777. * Set a texture in the shader program used to render.
  11778. * @param name Define the name of the uniform samplers as defined in the shader
  11779. * @param texture Define the texture to bind to this sampler
  11780. * @return the texture itself allowing "fluent" like uniform updates
  11781. */
  11782. setTexture(name: string, texture: Texture): ProceduralTexture;
  11783. /**
  11784. * Set a float in the shader.
  11785. * @param name Define the name of the uniform as defined in the shader
  11786. * @param value Define the value to give to the uniform
  11787. * @return the texture itself allowing "fluent" like uniform updates
  11788. */
  11789. setFloat(name: string, value: number): ProceduralTexture;
  11790. /**
  11791. * Set a int in the shader.
  11792. * @param name Define the name of the uniform as defined in the shader
  11793. * @param value Define the value to give to the uniform
  11794. * @return the texture itself allowing "fluent" like uniform updates
  11795. */
  11796. setInt(name: string, value: number): ProceduralTexture;
  11797. /**
  11798. * Set an array of floats in the shader.
  11799. * @param name Define the name of the uniform as defined in the shader
  11800. * @param value Define the value to give to the uniform
  11801. * @return the texture itself allowing "fluent" like uniform updates
  11802. */
  11803. setFloats(name: string, value: number[]): ProceduralTexture;
  11804. /**
  11805. * Set a vec3 in the shader from a Color3.
  11806. * @param name Define the name of the uniform as defined in the shader
  11807. * @param value Define the value to give to the uniform
  11808. * @return the texture itself allowing "fluent" like uniform updates
  11809. */
  11810. setColor3(name: string, value: Color3): ProceduralTexture;
  11811. /**
  11812. * Set a vec4 in the shader from a Color4.
  11813. * @param name Define the name of the uniform as defined in the shader
  11814. * @param value Define the value to give to the uniform
  11815. * @return the texture itself allowing "fluent" like uniform updates
  11816. */
  11817. setColor4(name: string, value: Color4): ProceduralTexture;
  11818. /**
  11819. * Set a vec2 in the shader from a Vector2.
  11820. * @param name Define the name of the uniform as defined in the shader
  11821. * @param value Define the value to give to the uniform
  11822. * @return the texture itself allowing "fluent" like uniform updates
  11823. */
  11824. setVector2(name: string, value: Vector2): ProceduralTexture;
  11825. /**
  11826. * Set a vec3 in the shader from a Vector3.
  11827. * @param name Define the name of the uniform as defined in the shader
  11828. * @param value Define the value to give to the uniform
  11829. * @return the texture itself allowing "fluent" like uniform updates
  11830. */
  11831. setVector3(name: string, value: Vector3): ProceduralTexture;
  11832. /**
  11833. * Set a mat4 in the shader from a MAtrix.
  11834. * @param name Define the name of the uniform as defined in the shader
  11835. * @param value Define the value to give to the uniform
  11836. * @return the texture itself allowing "fluent" like uniform updates
  11837. */
  11838. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11839. /**
  11840. * Render the texture to its associated render target.
  11841. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11842. */
  11843. render(useCameraPostProcess?: boolean): void;
  11844. /**
  11845. * Clone the texture.
  11846. * @returns the cloned texture
  11847. */
  11848. clone(): ProceduralTexture;
  11849. /**
  11850. * Dispose the texture and release its asoociated resources.
  11851. */
  11852. dispose(): void;
  11853. }
  11854. }
  11855. declare module BABYLON {
  11856. /**
  11857. * This represents the base class for particle system in Babylon.
  11858. * 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.
  11859. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11860. * @example https://doc.babylonjs.com/babylon101/particles
  11861. */
  11862. export class BaseParticleSystem {
  11863. /**
  11864. * Source color is added to the destination color without alpha affecting the result
  11865. */
  11866. static BLENDMODE_ONEONE: number;
  11867. /**
  11868. * Blend current color and particle color using particle’s alpha
  11869. */
  11870. static BLENDMODE_STANDARD: number;
  11871. /**
  11872. * Add current color and particle color multiplied by particle’s alpha
  11873. */
  11874. static BLENDMODE_ADD: number;
  11875. /**
  11876. * Multiply current color with particle color
  11877. */
  11878. static BLENDMODE_MULTIPLY: number;
  11879. /**
  11880. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11881. */
  11882. static BLENDMODE_MULTIPLYADD: number;
  11883. /**
  11884. * List of animations used by the particle system.
  11885. */
  11886. animations: Animation[];
  11887. /**
  11888. * Gets or sets the unique id of the particle system
  11889. */
  11890. uniqueId: number;
  11891. /**
  11892. * The id of the Particle system.
  11893. */
  11894. id: string;
  11895. /**
  11896. * The friendly name of the Particle system.
  11897. */
  11898. name: string;
  11899. /**
  11900. * Snippet ID if the particle system was created from the snippet server
  11901. */
  11902. snippetId: string;
  11903. /**
  11904. * The rendering group used by the Particle system to chose when to render.
  11905. */
  11906. renderingGroupId: number;
  11907. /**
  11908. * The emitter represents the Mesh or position we are attaching the particle system to.
  11909. */
  11910. emitter: Nullable<AbstractMesh | Vector3>;
  11911. /**
  11912. * The maximum number of particles to emit per frame
  11913. */
  11914. emitRate: number;
  11915. /**
  11916. * If you want to launch only a few particles at once, that can be done, as well.
  11917. */
  11918. manualEmitCount: number;
  11919. /**
  11920. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11921. */
  11922. updateSpeed: number;
  11923. /**
  11924. * The amount of time the particle system is running (depends of the overall update speed).
  11925. */
  11926. targetStopDuration: number;
  11927. /**
  11928. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11929. */
  11930. disposeOnStop: boolean;
  11931. /**
  11932. * Minimum power of emitting particles.
  11933. */
  11934. minEmitPower: number;
  11935. /**
  11936. * Maximum power of emitting particles.
  11937. */
  11938. maxEmitPower: number;
  11939. /**
  11940. * Minimum life time of emitting particles.
  11941. */
  11942. minLifeTime: number;
  11943. /**
  11944. * Maximum life time of emitting particles.
  11945. */
  11946. maxLifeTime: number;
  11947. /**
  11948. * Minimum Size of emitting particles.
  11949. */
  11950. minSize: number;
  11951. /**
  11952. * Maximum Size of emitting particles.
  11953. */
  11954. maxSize: number;
  11955. /**
  11956. * Minimum scale of emitting particles on X axis.
  11957. */
  11958. minScaleX: number;
  11959. /**
  11960. * Maximum scale of emitting particles on X axis.
  11961. */
  11962. maxScaleX: number;
  11963. /**
  11964. * Minimum scale of emitting particles on Y axis.
  11965. */
  11966. minScaleY: number;
  11967. /**
  11968. * Maximum scale of emitting particles on Y axis.
  11969. */
  11970. maxScaleY: number;
  11971. /**
  11972. * Gets or sets the minimal initial rotation in radians.
  11973. */
  11974. minInitialRotation: number;
  11975. /**
  11976. * Gets or sets the maximal initial rotation in radians.
  11977. */
  11978. maxInitialRotation: number;
  11979. /**
  11980. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11981. */
  11982. minAngularSpeed: number;
  11983. /**
  11984. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11985. */
  11986. maxAngularSpeed: number;
  11987. /**
  11988. * The texture used to render each particle. (this can be a spritesheet)
  11989. */
  11990. particleTexture: Nullable<Texture>;
  11991. /**
  11992. * The layer mask we are rendering the particles through.
  11993. */
  11994. layerMask: number;
  11995. /**
  11996. * This can help using your own shader to render the particle system.
  11997. * The according effect will be created
  11998. */
  11999. customShader: any;
  12000. /**
  12001. * By default particle system starts as soon as they are created. This prevents the
  12002. * automatic start to happen and let you decide when to start emitting particles.
  12003. */
  12004. preventAutoStart: boolean;
  12005. private _noiseTexture;
  12006. /**
  12007. * Gets or sets a texture used to add random noise to particle positions
  12008. */
  12009. get noiseTexture(): Nullable<ProceduralTexture>;
  12010. set noiseTexture(value: Nullable<ProceduralTexture>);
  12011. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12012. noiseStrength: Vector3;
  12013. /**
  12014. * Callback triggered when the particle animation is ending.
  12015. */
  12016. onAnimationEnd: Nullable<() => void>;
  12017. /**
  12018. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12019. */
  12020. blendMode: number;
  12021. /**
  12022. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12023. * to override the particles.
  12024. */
  12025. forceDepthWrite: boolean;
  12026. /** 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 */
  12027. preWarmCycles: number;
  12028. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12029. preWarmStepOffset: number;
  12030. /**
  12031. * 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)
  12032. */
  12033. spriteCellChangeSpeed: number;
  12034. /**
  12035. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12036. */
  12037. startSpriteCellID: number;
  12038. /**
  12039. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12040. */
  12041. endSpriteCellID: number;
  12042. /**
  12043. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12044. */
  12045. spriteCellWidth: number;
  12046. /**
  12047. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12048. */
  12049. spriteCellHeight: number;
  12050. /**
  12051. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12052. */
  12053. spriteRandomStartCell: boolean;
  12054. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12055. translationPivot: Vector2;
  12056. /** @hidden */
  12057. protected _isAnimationSheetEnabled: boolean;
  12058. /**
  12059. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12060. */
  12061. beginAnimationOnStart: boolean;
  12062. /**
  12063. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12064. */
  12065. beginAnimationFrom: number;
  12066. /**
  12067. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12068. */
  12069. beginAnimationTo: number;
  12070. /**
  12071. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12072. */
  12073. beginAnimationLoop: boolean;
  12074. /**
  12075. * Gets or sets a world offset applied to all particles
  12076. */
  12077. worldOffset: Vector3;
  12078. /**
  12079. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12080. */
  12081. get isAnimationSheetEnabled(): boolean;
  12082. set isAnimationSheetEnabled(value: boolean);
  12083. /**
  12084. * Get hosting scene
  12085. * @returns the scene
  12086. */
  12087. getScene(): Scene;
  12088. /**
  12089. * You can use gravity if you want to give an orientation to your particles.
  12090. */
  12091. gravity: Vector3;
  12092. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12093. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12094. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12095. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12096. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12097. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12098. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12099. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12100. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12101. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12102. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12103. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12104. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12105. /**
  12106. * Defines the delay in milliseconds before starting the system (0 by default)
  12107. */
  12108. startDelay: number;
  12109. /**
  12110. * Gets the current list of drag gradients.
  12111. * You must use addDragGradient and removeDragGradient to udpate this list
  12112. * @returns the list of drag gradients
  12113. */
  12114. getDragGradients(): Nullable<Array<FactorGradient>>;
  12115. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12116. limitVelocityDamping: number;
  12117. /**
  12118. * Gets the current list of limit velocity gradients.
  12119. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12120. * @returns the list of limit velocity gradients
  12121. */
  12122. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12123. /**
  12124. * Gets the current list of color gradients.
  12125. * You must use addColorGradient and removeColorGradient to udpate this list
  12126. * @returns the list of color gradients
  12127. */
  12128. getColorGradients(): Nullable<Array<ColorGradient>>;
  12129. /**
  12130. * Gets the current list of size gradients.
  12131. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12132. * @returns the list of size gradients
  12133. */
  12134. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12135. /**
  12136. * Gets the current list of color remap gradients.
  12137. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12138. * @returns the list of color remap gradients
  12139. */
  12140. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12141. /**
  12142. * Gets the current list of alpha remap gradients.
  12143. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12144. * @returns the list of alpha remap gradients
  12145. */
  12146. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12147. /**
  12148. * Gets the current list of life time gradients.
  12149. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12150. * @returns the list of life time gradients
  12151. */
  12152. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12153. /**
  12154. * Gets the current list of angular speed gradients.
  12155. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12156. * @returns the list of angular speed gradients
  12157. */
  12158. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12159. /**
  12160. * Gets the current list of velocity gradients.
  12161. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12162. * @returns the list of velocity gradients
  12163. */
  12164. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12165. /**
  12166. * Gets the current list of start size gradients.
  12167. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12168. * @returns the list of start size gradients
  12169. */
  12170. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12171. /**
  12172. * Gets the current list of emit rate gradients.
  12173. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12174. * @returns the list of emit rate gradients
  12175. */
  12176. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12177. /**
  12178. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12179. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12180. */
  12181. get direction1(): Vector3;
  12182. set direction1(value: Vector3);
  12183. /**
  12184. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12185. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12186. */
  12187. get direction2(): Vector3;
  12188. set direction2(value: Vector3);
  12189. /**
  12190. * 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.
  12191. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12192. */
  12193. get minEmitBox(): Vector3;
  12194. set minEmitBox(value: Vector3);
  12195. /**
  12196. * 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.
  12197. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12198. */
  12199. get maxEmitBox(): Vector3;
  12200. set maxEmitBox(value: Vector3);
  12201. /**
  12202. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12203. */
  12204. color1: Color4;
  12205. /**
  12206. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12207. */
  12208. color2: Color4;
  12209. /**
  12210. * Color the particle will have at the end of its lifetime
  12211. */
  12212. colorDead: Color4;
  12213. /**
  12214. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12215. */
  12216. textureMask: Color4;
  12217. /**
  12218. * The particle emitter type defines the emitter used by the particle system.
  12219. * It can be for example box, sphere, or cone...
  12220. */
  12221. particleEmitterType: IParticleEmitterType;
  12222. /** @hidden */
  12223. _isSubEmitter: boolean;
  12224. /**
  12225. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12226. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12227. */
  12228. billboardMode: number;
  12229. protected _isBillboardBased: boolean;
  12230. /**
  12231. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12232. */
  12233. get isBillboardBased(): boolean;
  12234. set isBillboardBased(value: boolean);
  12235. /**
  12236. * The scene the particle system belongs to.
  12237. */
  12238. protected _scene: Scene;
  12239. /**
  12240. * Local cache of defines for image processing.
  12241. */
  12242. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12243. /**
  12244. * Default configuration related to image processing available in the standard Material.
  12245. */
  12246. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12247. /**
  12248. * Gets the image processing configuration used either in this material.
  12249. */
  12250. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12251. /**
  12252. * Sets the Default image processing configuration used either in the this material.
  12253. *
  12254. * If sets to null, the scene one is in use.
  12255. */
  12256. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12257. /**
  12258. * Attaches a new image processing configuration to the Standard Material.
  12259. * @param configuration
  12260. */
  12261. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12262. /** @hidden */
  12263. protected _reset(): void;
  12264. /** @hidden */
  12265. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12266. /**
  12267. * Instantiates a particle system.
  12268. * 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.
  12269. * @param name The name of the particle system
  12270. */
  12271. constructor(name: string);
  12272. /**
  12273. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12274. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12275. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12276. * @returns the emitter
  12277. */
  12278. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12279. /**
  12280. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12281. * @param radius The radius of the hemisphere to emit from
  12282. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12283. * @returns the emitter
  12284. */
  12285. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12286. /**
  12287. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12288. * @param radius The radius of the sphere to emit from
  12289. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12290. * @returns the emitter
  12291. */
  12292. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12293. /**
  12294. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12295. * @param radius The radius of the sphere to emit from
  12296. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12297. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12298. * @returns the emitter
  12299. */
  12300. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12301. /**
  12302. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12303. * @param radius The radius of the emission cylinder
  12304. * @param height The height of the emission cylinder
  12305. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12306. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12307. * @returns the emitter
  12308. */
  12309. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12310. /**
  12311. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12312. * @param radius The radius of the cylinder to emit from
  12313. * @param height The height of the emission cylinder
  12314. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12315. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12316. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12317. * @returns the emitter
  12318. */
  12319. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12320. /**
  12321. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12322. * @param radius The radius of the cone to emit from
  12323. * @param angle The base angle of the cone
  12324. * @returns the emitter
  12325. */
  12326. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12327. /**
  12328. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12329. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12330. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12331. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12332. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12333. * @returns the emitter
  12334. */
  12335. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12336. }
  12337. }
  12338. declare module BABYLON {
  12339. /**
  12340. * Type of sub emitter
  12341. */
  12342. export enum SubEmitterType {
  12343. /**
  12344. * Attached to the particle over it's lifetime
  12345. */
  12346. ATTACHED = 0,
  12347. /**
  12348. * Created when the particle dies
  12349. */
  12350. END = 1
  12351. }
  12352. /**
  12353. * Sub emitter class used to emit particles from an existing particle
  12354. */
  12355. export class SubEmitter {
  12356. /**
  12357. * the particle system to be used by the sub emitter
  12358. */
  12359. particleSystem: ParticleSystem;
  12360. /**
  12361. * Type of the submitter (Default: END)
  12362. */
  12363. type: SubEmitterType;
  12364. /**
  12365. * 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)
  12366. * Note: This only is supported when using an emitter of type Mesh
  12367. */
  12368. inheritDirection: boolean;
  12369. /**
  12370. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12371. */
  12372. inheritedVelocityAmount: number;
  12373. /**
  12374. * Creates a sub emitter
  12375. * @param particleSystem the particle system to be used by the sub emitter
  12376. */
  12377. constructor(
  12378. /**
  12379. * the particle system to be used by the sub emitter
  12380. */
  12381. particleSystem: ParticleSystem);
  12382. /**
  12383. * Clones the sub emitter
  12384. * @returns the cloned sub emitter
  12385. */
  12386. clone(): SubEmitter;
  12387. /**
  12388. * Serialize current object to a JSON object
  12389. * @returns the serialized object
  12390. */
  12391. serialize(): any;
  12392. /** @hidden */
  12393. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12394. /**
  12395. * Creates a new SubEmitter from a serialized JSON version
  12396. * @param serializationObject defines the JSON object to read from
  12397. * @param scene defines the hosting scene
  12398. * @param rootUrl defines the rootUrl for data loading
  12399. * @returns a new SubEmitter
  12400. */
  12401. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12402. /** Release associated resources */
  12403. dispose(): void;
  12404. }
  12405. }
  12406. declare module BABYLON {
  12407. /** @hidden */
  12408. export var imageProcessingDeclaration: {
  12409. name: string;
  12410. shader: string;
  12411. };
  12412. }
  12413. declare module BABYLON {
  12414. /** @hidden */
  12415. export var imageProcessingFunctions: {
  12416. name: string;
  12417. shader: string;
  12418. };
  12419. }
  12420. declare module BABYLON {
  12421. /** @hidden */
  12422. export var particlesPixelShader: {
  12423. name: string;
  12424. shader: string;
  12425. };
  12426. }
  12427. declare module BABYLON {
  12428. /** @hidden */
  12429. export var particlesVertexShader: {
  12430. name: string;
  12431. shader: string;
  12432. };
  12433. }
  12434. declare module BABYLON {
  12435. /**
  12436. * This represents a particle system in Babylon.
  12437. * 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.
  12438. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12439. * @example https://doc.babylonjs.com/babylon101/particles
  12440. */
  12441. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12442. /**
  12443. * Billboard mode will only apply to Y axis
  12444. */
  12445. static readonly BILLBOARDMODE_Y: number;
  12446. /**
  12447. * Billboard mode will apply to all axes
  12448. */
  12449. static readonly BILLBOARDMODE_ALL: number;
  12450. /**
  12451. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12452. */
  12453. static readonly BILLBOARDMODE_STRETCHED: number;
  12454. /**
  12455. * This function can be defined to provide custom update for active particles.
  12456. * This function will be called instead of regular update (age, position, color, etc.).
  12457. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12458. */
  12459. updateFunction: (particles: Particle[]) => void;
  12460. private _emitterWorldMatrix;
  12461. /**
  12462. * This function can be defined to specify initial direction for every new particle.
  12463. * It by default use the emitterType defined function
  12464. */
  12465. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12466. /**
  12467. * This function can be defined to specify initial position for every new particle.
  12468. * It by default use the emitterType defined function
  12469. */
  12470. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12471. /**
  12472. * @hidden
  12473. */
  12474. _inheritedVelocityOffset: Vector3;
  12475. /**
  12476. * An event triggered when the system is disposed
  12477. */
  12478. onDisposeObservable: Observable<IParticleSystem>;
  12479. private _onDisposeObserver;
  12480. /**
  12481. * Sets a callback that will be triggered when the system is disposed
  12482. */
  12483. set onDispose(callback: () => void);
  12484. private _particles;
  12485. private _epsilon;
  12486. private _capacity;
  12487. private _stockParticles;
  12488. private _newPartsExcess;
  12489. private _vertexData;
  12490. private _vertexBuffer;
  12491. private _vertexBuffers;
  12492. private _spriteBuffer;
  12493. private _indexBuffer;
  12494. private _effect;
  12495. private _customEffect;
  12496. private _cachedDefines;
  12497. private _scaledColorStep;
  12498. private _colorDiff;
  12499. private _scaledDirection;
  12500. private _scaledGravity;
  12501. private _currentRenderId;
  12502. private _alive;
  12503. private _useInstancing;
  12504. private _started;
  12505. private _stopped;
  12506. private _actualFrame;
  12507. private _scaledUpdateSpeed;
  12508. private _vertexBufferSize;
  12509. /** @hidden */
  12510. _currentEmitRateGradient: Nullable<FactorGradient>;
  12511. /** @hidden */
  12512. _currentEmitRate1: number;
  12513. /** @hidden */
  12514. _currentEmitRate2: number;
  12515. /** @hidden */
  12516. _currentStartSizeGradient: Nullable<FactorGradient>;
  12517. /** @hidden */
  12518. _currentStartSize1: number;
  12519. /** @hidden */
  12520. _currentStartSize2: number;
  12521. private readonly _rawTextureWidth;
  12522. private _rampGradientsTexture;
  12523. private _useRampGradients;
  12524. /** Gets or sets a boolean indicating that ramp gradients must be used
  12525. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12526. */
  12527. get useRampGradients(): boolean;
  12528. set useRampGradients(value: boolean);
  12529. /**
  12530. * 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.
  12531. * 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: [])
  12532. */
  12533. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12534. private _subEmitters;
  12535. /**
  12536. * @hidden
  12537. * If the particle systems emitter should be disposed when the particle system is disposed
  12538. */
  12539. _disposeEmitterOnDispose: boolean;
  12540. /**
  12541. * The current active Sub-systems, this property is used by the root particle system only.
  12542. */
  12543. activeSubSystems: Array<ParticleSystem>;
  12544. /**
  12545. * Specifies if the particles are updated in emitter local space or world space
  12546. */
  12547. isLocal: boolean;
  12548. private _rootParticleSystem;
  12549. /**
  12550. * Gets the current list of active particles
  12551. */
  12552. get particles(): Particle[];
  12553. /**
  12554. * Gets the number of particles active at the same time.
  12555. * @returns The number of active particles.
  12556. */
  12557. getActiveCount(): number;
  12558. /**
  12559. * Returns the string "ParticleSystem"
  12560. * @returns a string containing the class name
  12561. */
  12562. getClassName(): string;
  12563. /**
  12564. * Gets a boolean indicating that the system is stopping
  12565. * @returns true if the system is currently stopping
  12566. */
  12567. isStopping(): boolean;
  12568. /**
  12569. * Gets the custom effect used to render the particles
  12570. * @param blendMode Blend mode for which the effect should be retrieved
  12571. * @returns The effect
  12572. */
  12573. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12574. /**
  12575. * Sets the custom effect used to render the particles
  12576. * @param effect The effect to set
  12577. * @param blendMode Blend mode for which the effect should be set
  12578. */
  12579. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12580. /** @hidden */
  12581. private _onBeforeDrawParticlesObservable;
  12582. /**
  12583. * Observable that will be called just before the particles are drawn
  12584. */
  12585. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12586. /**
  12587. * Gets the name of the particle vertex shader
  12588. */
  12589. get vertexShaderName(): string;
  12590. /**
  12591. * Instantiates a particle system.
  12592. * 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.
  12593. * @param name The name of the particle system
  12594. * @param capacity The max number of particles alive at the same time
  12595. * @param scene The scene the particle system belongs to
  12596. * @param customEffect a custom effect used to change the way particles are rendered by default
  12597. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12598. * @param epsilon Offset used to render the particles
  12599. */
  12600. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12601. private _addFactorGradient;
  12602. private _removeFactorGradient;
  12603. /**
  12604. * Adds a new life time gradient
  12605. * @param gradient defines the gradient to use (between 0 and 1)
  12606. * @param factor defines the life time factor to affect to the specified gradient
  12607. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12608. * @returns the current particle system
  12609. */
  12610. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12611. /**
  12612. * Remove a specific life time gradient
  12613. * @param gradient defines the gradient to remove
  12614. * @returns the current particle system
  12615. */
  12616. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12617. /**
  12618. * Adds a new size gradient
  12619. * @param gradient defines the gradient to use (between 0 and 1)
  12620. * @param factor defines the size factor to affect to the specified gradient
  12621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12622. * @returns the current particle system
  12623. */
  12624. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12625. /**
  12626. * Remove a specific size gradient
  12627. * @param gradient defines the gradient to remove
  12628. * @returns the current particle system
  12629. */
  12630. removeSizeGradient(gradient: number): IParticleSystem;
  12631. /**
  12632. * Adds a new color remap gradient
  12633. * @param gradient defines the gradient to use (between 0 and 1)
  12634. * @param min defines the color remap minimal range
  12635. * @param max defines the color remap maximal range
  12636. * @returns the current particle system
  12637. */
  12638. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12639. /**
  12640. * Remove a specific color remap gradient
  12641. * @param gradient defines the gradient to remove
  12642. * @returns the current particle system
  12643. */
  12644. removeColorRemapGradient(gradient: number): IParticleSystem;
  12645. /**
  12646. * Adds a new alpha remap gradient
  12647. * @param gradient defines the gradient to use (between 0 and 1)
  12648. * @param min defines the alpha remap minimal range
  12649. * @param max defines the alpha remap maximal range
  12650. * @returns the current particle system
  12651. */
  12652. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12653. /**
  12654. * Remove a specific alpha remap gradient
  12655. * @param gradient defines the gradient to remove
  12656. * @returns the current particle system
  12657. */
  12658. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12659. /**
  12660. * Adds a new angular speed gradient
  12661. * @param gradient defines the gradient to use (between 0 and 1)
  12662. * @param factor defines the angular speed to affect to the specified gradient
  12663. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12664. * @returns the current particle system
  12665. */
  12666. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12667. /**
  12668. * Remove a specific angular speed gradient
  12669. * @param gradient defines the gradient to remove
  12670. * @returns the current particle system
  12671. */
  12672. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12673. /**
  12674. * Adds a new velocity gradient
  12675. * @param gradient defines the gradient to use (between 0 and 1)
  12676. * @param factor defines the velocity to affect to the specified gradient
  12677. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12678. * @returns the current particle system
  12679. */
  12680. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12681. /**
  12682. * Remove a specific velocity gradient
  12683. * @param gradient defines the gradient to remove
  12684. * @returns the current particle system
  12685. */
  12686. removeVelocityGradient(gradient: number): IParticleSystem;
  12687. /**
  12688. * Adds a new limit velocity gradient
  12689. * @param gradient defines the gradient to use (between 0 and 1)
  12690. * @param factor defines the limit velocity value to affect to the specified gradient
  12691. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12692. * @returns the current particle system
  12693. */
  12694. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12695. /**
  12696. * Remove a specific limit velocity gradient
  12697. * @param gradient defines the gradient to remove
  12698. * @returns the current particle system
  12699. */
  12700. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12701. /**
  12702. * Adds a new drag gradient
  12703. * @param gradient defines the gradient to use (between 0 and 1)
  12704. * @param factor defines the drag value to affect to the specified gradient
  12705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12706. * @returns the current particle system
  12707. */
  12708. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12709. /**
  12710. * Remove a specific drag gradient
  12711. * @param gradient defines the gradient to remove
  12712. * @returns the current particle system
  12713. */
  12714. removeDragGradient(gradient: number): IParticleSystem;
  12715. /**
  12716. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12717. * @param gradient defines the gradient to use (between 0 and 1)
  12718. * @param factor defines the emit rate value to affect to the specified gradient
  12719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12720. * @returns the current particle system
  12721. */
  12722. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12723. /**
  12724. * Remove a specific emit rate gradient
  12725. * @param gradient defines the gradient to remove
  12726. * @returns the current particle system
  12727. */
  12728. removeEmitRateGradient(gradient: number): IParticleSystem;
  12729. /**
  12730. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12731. * @param gradient defines the gradient to use (between 0 and 1)
  12732. * @param factor defines the start size value to affect to the specified gradient
  12733. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12734. * @returns the current particle system
  12735. */
  12736. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12737. /**
  12738. * Remove a specific start size gradient
  12739. * @param gradient defines the gradient to remove
  12740. * @returns the current particle system
  12741. */
  12742. removeStartSizeGradient(gradient: number): IParticleSystem;
  12743. private _createRampGradientTexture;
  12744. /**
  12745. * Gets the current list of ramp gradients.
  12746. * You must use addRampGradient and removeRampGradient to udpate this list
  12747. * @returns the list of ramp gradients
  12748. */
  12749. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12750. /** Force the system to rebuild all gradients that need to be resync */
  12751. forceRefreshGradients(): void;
  12752. private _syncRampGradientTexture;
  12753. /**
  12754. * Adds a new ramp gradient used to remap particle colors
  12755. * @param gradient defines the gradient to use (between 0 and 1)
  12756. * @param color defines the color to affect to the specified gradient
  12757. * @returns the current particle system
  12758. */
  12759. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12760. /**
  12761. * Remove a specific ramp gradient
  12762. * @param gradient defines the gradient to remove
  12763. * @returns the current particle system
  12764. */
  12765. removeRampGradient(gradient: number): ParticleSystem;
  12766. /**
  12767. * Adds a new color gradient
  12768. * @param gradient defines the gradient to use (between 0 and 1)
  12769. * @param color1 defines the color to affect to the specified gradient
  12770. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12771. * @returns this particle system
  12772. */
  12773. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12774. /**
  12775. * Remove a specific color gradient
  12776. * @param gradient defines the gradient to remove
  12777. * @returns this particle system
  12778. */
  12779. removeColorGradient(gradient: number): IParticleSystem;
  12780. private _fetchR;
  12781. protected _reset(): void;
  12782. private _resetEffect;
  12783. private _createVertexBuffers;
  12784. private _createIndexBuffer;
  12785. /**
  12786. * Gets the maximum number of particles active at the same time.
  12787. * @returns The max number of active particles.
  12788. */
  12789. getCapacity(): number;
  12790. /**
  12791. * Gets whether there are still active particles in the system.
  12792. * @returns True if it is alive, otherwise false.
  12793. */
  12794. isAlive(): boolean;
  12795. /**
  12796. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12797. * @returns True if it has been started, otherwise false.
  12798. */
  12799. isStarted(): boolean;
  12800. private _prepareSubEmitterInternalArray;
  12801. /**
  12802. * Starts the particle system and begins to emit
  12803. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12804. */
  12805. start(delay?: number): void;
  12806. /**
  12807. * Stops the particle system.
  12808. * @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.
  12809. */
  12810. stop(stopSubEmitters?: boolean): void;
  12811. /**
  12812. * Remove all active particles
  12813. */
  12814. reset(): void;
  12815. /**
  12816. * @hidden (for internal use only)
  12817. */
  12818. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12819. /**
  12820. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12821. * Its lifetime will start back at 0.
  12822. */
  12823. recycleParticle: (particle: Particle) => void;
  12824. private _stopSubEmitters;
  12825. private _createParticle;
  12826. private _removeFromRoot;
  12827. private _emitFromParticle;
  12828. private _update;
  12829. /** @hidden */
  12830. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12831. /** @hidden */
  12832. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12833. /**
  12834. * Fill the defines array according to the current settings of the particle system
  12835. * @param defines Array to be updated
  12836. * @param blendMode blend mode to take into account when updating the array
  12837. */
  12838. fillDefines(defines: Array<string>, blendMode: number): void;
  12839. /**
  12840. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12841. * @param uniforms Uniforms array to fill
  12842. * @param attributes Attributes array to fill
  12843. * @param samplers Samplers array to fill
  12844. */
  12845. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12846. /** @hidden */
  12847. private _getEffect;
  12848. /**
  12849. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12850. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12851. */
  12852. animate(preWarmOnly?: boolean): void;
  12853. private _appendParticleVertices;
  12854. /**
  12855. * Rebuilds the particle system.
  12856. */
  12857. rebuild(): void;
  12858. /**
  12859. * Is this system ready to be used/rendered
  12860. * @return true if the system is ready
  12861. */
  12862. isReady(): boolean;
  12863. private _render;
  12864. /**
  12865. * Renders the particle system in its current state.
  12866. * @returns the current number of particles
  12867. */
  12868. render(): number;
  12869. /**
  12870. * Disposes the particle system and free the associated resources
  12871. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12872. */
  12873. dispose(disposeTexture?: boolean): void;
  12874. /**
  12875. * Clones the particle system.
  12876. * @param name The name of the cloned object
  12877. * @param newEmitter The new emitter to use
  12878. * @returns the cloned particle system
  12879. */
  12880. clone(name: string, newEmitter: any): ParticleSystem;
  12881. /**
  12882. * Serializes the particle system to a JSON object
  12883. * @param serializeTexture defines if the texture must be serialized as well
  12884. * @returns the JSON object
  12885. */
  12886. serialize(serializeTexture?: boolean): any;
  12887. /** @hidden */
  12888. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12889. /** @hidden */
  12890. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12891. /**
  12892. * Parses a JSON object to create a particle system.
  12893. * @param parsedParticleSystem The JSON object to parse
  12894. * @param scene The scene to create the particle system in
  12895. * @param rootUrl The root url to use to load external dependencies like texture
  12896. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12897. * @returns the Parsed particle system
  12898. */
  12899. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12900. }
  12901. }
  12902. declare module BABYLON {
  12903. /**
  12904. * A particle represents one of the element emitted by a particle system.
  12905. * This is mainly define by its coordinates, direction, velocity and age.
  12906. */
  12907. export class Particle {
  12908. /**
  12909. * The particle system the particle belongs to.
  12910. */
  12911. particleSystem: ParticleSystem;
  12912. private static _Count;
  12913. /**
  12914. * Unique ID of the particle
  12915. */
  12916. id: number;
  12917. /**
  12918. * The world position of the particle in the scene.
  12919. */
  12920. position: Vector3;
  12921. /**
  12922. * The world direction of the particle in the scene.
  12923. */
  12924. direction: Vector3;
  12925. /**
  12926. * The color of the particle.
  12927. */
  12928. color: Color4;
  12929. /**
  12930. * The color change of the particle per step.
  12931. */
  12932. colorStep: Color4;
  12933. /**
  12934. * Defines how long will the life of the particle be.
  12935. */
  12936. lifeTime: number;
  12937. /**
  12938. * The current age of the particle.
  12939. */
  12940. age: number;
  12941. /**
  12942. * The current size of the particle.
  12943. */
  12944. size: number;
  12945. /**
  12946. * The current scale of the particle.
  12947. */
  12948. scale: Vector2;
  12949. /**
  12950. * The current angle of the particle.
  12951. */
  12952. angle: number;
  12953. /**
  12954. * Defines how fast is the angle changing.
  12955. */
  12956. angularSpeed: number;
  12957. /**
  12958. * Defines the cell index used by the particle to be rendered from a sprite.
  12959. */
  12960. cellIndex: number;
  12961. /**
  12962. * The information required to support color remapping
  12963. */
  12964. remapData: Vector4;
  12965. /** @hidden */
  12966. _randomCellOffset?: number;
  12967. /** @hidden */
  12968. _initialDirection: Nullable<Vector3>;
  12969. /** @hidden */
  12970. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12971. /** @hidden */
  12972. _initialStartSpriteCellID: number;
  12973. /** @hidden */
  12974. _initialEndSpriteCellID: number;
  12975. /** @hidden */
  12976. _currentColorGradient: Nullable<ColorGradient>;
  12977. /** @hidden */
  12978. _currentColor1: Color4;
  12979. /** @hidden */
  12980. _currentColor2: Color4;
  12981. /** @hidden */
  12982. _currentSizeGradient: Nullable<FactorGradient>;
  12983. /** @hidden */
  12984. _currentSize1: number;
  12985. /** @hidden */
  12986. _currentSize2: number;
  12987. /** @hidden */
  12988. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12989. /** @hidden */
  12990. _currentAngularSpeed1: number;
  12991. /** @hidden */
  12992. _currentAngularSpeed2: number;
  12993. /** @hidden */
  12994. _currentVelocityGradient: Nullable<FactorGradient>;
  12995. /** @hidden */
  12996. _currentVelocity1: number;
  12997. /** @hidden */
  12998. _currentVelocity2: number;
  12999. /** @hidden */
  13000. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13001. /** @hidden */
  13002. _currentLimitVelocity1: number;
  13003. /** @hidden */
  13004. _currentLimitVelocity2: number;
  13005. /** @hidden */
  13006. _currentDragGradient: Nullable<FactorGradient>;
  13007. /** @hidden */
  13008. _currentDrag1: number;
  13009. /** @hidden */
  13010. _currentDrag2: number;
  13011. /** @hidden */
  13012. _randomNoiseCoordinates1: Vector3;
  13013. /** @hidden */
  13014. _randomNoiseCoordinates2: Vector3;
  13015. /** @hidden */
  13016. _localPosition?: Vector3;
  13017. /**
  13018. * Creates a new instance Particle
  13019. * @param particleSystem the particle system the particle belongs to
  13020. */
  13021. constructor(
  13022. /**
  13023. * The particle system the particle belongs to.
  13024. */
  13025. particleSystem: ParticleSystem);
  13026. private updateCellInfoFromSystem;
  13027. /**
  13028. * Defines how the sprite cell index is updated for the particle
  13029. */
  13030. updateCellIndex(): void;
  13031. /** @hidden */
  13032. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13033. /** @hidden */
  13034. _inheritParticleInfoToSubEmitters(): void;
  13035. /** @hidden */
  13036. _reset(): void;
  13037. /**
  13038. * Copy the properties of particle to another one.
  13039. * @param other the particle to copy the information to.
  13040. */
  13041. copyTo(other: Particle): void;
  13042. }
  13043. }
  13044. declare module BABYLON {
  13045. /**
  13046. * Particle emitter represents a volume emitting particles.
  13047. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13048. */
  13049. export interface IParticleEmitterType {
  13050. /**
  13051. * Called by the particle System when the direction is computed for the created particle.
  13052. * @param worldMatrix is the world matrix of the particle system
  13053. * @param directionToUpdate is the direction vector to update with the result
  13054. * @param particle is the particle we are computed the direction for
  13055. * @param isLocal defines if the direction should be set in local space
  13056. */
  13057. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13058. /**
  13059. * Called by the particle System when the position is computed for the created particle.
  13060. * @param worldMatrix is the world matrix of the particle system
  13061. * @param positionToUpdate is the position vector to update with the result
  13062. * @param particle is the particle we are computed the position for
  13063. * @param isLocal defines if the position should be set in local space
  13064. */
  13065. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13066. /**
  13067. * Clones the current emitter and returns a copy of it
  13068. * @returns the new emitter
  13069. */
  13070. clone(): IParticleEmitterType;
  13071. /**
  13072. * Called by the GPUParticleSystem to setup the update shader
  13073. * @param effect defines the update shader
  13074. */
  13075. applyToShader(effect: Effect): void;
  13076. /**
  13077. * Returns a string to use to update the GPU particles update shader
  13078. * @returns the effect defines string
  13079. */
  13080. getEffectDefines(): string;
  13081. /**
  13082. * Returns a string representing the class name
  13083. * @returns a string containing the class name
  13084. */
  13085. getClassName(): string;
  13086. /**
  13087. * Serializes the particle system to a JSON object.
  13088. * @returns the JSON object
  13089. */
  13090. serialize(): any;
  13091. /**
  13092. * Parse properties from a JSON object
  13093. * @param serializationObject defines the JSON object
  13094. * @param scene defines the hosting scene
  13095. */
  13096. parse(serializationObject: any, scene: Scene): void;
  13097. }
  13098. }
  13099. declare module BABYLON {
  13100. /**
  13101. * Particle emitter emitting particles from the inside of a box.
  13102. * It emits the particles randomly between 2 given directions.
  13103. */
  13104. export class BoxParticleEmitter implements IParticleEmitterType {
  13105. /**
  13106. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13107. */
  13108. direction1: Vector3;
  13109. /**
  13110. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13111. */
  13112. direction2: Vector3;
  13113. /**
  13114. * 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.
  13115. */
  13116. minEmitBox: Vector3;
  13117. /**
  13118. * 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.
  13119. */
  13120. maxEmitBox: Vector3;
  13121. /**
  13122. * Creates a new instance BoxParticleEmitter
  13123. */
  13124. constructor();
  13125. /**
  13126. * Called by the particle System when the direction is computed for the created particle.
  13127. * @param worldMatrix is the world matrix of the particle system
  13128. * @param directionToUpdate is the direction vector to update with the result
  13129. * @param particle is the particle we are computed the direction for
  13130. * @param isLocal defines if the direction should be set in local space
  13131. */
  13132. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13133. /**
  13134. * Called by the particle System when the position is computed for the created particle.
  13135. * @param worldMatrix is the world matrix of the particle system
  13136. * @param positionToUpdate is the position vector to update with the result
  13137. * @param particle is the particle we are computed the position for
  13138. * @param isLocal defines if the position should be set in local space
  13139. */
  13140. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13141. /**
  13142. * Clones the current emitter and returns a copy of it
  13143. * @returns the new emitter
  13144. */
  13145. clone(): BoxParticleEmitter;
  13146. /**
  13147. * Called by the GPUParticleSystem to setup the update shader
  13148. * @param effect defines the update shader
  13149. */
  13150. applyToShader(effect: Effect): void;
  13151. /**
  13152. * Returns a string to use to update the GPU particles update shader
  13153. * @returns a string containng the defines string
  13154. */
  13155. getEffectDefines(): string;
  13156. /**
  13157. * Returns the string "BoxParticleEmitter"
  13158. * @returns a string containing the class name
  13159. */
  13160. getClassName(): string;
  13161. /**
  13162. * Serializes the particle system to a JSON object.
  13163. * @returns the JSON object
  13164. */
  13165. serialize(): any;
  13166. /**
  13167. * Parse properties from a JSON object
  13168. * @param serializationObject defines the JSON object
  13169. */
  13170. parse(serializationObject: any): void;
  13171. }
  13172. }
  13173. declare module BABYLON {
  13174. /**
  13175. * Particle emitter emitting particles from the inside of a cone.
  13176. * It emits the particles alongside the cone volume from the base to the particle.
  13177. * The emission direction might be randomized.
  13178. */
  13179. export class ConeParticleEmitter implements IParticleEmitterType {
  13180. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13181. directionRandomizer: number;
  13182. private _radius;
  13183. private _angle;
  13184. private _height;
  13185. /**
  13186. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13187. */
  13188. radiusRange: number;
  13189. /**
  13190. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13191. */
  13192. heightRange: number;
  13193. /**
  13194. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13195. */
  13196. emitFromSpawnPointOnly: boolean;
  13197. /**
  13198. * Gets or sets the radius of the emission cone
  13199. */
  13200. get radius(): number;
  13201. set radius(value: number);
  13202. /**
  13203. * Gets or sets the angle of the emission cone
  13204. */
  13205. get angle(): number;
  13206. set angle(value: number);
  13207. private _buildHeight;
  13208. /**
  13209. * Creates a new instance ConeParticleEmitter
  13210. * @param radius the radius of the emission cone (1 by default)
  13211. * @param angle the cone base angle (PI by default)
  13212. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13213. */
  13214. constructor(radius?: number, angle?: number,
  13215. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13216. directionRandomizer?: number);
  13217. /**
  13218. * Called by the particle System when the direction is computed for the created particle.
  13219. * @param worldMatrix is the world matrix of the particle system
  13220. * @param directionToUpdate is the direction vector to update with the result
  13221. * @param particle is the particle we are computed the direction for
  13222. * @param isLocal defines if the direction should be set in local space
  13223. */
  13224. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13225. /**
  13226. * Called by the particle System when the position is computed for the created particle.
  13227. * @param worldMatrix is the world matrix of the particle system
  13228. * @param positionToUpdate is the position vector to update with the result
  13229. * @param particle is the particle we are computed the position for
  13230. * @param isLocal defines if the position should be set in local space
  13231. */
  13232. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13233. /**
  13234. * Clones the current emitter and returns a copy of it
  13235. * @returns the new emitter
  13236. */
  13237. clone(): ConeParticleEmitter;
  13238. /**
  13239. * Called by the GPUParticleSystem to setup the update shader
  13240. * @param effect defines the update shader
  13241. */
  13242. applyToShader(effect: Effect): void;
  13243. /**
  13244. * Returns a string to use to update the GPU particles update shader
  13245. * @returns a string containng the defines string
  13246. */
  13247. getEffectDefines(): string;
  13248. /**
  13249. * Returns the string "ConeParticleEmitter"
  13250. * @returns a string containing the class name
  13251. */
  13252. getClassName(): string;
  13253. /**
  13254. * Serializes the particle system to a JSON object.
  13255. * @returns the JSON object
  13256. */
  13257. serialize(): any;
  13258. /**
  13259. * Parse properties from a JSON object
  13260. * @param serializationObject defines the JSON object
  13261. */
  13262. parse(serializationObject: any): void;
  13263. }
  13264. }
  13265. declare module BABYLON {
  13266. /**
  13267. * Particle emitter emitting particles from the inside of a cylinder.
  13268. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13269. */
  13270. export class CylinderParticleEmitter implements IParticleEmitterType {
  13271. /**
  13272. * The radius of the emission cylinder.
  13273. */
  13274. radius: number;
  13275. /**
  13276. * The height of the emission cylinder.
  13277. */
  13278. height: number;
  13279. /**
  13280. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13281. */
  13282. radiusRange: number;
  13283. /**
  13284. * How much to randomize the particle direction [0-1].
  13285. */
  13286. directionRandomizer: number;
  13287. /**
  13288. * Creates a new instance CylinderParticleEmitter
  13289. * @param radius the radius of the emission cylinder (1 by default)
  13290. * @param height the height of the emission cylinder (1 by default)
  13291. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13292. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13293. */
  13294. constructor(
  13295. /**
  13296. * The radius of the emission cylinder.
  13297. */
  13298. radius?: number,
  13299. /**
  13300. * The height of the emission cylinder.
  13301. */
  13302. height?: number,
  13303. /**
  13304. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13305. */
  13306. radiusRange?: number,
  13307. /**
  13308. * How much to randomize the particle direction [0-1].
  13309. */
  13310. directionRandomizer?: number);
  13311. /**
  13312. * Called by the particle System when the direction is computed for the created particle.
  13313. * @param worldMatrix is the world matrix of the particle system
  13314. * @param directionToUpdate is the direction vector to update with the result
  13315. * @param particle is the particle we are computed the direction for
  13316. * @param isLocal defines if the direction should be set in local space
  13317. */
  13318. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13319. /**
  13320. * Called by the particle System when the position is computed for the created particle.
  13321. * @param worldMatrix is the world matrix of the particle system
  13322. * @param positionToUpdate is the position vector to update with the result
  13323. * @param particle is the particle we are computed the position for
  13324. * @param isLocal defines if the position should be set in local space
  13325. */
  13326. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13327. /**
  13328. * Clones the current emitter and returns a copy of it
  13329. * @returns the new emitter
  13330. */
  13331. clone(): CylinderParticleEmitter;
  13332. /**
  13333. * Called by the GPUParticleSystem to setup the update shader
  13334. * @param effect defines the update shader
  13335. */
  13336. applyToShader(effect: Effect): void;
  13337. /**
  13338. * Returns a string to use to update the GPU particles update shader
  13339. * @returns a string containng the defines string
  13340. */
  13341. getEffectDefines(): string;
  13342. /**
  13343. * Returns the string "CylinderParticleEmitter"
  13344. * @returns a string containing the class name
  13345. */
  13346. getClassName(): string;
  13347. /**
  13348. * Serializes the particle system to a JSON object.
  13349. * @returns the JSON object
  13350. */
  13351. serialize(): any;
  13352. /**
  13353. * Parse properties from a JSON object
  13354. * @param serializationObject defines the JSON object
  13355. */
  13356. parse(serializationObject: any): void;
  13357. }
  13358. /**
  13359. * Particle emitter emitting particles from the inside of a cylinder.
  13360. * It emits the particles randomly between two vectors.
  13361. */
  13362. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13363. /**
  13364. * The min limit of the emission direction.
  13365. */
  13366. direction1: Vector3;
  13367. /**
  13368. * The max limit of the emission direction.
  13369. */
  13370. direction2: Vector3;
  13371. /**
  13372. * Creates a new instance CylinderDirectedParticleEmitter
  13373. * @param radius the radius of the emission cylinder (1 by default)
  13374. * @param height the height of the emission cylinder (1 by default)
  13375. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13376. * @param direction1 the min limit of the emission direction (up vector by default)
  13377. * @param direction2 the max limit of the emission direction (up vector by default)
  13378. */
  13379. constructor(radius?: number, height?: number, radiusRange?: number,
  13380. /**
  13381. * The min limit of the emission direction.
  13382. */
  13383. direction1?: Vector3,
  13384. /**
  13385. * The max limit of the emission direction.
  13386. */
  13387. direction2?: Vector3);
  13388. /**
  13389. * Called by the particle System when the direction is computed for the created particle.
  13390. * @param worldMatrix is the world matrix of the particle system
  13391. * @param directionToUpdate is the direction vector to update with the result
  13392. * @param particle is the particle we are computed the direction for
  13393. */
  13394. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13395. /**
  13396. * Clones the current emitter and returns a copy of it
  13397. * @returns the new emitter
  13398. */
  13399. clone(): CylinderDirectedParticleEmitter;
  13400. /**
  13401. * Called by the GPUParticleSystem to setup the update shader
  13402. * @param effect defines the update shader
  13403. */
  13404. applyToShader(effect: Effect): void;
  13405. /**
  13406. * Returns a string to use to update the GPU particles update shader
  13407. * @returns a string containng the defines string
  13408. */
  13409. getEffectDefines(): string;
  13410. /**
  13411. * Returns the string "CylinderDirectedParticleEmitter"
  13412. * @returns a string containing the class name
  13413. */
  13414. getClassName(): string;
  13415. /**
  13416. * Serializes the particle system to a JSON object.
  13417. * @returns the JSON object
  13418. */
  13419. serialize(): any;
  13420. /**
  13421. * Parse properties from a JSON object
  13422. * @param serializationObject defines the JSON object
  13423. */
  13424. parse(serializationObject: any): void;
  13425. }
  13426. }
  13427. declare module BABYLON {
  13428. /**
  13429. * Particle emitter emitting particles from the inside of a hemisphere.
  13430. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13431. */
  13432. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13433. /**
  13434. * The radius of the emission hemisphere.
  13435. */
  13436. radius: number;
  13437. /**
  13438. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13439. */
  13440. radiusRange: number;
  13441. /**
  13442. * How much to randomize the particle direction [0-1].
  13443. */
  13444. directionRandomizer: number;
  13445. /**
  13446. * Creates a new instance HemisphericParticleEmitter
  13447. * @param radius the radius of the emission hemisphere (1 by default)
  13448. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13449. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13450. */
  13451. constructor(
  13452. /**
  13453. * The radius of the emission hemisphere.
  13454. */
  13455. radius?: number,
  13456. /**
  13457. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13458. */
  13459. radiusRange?: number,
  13460. /**
  13461. * How much to randomize the particle direction [0-1].
  13462. */
  13463. directionRandomizer?: number);
  13464. /**
  13465. * Called by the particle System when the direction is computed for the created particle.
  13466. * @param worldMatrix is the world matrix of the particle system
  13467. * @param directionToUpdate is the direction vector to update with the result
  13468. * @param particle is the particle we are computed the direction for
  13469. * @param isLocal defines if the direction should be set in local space
  13470. */
  13471. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13472. /**
  13473. * Called by the particle System when the position is computed for the created particle.
  13474. * @param worldMatrix is the world matrix of the particle system
  13475. * @param positionToUpdate is the position vector to update with the result
  13476. * @param particle is the particle we are computed the position for
  13477. * @param isLocal defines if the position should be set in local space
  13478. */
  13479. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13480. /**
  13481. * Clones the current emitter and returns a copy of it
  13482. * @returns the new emitter
  13483. */
  13484. clone(): HemisphericParticleEmitter;
  13485. /**
  13486. * Called by the GPUParticleSystem to setup the update shader
  13487. * @param effect defines the update shader
  13488. */
  13489. applyToShader(effect: Effect): void;
  13490. /**
  13491. * Returns a string to use to update the GPU particles update shader
  13492. * @returns a string containng the defines string
  13493. */
  13494. getEffectDefines(): string;
  13495. /**
  13496. * Returns the string "HemisphericParticleEmitter"
  13497. * @returns a string containing the class name
  13498. */
  13499. getClassName(): string;
  13500. /**
  13501. * Serializes the particle system to a JSON object.
  13502. * @returns the JSON object
  13503. */
  13504. serialize(): any;
  13505. /**
  13506. * Parse properties from a JSON object
  13507. * @param serializationObject defines the JSON object
  13508. */
  13509. parse(serializationObject: any): void;
  13510. }
  13511. }
  13512. declare module BABYLON {
  13513. /**
  13514. * Particle emitter emitting particles from a point.
  13515. * It emits the particles randomly between 2 given directions.
  13516. */
  13517. export class PointParticleEmitter implements IParticleEmitterType {
  13518. /**
  13519. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13520. */
  13521. direction1: Vector3;
  13522. /**
  13523. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13524. */
  13525. direction2: Vector3;
  13526. /**
  13527. * Creates a new instance PointParticleEmitter
  13528. */
  13529. constructor();
  13530. /**
  13531. * Called by the particle System when the direction is computed for the created particle.
  13532. * @param worldMatrix is the world matrix of the particle system
  13533. * @param directionToUpdate is the direction vector to update with the result
  13534. * @param particle is the particle we are computed the direction for
  13535. * @param isLocal defines if the direction should be set in local space
  13536. */
  13537. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13538. /**
  13539. * Called by the particle System when the position is computed for the created particle.
  13540. * @param worldMatrix is the world matrix of the particle system
  13541. * @param positionToUpdate is the position vector to update with the result
  13542. * @param particle is the particle we are computed the position for
  13543. * @param isLocal defines if the position should be set in local space
  13544. */
  13545. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13546. /**
  13547. * Clones the current emitter and returns a copy of it
  13548. * @returns the new emitter
  13549. */
  13550. clone(): PointParticleEmitter;
  13551. /**
  13552. * Called by the GPUParticleSystem to setup the update shader
  13553. * @param effect defines the update shader
  13554. */
  13555. applyToShader(effect: Effect): void;
  13556. /**
  13557. * Returns a string to use to update the GPU particles update shader
  13558. * @returns a string containng the defines string
  13559. */
  13560. getEffectDefines(): string;
  13561. /**
  13562. * Returns the string "PointParticleEmitter"
  13563. * @returns a string containing the class name
  13564. */
  13565. getClassName(): string;
  13566. /**
  13567. * Serializes the particle system to a JSON object.
  13568. * @returns the JSON object
  13569. */
  13570. serialize(): any;
  13571. /**
  13572. * Parse properties from a JSON object
  13573. * @param serializationObject defines the JSON object
  13574. */
  13575. parse(serializationObject: any): void;
  13576. }
  13577. }
  13578. declare module BABYLON {
  13579. /**
  13580. * Particle emitter emitting particles from the inside of a sphere.
  13581. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13582. */
  13583. export class SphereParticleEmitter implements IParticleEmitterType {
  13584. /**
  13585. * The radius of the emission sphere.
  13586. */
  13587. radius: number;
  13588. /**
  13589. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13590. */
  13591. radiusRange: number;
  13592. /**
  13593. * How much to randomize the particle direction [0-1].
  13594. */
  13595. directionRandomizer: number;
  13596. /**
  13597. * Creates a new instance SphereParticleEmitter
  13598. * @param radius the radius of the emission sphere (1 by default)
  13599. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13600. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13601. */
  13602. constructor(
  13603. /**
  13604. * The radius of the emission sphere.
  13605. */
  13606. radius?: number,
  13607. /**
  13608. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13609. */
  13610. radiusRange?: number,
  13611. /**
  13612. * How much to randomize the particle direction [0-1].
  13613. */
  13614. directionRandomizer?: number);
  13615. /**
  13616. * Called by the particle System when the direction is computed for the created particle.
  13617. * @param worldMatrix is the world matrix of the particle system
  13618. * @param directionToUpdate is the direction vector to update with the result
  13619. * @param particle is the particle we are computed the direction for
  13620. * @param isLocal defines if the direction should be set in local space
  13621. */
  13622. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13623. /**
  13624. * Called by the particle System when the position is computed for the created particle.
  13625. * @param worldMatrix is the world matrix of the particle system
  13626. * @param positionToUpdate is the position vector to update with the result
  13627. * @param particle is the particle we are computed the position for
  13628. * @param isLocal defines if the position should be set in local space
  13629. */
  13630. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13631. /**
  13632. * Clones the current emitter and returns a copy of it
  13633. * @returns the new emitter
  13634. */
  13635. clone(): SphereParticleEmitter;
  13636. /**
  13637. * Called by the GPUParticleSystem to setup the update shader
  13638. * @param effect defines the update shader
  13639. */
  13640. applyToShader(effect: Effect): void;
  13641. /**
  13642. * Returns a string to use to update the GPU particles update shader
  13643. * @returns a string containng the defines string
  13644. */
  13645. getEffectDefines(): string;
  13646. /**
  13647. * Returns the string "SphereParticleEmitter"
  13648. * @returns a string containing the class name
  13649. */
  13650. getClassName(): string;
  13651. /**
  13652. * Serializes the particle system to a JSON object.
  13653. * @returns the JSON object
  13654. */
  13655. serialize(): any;
  13656. /**
  13657. * Parse properties from a JSON object
  13658. * @param serializationObject defines the JSON object
  13659. */
  13660. parse(serializationObject: any): void;
  13661. }
  13662. /**
  13663. * Particle emitter emitting particles from the inside of a sphere.
  13664. * It emits the particles randomly between two vectors.
  13665. */
  13666. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13667. /**
  13668. * The min limit of the emission direction.
  13669. */
  13670. direction1: Vector3;
  13671. /**
  13672. * The max limit of the emission direction.
  13673. */
  13674. direction2: Vector3;
  13675. /**
  13676. * Creates a new instance SphereDirectedParticleEmitter
  13677. * @param radius the radius of the emission sphere (1 by default)
  13678. * @param direction1 the min limit of the emission direction (up vector by default)
  13679. * @param direction2 the max limit of the emission direction (up vector by default)
  13680. */
  13681. constructor(radius?: number,
  13682. /**
  13683. * The min limit of the emission direction.
  13684. */
  13685. direction1?: Vector3,
  13686. /**
  13687. * The max limit of the emission direction.
  13688. */
  13689. direction2?: Vector3);
  13690. /**
  13691. * Called by the particle System when the direction is computed for the created particle.
  13692. * @param worldMatrix is the world matrix of the particle system
  13693. * @param directionToUpdate is the direction vector to update with the result
  13694. * @param particle is the particle we are computed the direction for
  13695. */
  13696. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13697. /**
  13698. * Clones the current emitter and returns a copy of it
  13699. * @returns the new emitter
  13700. */
  13701. clone(): SphereDirectedParticleEmitter;
  13702. /**
  13703. * Called by the GPUParticleSystem to setup the update shader
  13704. * @param effect defines the update shader
  13705. */
  13706. applyToShader(effect: Effect): void;
  13707. /**
  13708. * Returns a string to use to update the GPU particles update shader
  13709. * @returns a string containng the defines string
  13710. */
  13711. getEffectDefines(): string;
  13712. /**
  13713. * Returns the string "SphereDirectedParticleEmitter"
  13714. * @returns a string containing the class name
  13715. */
  13716. getClassName(): string;
  13717. /**
  13718. * Serializes the particle system to a JSON object.
  13719. * @returns the JSON object
  13720. */
  13721. serialize(): any;
  13722. /**
  13723. * Parse properties from a JSON object
  13724. * @param serializationObject defines the JSON object
  13725. */
  13726. parse(serializationObject: any): void;
  13727. }
  13728. }
  13729. declare module BABYLON {
  13730. /**
  13731. * Particle emitter emitting particles from a custom list of positions.
  13732. */
  13733. export class CustomParticleEmitter implements IParticleEmitterType {
  13734. /**
  13735. * Gets or sets the position generator that will create the inital position of each particle.
  13736. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13737. */
  13738. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13739. /**
  13740. * Gets or sets the destination generator that will create the final destination of each particle.
  13741. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13742. */
  13743. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13744. /**
  13745. * Creates a new instance CustomParticleEmitter
  13746. */
  13747. constructor();
  13748. /**
  13749. * Called by the particle System when the direction is computed for the created particle.
  13750. * @param worldMatrix is the world matrix of the particle system
  13751. * @param directionToUpdate is the direction vector to update with the result
  13752. * @param particle is the particle we are computed the direction for
  13753. * @param isLocal defines if the direction should be set in local space
  13754. */
  13755. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13756. /**
  13757. * Called by the particle System when the position is computed for the created particle.
  13758. * @param worldMatrix is the world matrix of the particle system
  13759. * @param positionToUpdate is the position vector to update with the result
  13760. * @param particle is the particle we are computed the position for
  13761. * @param isLocal defines if the position should be set in local space
  13762. */
  13763. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13764. /**
  13765. * Clones the current emitter and returns a copy of it
  13766. * @returns the new emitter
  13767. */
  13768. clone(): CustomParticleEmitter;
  13769. /**
  13770. * Called by the GPUParticleSystem to setup the update shader
  13771. * @param effect defines the update shader
  13772. */
  13773. applyToShader(effect: Effect): void;
  13774. /**
  13775. * Returns a string to use to update the GPU particles update shader
  13776. * @returns a string containng the defines string
  13777. */
  13778. getEffectDefines(): string;
  13779. /**
  13780. * Returns the string "PointParticleEmitter"
  13781. * @returns a string containing the class name
  13782. */
  13783. getClassName(): string;
  13784. /**
  13785. * Serializes the particle system to a JSON object.
  13786. * @returns the JSON object
  13787. */
  13788. serialize(): any;
  13789. /**
  13790. * Parse properties from a JSON object
  13791. * @param serializationObject defines the JSON object
  13792. */
  13793. parse(serializationObject: any): void;
  13794. }
  13795. }
  13796. declare module BABYLON {
  13797. /**
  13798. * Particle emitter emitting particles from the inside of a box.
  13799. * It emits the particles randomly between 2 given directions.
  13800. */
  13801. export class MeshParticleEmitter implements IParticleEmitterType {
  13802. private _indices;
  13803. private _positions;
  13804. private _normals;
  13805. private _storedNormal;
  13806. private _mesh;
  13807. /**
  13808. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13809. */
  13810. direction1: Vector3;
  13811. /**
  13812. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13813. */
  13814. direction2: Vector3;
  13815. /**
  13816. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13817. */
  13818. useMeshNormalsForDirection: boolean;
  13819. /** Defines the mesh to use as source */
  13820. get mesh(): Nullable<AbstractMesh>;
  13821. set mesh(value: Nullable<AbstractMesh>);
  13822. /**
  13823. * Creates a new instance MeshParticleEmitter
  13824. * @param mesh defines the mesh to use as source
  13825. */
  13826. constructor(mesh?: Nullable<AbstractMesh>);
  13827. /**
  13828. * Called by the particle System when the direction is computed for the created particle.
  13829. * @param worldMatrix is the world matrix of the particle system
  13830. * @param directionToUpdate is the direction vector to update with the result
  13831. * @param particle is the particle we are computed the direction for
  13832. * @param isLocal defines if the direction should be set in local space
  13833. */
  13834. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13835. /**
  13836. * Called by the particle System when the position is computed for the created particle.
  13837. * @param worldMatrix is the world matrix of the particle system
  13838. * @param positionToUpdate is the position vector to update with the result
  13839. * @param particle is the particle we are computed the position for
  13840. * @param isLocal defines if the position should be set in local space
  13841. */
  13842. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13843. /**
  13844. * Clones the current emitter and returns a copy of it
  13845. * @returns the new emitter
  13846. */
  13847. clone(): MeshParticleEmitter;
  13848. /**
  13849. * Called by the GPUParticleSystem to setup the update shader
  13850. * @param effect defines the update shader
  13851. */
  13852. applyToShader(effect: Effect): void;
  13853. /**
  13854. * Returns a string to use to update the GPU particles update shader
  13855. * @returns a string containng the defines string
  13856. */
  13857. getEffectDefines(): string;
  13858. /**
  13859. * Returns the string "BoxParticleEmitter"
  13860. * @returns a string containing the class name
  13861. */
  13862. getClassName(): string;
  13863. /**
  13864. * Serializes the particle system to a JSON object.
  13865. * @returns the JSON object
  13866. */
  13867. serialize(): any;
  13868. /**
  13869. * Parse properties from a JSON object
  13870. * @param serializationObject defines the JSON object
  13871. * @param scene defines the hosting scene
  13872. */
  13873. parse(serializationObject: any, scene: Scene): void;
  13874. }
  13875. }
  13876. declare module BABYLON {
  13877. /**
  13878. * Interface representing a particle system in Babylon.js.
  13879. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13880. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13881. */
  13882. export interface IParticleSystem {
  13883. /**
  13884. * List of animations used by the particle system.
  13885. */
  13886. animations: Animation[];
  13887. /**
  13888. * The id of the Particle system.
  13889. */
  13890. id: string;
  13891. /**
  13892. * The name of the Particle system.
  13893. */
  13894. name: string;
  13895. /**
  13896. * The emitter represents the Mesh or position we are attaching the particle system to.
  13897. */
  13898. emitter: Nullable<AbstractMesh | Vector3>;
  13899. /**
  13900. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13901. */
  13902. isBillboardBased: boolean;
  13903. /**
  13904. * The rendering group used by the Particle system to chose when to render.
  13905. */
  13906. renderingGroupId: number;
  13907. /**
  13908. * The layer mask we are rendering the particles through.
  13909. */
  13910. layerMask: number;
  13911. /**
  13912. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13913. */
  13914. updateSpeed: number;
  13915. /**
  13916. * The amount of time the particle system is running (depends of the overall update speed).
  13917. */
  13918. targetStopDuration: number;
  13919. /**
  13920. * The texture used to render each particle. (this can be a spritesheet)
  13921. */
  13922. particleTexture: Nullable<Texture>;
  13923. /**
  13924. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13925. */
  13926. blendMode: number;
  13927. /**
  13928. * Minimum life time of emitting particles.
  13929. */
  13930. minLifeTime: number;
  13931. /**
  13932. * Maximum life time of emitting particles.
  13933. */
  13934. maxLifeTime: number;
  13935. /**
  13936. * Minimum Size of emitting particles.
  13937. */
  13938. minSize: number;
  13939. /**
  13940. * Maximum Size of emitting particles.
  13941. */
  13942. maxSize: number;
  13943. /**
  13944. * Minimum scale of emitting particles on X axis.
  13945. */
  13946. minScaleX: number;
  13947. /**
  13948. * Maximum scale of emitting particles on X axis.
  13949. */
  13950. maxScaleX: number;
  13951. /**
  13952. * Minimum scale of emitting particles on Y axis.
  13953. */
  13954. minScaleY: number;
  13955. /**
  13956. * Maximum scale of emitting particles on Y axis.
  13957. */
  13958. maxScaleY: number;
  13959. /**
  13960. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13961. */
  13962. color1: Color4;
  13963. /**
  13964. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13965. */
  13966. color2: Color4;
  13967. /**
  13968. * Color the particle will have at the end of its lifetime.
  13969. */
  13970. colorDead: Color4;
  13971. /**
  13972. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13973. */
  13974. emitRate: number;
  13975. /**
  13976. * You can use gravity if you want to give an orientation to your particles.
  13977. */
  13978. gravity: Vector3;
  13979. /**
  13980. * Minimum power of emitting particles.
  13981. */
  13982. minEmitPower: number;
  13983. /**
  13984. * Maximum power of emitting particles.
  13985. */
  13986. maxEmitPower: number;
  13987. /**
  13988. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13989. */
  13990. minAngularSpeed: number;
  13991. /**
  13992. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13993. */
  13994. maxAngularSpeed: number;
  13995. /**
  13996. * Gets or sets the minimal initial rotation in radians.
  13997. */
  13998. minInitialRotation: number;
  13999. /**
  14000. * Gets or sets the maximal initial rotation in radians.
  14001. */
  14002. maxInitialRotation: number;
  14003. /**
  14004. * The particle emitter type defines the emitter used by the particle system.
  14005. * It can be for example box, sphere, or cone...
  14006. */
  14007. particleEmitterType: Nullable<IParticleEmitterType>;
  14008. /**
  14009. * Defines the delay in milliseconds before starting the system (0 by default)
  14010. */
  14011. startDelay: number;
  14012. /**
  14013. * 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
  14014. */
  14015. preWarmCycles: number;
  14016. /**
  14017. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14018. */
  14019. preWarmStepOffset: number;
  14020. /**
  14021. * 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)
  14022. */
  14023. spriteCellChangeSpeed: number;
  14024. /**
  14025. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14026. */
  14027. startSpriteCellID: number;
  14028. /**
  14029. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14030. */
  14031. endSpriteCellID: number;
  14032. /**
  14033. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14034. */
  14035. spriteCellWidth: number;
  14036. /**
  14037. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14038. */
  14039. spriteCellHeight: number;
  14040. /**
  14041. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14042. */
  14043. spriteRandomStartCell: boolean;
  14044. /**
  14045. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14046. */
  14047. isAnimationSheetEnabled: boolean;
  14048. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14049. translationPivot: Vector2;
  14050. /**
  14051. * Gets or sets a texture used to add random noise to particle positions
  14052. */
  14053. noiseTexture: Nullable<BaseTexture>;
  14054. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14055. noiseStrength: Vector3;
  14056. /**
  14057. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14058. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14059. */
  14060. billboardMode: number;
  14061. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14062. limitVelocityDamping: number;
  14063. /**
  14064. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14065. */
  14066. beginAnimationOnStart: boolean;
  14067. /**
  14068. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14069. */
  14070. beginAnimationFrom: number;
  14071. /**
  14072. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14073. */
  14074. beginAnimationTo: number;
  14075. /**
  14076. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14077. */
  14078. beginAnimationLoop: boolean;
  14079. /**
  14080. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14081. */
  14082. disposeOnStop: boolean;
  14083. /**
  14084. * Specifies if the particles are updated in emitter local space or world space
  14085. */
  14086. isLocal: boolean;
  14087. /** Snippet ID if the particle system was created from the snippet server */
  14088. snippetId: string;
  14089. /**
  14090. * Gets the maximum number of particles active at the same time.
  14091. * @returns The max number of active particles.
  14092. */
  14093. getCapacity(): number;
  14094. /**
  14095. * Gets the number of particles active at the same time.
  14096. * @returns The number of active particles.
  14097. */
  14098. getActiveCount(): number;
  14099. /**
  14100. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14101. * @returns True if it has been started, otherwise false.
  14102. */
  14103. isStarted(): boolean;
  14104. /**
  14105. * Animates the particle system for this frame.
  14106. */
  14107. animate(): void;
  14108. /**
  14109. * Renders the particle system in its current state.
  14110. * @returns the current number of particles
  14111. */
  14112. render(): number;
  14113. /**
  14114. * Dispose the particle system and frees its associated resources.
  14115. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14116. */
  14117. dispose(disposeTexture?: boolean): void;
  14118. /**
  14119. * An event triggered when the system is disposed
  14120. */
  14121. onDisposeObservable: Observable<IParticleSystem>;
  14122. /**
  14123. * Clones the particle system.
  14124. * @param name The name of the cloned object
  14125. * @param newEmitter The new emitter to use
  14126. * @returns the cloned particle system
  14127. */
  14128. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14129. /**
  14130. * Serializes the particle system to a JSON object
  14131. * @param serializeTexture defines if the texture must be serialized as well
  14132. * @returns the JSON object
  14133. */
  14134. serialize(serializeTexture: boolean): any;
  14135. /**
  14136. * Rebuild the particle system
  14137. */
  14138. rebuild(): void;
  14139. /** Force the system to rebuild all gradients that need to be resync */
  14140. forceRefreshGradients(): void;
  14141. /**
  14142. * Starts the particle system and begins to emit
  14143. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14144. */
  14145. start(delay?: number): void;
  14146. /**
  14147. * Stops the particle system.
  14148. */
  14149. stop(): void;
  14150. /**
  14151. * Remove all active particles
  14152. */
  14153. reset(): void;
  14154. /**
  14155. * Gets a boolean indicating that the system is stopping
  14156. * @returns true if the system is currently stopping
  14157. */
  14158. isStopping(): boolean;
  14159. /**
  14160. * Is this system ready to be used/rendered
  14161. * @return true if the system is ready
  14162. */
  14163. isReady(): boolean;
  14164. /**
  14165. * Returns the string "ParticleSystem"
  14166. * @returns a string containing the class name
  14167. */
  14168. getClassName(): string;
  14169. /**
  14170. * Gets the custom effect used to render the particles
  14171. * @param blendMode Blend mode for which the effect should be retrieved
  14172. * @returns The effect
  14173. */
  14174. getCustomEffect(blendMode: number): Nullable<Effect>;
  14175. /**
  14176. * Sets the custom effect used to render the particles
  14177. * @param effect The effect to set
  14178. * @param blendMode Blend mode for which the effect should be set
  14179. */
  14180. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14181. /**
  14182. * Fill the defines array according to the current settings of the particle system
  14183. * @param defines Array to be updated
  14184. * @param blendMode blend mode to take into account when updating the array
  14185. */
  14186. fillDefines(defines: Array<string>, blendMode: number): void;
  14187. /**
  14188. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14189. * @param uniforms Uniforms array to fill
  14190. * @param attributes Attributes array to fill
  14191. * @param samplers Samplers array to fill
  14192. */
  14193. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14194. /**
  14195. * Observable that will be called just before the particles are drawn
  14196. */
  14197. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14198. /**
  14199. * Gets the name of the particle vertex shader
  14200. */
  14201. vertexShaderName: string;
  14202. /**
  14203. * Adds a new color gradient
  14204. * @param gradient defines the gradient to use (between 0 and 1)
  14205. * @param color1 defines the color to affect to the specified gradient
  14206. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14207. * @returns the current particle system
  14208. */
  14209. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14210. /**
  14211. * Remove a specific color gradient
  14212. * @param gradient defines the gradient to remove
  14213. * @returns the current particle system
  14214. */
  14215. removeColorGradient(gradient: number): IParticleSystem;
  14216. /**
  14217. * Adds a new size gradient
  14218. * @param gradient defines the gradient to use (between 0 and 1)
  14219. * @param factor defines the size factor 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. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14224. /**
  14225. * Remove a specific size gradient
  14226. * @param gradient defines the gradient to remove
  14227. * @returns the current particle system
  14228. */
  14229. removeSizeGradient(gradient: number): IParticleSystem;
  14230. /**
  14231. * Gets the current list of color gradients.
  14232. * You must use addColorGradient and removeColorGradient to udpate this list
  14233. * @returns the list of color gradients
  14234. */
  14235. getColorGradients(): Nullable<Array<ColorGradient>>;
  14236. /**
  14237. * Gets the current list of size gradients.
  14238. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14239. * @returns the list of size gradients
  14240. */
  14241. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14242. /**
  14243. * Gets the current list of angular speed gradients.
  14244. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14245. * @returns the list of angular speed gradients
  14246. */
  14247. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14248. /**
  14249. * Adds a new angular speed gradient
  14250. * @param gradient defines the gradient to use (between 0 and 1)
  14251. * @param factor defines the angular speed to affect to the specified gradient
  14252. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14253. * @returns the current particle system
  14254. */
  14255. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14256. /**
  14257. * Remove a specific angular speed gradient
  14258. * @param gradient defines the gradient to remove
  14259. * @returns the current particle system
  14260. */
  14261. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14262. /**
  14263. * Gets the current list of velocity gradients.
  14264. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14265. * @returns the list of velocity gradients
  14266. */
  14267. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14268. /**
  14269. * Adds a new velocity gradient
  14270. * @param gradient defines the gradient to use (between 0 and 1)
  14271. * @param factor defines the velocity to affect to the specified gradient
  14272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14273. * @returns the current particle system
  14274. */
  14275. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14276. /**
  14277. * Remove a specific velocity gradient
  14278. * @param gradient defines the gradient to remove
  14279. * @returns the current particle system
  14280. */
  14281. removeVelocityGradient(gradient: number): IParticleSystem;
  14282. /**
  14283. * Gets the current list of limit velocity gradients.
  14284. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14285. * @returns the list of limit velocity gradients
  14286. */
  14287. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14288. /**
  14289. * Adds a new limit velocity gradient
  14290. * @param gradient defines the gradient to use (between 0 and 1)
  14291. * @param factor defines the limit velocity to affect to the specified gradient
  14292. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14293. * @returns the current particle system
  14294. */
  14295. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14296. /**
  14297. * Remove a specific limit velocity gradient
  14298. * @param gradient defines the gradient to remove
  14299. * @returns the current particle system
  14300. */
  14301. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14302. /**
  14303. * Adds a new drag gradient
  14304. * @param gradient defines the gradient to use (between 0 and 1)
  14305. * @param factor defines the drag to affect to the specified gradient
  14306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14307. * @returns the current particle system
  14308. */
  14309. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14310. /**
  14311. * Remove a specific drag gradient
  14312. * @param gradient defines the gradient to remove
  14313. * @returns the current particle system
  14314. */
  14315. removeDragGradient(gradient: number): IParticleSystem;
  14316. /**
  14317. * Gets the current list of drag gradients.
  14318. * You must use addDragGradient and removeDragGradient to udpate this list
  14319. * @returns the list of drag gradients
  14320. */
  14321. getDragGradients(): Nullable<Array<FactorGradient>>;
  14322. /**
  14323. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14324. * @param gradient defines the gradient to use (between 0 and 1)
  14325. * @param factor defines the emit rate to affect to the specified gradient
  14326. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14327. * @returns the current particle system
  14328. */
  14329. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14330. /**
  14331. * Remove a specific emit rate gradient
  14332. * @param gradient defines the gradient to remove
  14333. * @returns the current particle system
  14334. */
  14335. removeEmitRateGradient(gradient: number): IParticleSystem;
  14336. /**
  14337. * Gets the current list of emit rate gradients.
  14338. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14339. * @returns the list of emit rate gradients
  14340. */
  14341. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14342. /**
  14343. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14344. * @param gradient defines the gradient to use (between 0 and 1)
  14345. * @param factor defines the start size to affect to the specified gradient
  14346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14347. * @returns the current particle system
  14348. */
  14349. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14350. /**
  14351. * Remove a specific start size gradient
  14352. * @param gradient defines the gradient to remove
  14353. * @returns the current particle system
  14354. */
  14355. removeStartSizeGradient(gradient: number): IParticleSystem;
  14356. /**
  14357. * Gets the current list of start size gradients.
  14358. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14359. * @returns the list of start size gradients
  14360. */
  14361. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14362. /**
  14363. * Adds a new life time gradient
  14364. * @param gradient defines the gradient to use (between 0 and 1)
  14365. * @param factor defines the life time factor to affect to the specified gradient
  14366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14367. * @returns the current particle system
  14368. */
  14369. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14370. /**
  14371. * Remove a specific life time gradient
  14372. * @param gradient defines the gradient to remove
  14373. * @returns the current particle system
  14374. */
  14375. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14376. /**
  14377. * Gets the current list of life time gradients.
  14378. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14379. * @returns the list of life time gradients
  14380. */
  14381. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14382. /**
  14383. * Gets the current list of color gradients.
  14384. * You must use addColorGradient and removeColorGradient to udpate this list
  14385. * @returns the list of color gradients
  14386. */
  14387. getColorGradients(): Nullable<Array<ColorGradient>>;
  14388. /**
  14389. * Adds a new ramp gradient used to remap particle colors
  14390. * @param gradient defines the gradient to use (between 0 and 1)
  14391. * @param color defines the color to affect to the specified gradient
  14392. * @returns the current particle system
  14393. */
  14394. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14395. /**
  14396. * Gets the current list of ramp gradients.
  14397. * You must use addRampGradient and removeRampGradient to udpate this list
  14398. * @returns the list of ramp gradients
  14399. */
  14400. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14401. /** Gets or sets a boolean indicating that ramp gradients must be used
  14402. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14403. */
  14404. useRampGradients: boolean;
  14405. /**
  14406. * Adds a new color remap gradient
  14407. * @param gradient defines the gradient to use (between 0 and 1)
  14408. * @param min defines the color remap minimal range
  14409. * @param max defines the color remap maximal range
  14410. * @returns the current particle system
  14411. */
  14412. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14413. /**
  14414. * Gets the current list of color remap gradients.
  14415. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14416. * @returns the list of color remap gradients
  14417. */
  14418. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14419. /**
  14420. * Adds a new alpha remap gradient
  14421. * @param gradient defines the gradient to use (between 0 and 1)
  14422. * @param min defines the alpha remap minimal range
  14423. * @param max defines the alpha remap maximal range
  14424. * @returns the current particle system
  14425. */
  14426. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14427. /**
  14428. * Gets the current list of alpha remap gradients.
  14429. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14430. * @returns the list of alpha remap gradients
  14431. */
  14432. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14433. /**
  14434. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14435. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14436. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14437. * @returns the emitter
  14438. */
  14439. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14440. /**
  14441. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14442. * @param radius The radius of the hemisphere to emit from
  14443. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14444. * @returns the emitter
  14445. */
  14446. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14447. /**
  14448. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14449. * @param radius The radius of the sphere to emit from
  14450. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14451. * @returns the emitter
  14452. */
  14453. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14454. /**
  14455. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14456. * @param radius The radius of the sphere to emit from
  14457. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14458. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14459. * @returns the emitter
  14460. */
  14461. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14462. /**
  14463. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14464. * @param radius The radius of the emission cylinder
  14465. * @param height The height of the emission cylinder
  14466. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14467. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14468. * @returns the emitter
  14469. */
  14470. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14471. /**
  14472. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14473. * @param radius The radius of the cylinder to emit from
  14474. * @param height The height of the emission cylinder
  14475. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14476. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14477. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14478. * @returns the emitter
  14479. */
  14480. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14481. /**
  14482. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14483. * @param radius The radius of the cone to emit from
  14484. * @param angle The base angle of the cone
  14485. * @returns the emitter
  14486. */
  14487. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14488. /**
  14489. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14490. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14491. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14492. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14493. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14494. * @returns the emitter
  14495. */
  14496. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14497. /**
  14498. * Get hosting scene
  14499. * @returns the scene
  14500. */
  14501. getScene(): Scene;
  14502. }
  14503. }
  14504. declare module BABYLON {
  14505. /**
  14506. * 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.
  14507. * @see https://doc.babylonjs.com/how_to/transformnode
  14508. */
  14509. export class TransformNode extends Node {
  14510. /**
  14511. * Object will not rotate to face the camera
  14512. */
  14513. static BILLBOARDMODE_NONE: number;
  14514. /**
  14515. * Object will rotate to face the camera but only on the x axis
  14516. */
  14517. static BILLBOARDMODE_X: number;
  14518. /**
  14519. * Object will rotate to face the camera but only on the y axis
  14520. */
  14521. static BILLBOARDMODE_Y: number;
  14522. /**
  14523. * Object will rotate to face the camera but only on the z axis
  14524. */
  14525. static BILLBOARDMODE_Z: number;
  14526. /**
  14527. * Object will rotate to face the camera
  14528. */
  14529. static BILLBOARDMODE_ALL: number;
  14530. /**
  14531. * Object will rotate to face the camera's position instead of orientation
  14532. */
  14533. static BILLBOARDMODE_USE_POSITION: number;
  14534. private _forward;
  14535. private _forwardInverted;
  14536. private _up;
  14537. private _right;
  14538. private _rightInverted;
  14539. private _position;
  14540. private _rotation;
  14541. private _rotationQuaternion;
  14542. protected _scaling: Vector3;
  14543. protected _isDirty: boolean;
  14544. private _transformToBoneReferal;
  14545. private _isAbsoluteSynced;
  14546. private _billboardMode;
  14547. /**
  14548. * Gets or sets the billboard mode. Default is 0.
  14549. *
  14550. * | Value | Type | Description |
  14551. * | --- | --- | --- |
  14552. * | 0 | BILLBOARDMODE_NONE | |
  14553. * | 1 | BILLBOARDMODE_X | |
  14554. * | 2 | BILLBOARDMODE_Y | |
  14555. * | 4 | BILLBOARDMODE_Z | |
  14556. * | 7 | BILLBOARDMODE_ALL | |
  14557. *
  14558. */
  14559. get billboardMode(): number;
  14560. set billboardMode(value: number);
  14561. private _preserveParentRotationForBillboard;
  14562. /**
  14563. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14564. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14565. */
  14566. get preserveParentRotationForBillboard(): boolean;
  14567. set preserveParentRotationForBillboard(value: boolean);
  14568. /**
  14569. * 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
  14570. */
  14571. scalingDeterminant: number;
  14572. private _infiniteDistance;
  14573. /**
  14574. * Gets or sets the distance of the object to max, often used by skybox
  14575. */
  14576. get infiniteDistance(): boolean;
  14577. set infiniteDistance(value: boolean);
  14578. /**
  14579. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14580. * By default the system will update normals to compensate
  14581. */
  14582. ignoreNonUniformScaling: boolean;
  14583. /**
  14584. * 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
  14585. */
  14586. reIntegrateRotationIntoRotationQuaternion: boolean;
  14587. /** @hidden */
  14588. _poseMatrix: Nullable<Matrix>;
  14589. /** @hidden */
  14590. _localMatrix: Matrix;
  14591. private _usePivotMatrix;
  14592. private _absolutePosition;
  14593. private _absoluteScaling;
  14594. private _absoluteRotationQuaternion;
  14595. private _pivotMatrix;
  14596. private _pivotMatrixInverse;
  14597. protected _postMultiplyPivotMatrix: boolean;
  14598. protected _isWorldMatrixFrozen: boolean;
  14599. /** @hidden */
  14600. _indexInSceneTransformNodesArray: number;
  14601. /**
  14602. * An event triggered after the world matrix is updated
  14603. */
  14604. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14605. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14606. /**
  14607. * Gets a string identifying the name of the class
  14608. * @returns "TransformNode" string
  14609. */
  14610. getClassName(): string;
  14611. /**
  14612. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14613. */
  14614. get position(): Vector3;
  14615. set position(newPosition: Vector3);
  14616. /**
  14617. * 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)).
  14618. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14619. */
  14620. get rotation(): Vector3;
  14621. set rotation(newRotation: Vector3);
  14622. /**
  14623. * 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)).
  14624. */
  14625. get scaling(): Vector3;
  14626. set scaling(newScaling: Vector3);
  14627. /**
  14628. * 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).
  14629. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14630. */
  14631. get rotationQuaternion(): Nullable<Quaternion>;
  14632. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14633. /**
  14634. * The forward direction of that transform in world space.
  14635. */
  14636. get forward(): Vector3;
  14637. /**
  14638. * The up direction of that transform in world space.
  14639. */
  14640. get up(): Vector3;
  14641. /**
  14642. * The right direction of that transform in world space.
  14643. */
  14644. get right(): Vector3;
  14645. /**
  14646. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14647. * @param matrix the matrix to copy the pose from
  14648. * @returns this TransformNode.
  14649. */
  14650. updatePoseMatrix(matrix: Matrix): TransformNode;
  14651. /**
  14652. * Returns the mesh Pose matrix.
  14653. * @returns the pose matrix
  14654. */
  14655. getPoseMatrix(): Matrix;
  14656. /** @hidden */
  14657. _isSynchronized(): boolean;
  14658. /** @hidden */
  14659. _initCache(): void;
  14660. /**
  14661. * Flag the transform node as dirty (Forcing it to update everything)
  14662. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14663. * @returns this transform node
  14664. */
  14665. markAsDirty(property: string): TransformNode;
  14666. /**
  14667. * Returns the current mesh absolute position.
  14668. * Returns a Vector3.
  14669. */
  14670. get absolutePosition(): Vector3;
  14671. /**
  14672. * Returns the current mesh absolute scaling.
  14673. * Returns a Vector3.
  14674. */
  14675. get absoluteScaling(): Vector3;
  14676. /**
  14677. * Returns the current mesh absolute rotation.
  14678. * Returns a Quaternion.
  14679. */
  14680. get absoluteRotationQuaternion(): Quaternion;
  14681. /**
  14682. * Sets a new matrix to apply before all other transformation
  14683. * @param matrix defines the transform matrix
  14684. * @returns the current TransformNode
  14685. */
  14686. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14687. /**
  14688. * Sets a new pivot matrix to the current node
  14689. * @param matrix defines the new pivot matrix to use
  14690. * @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
  14691. * @returns the current TransformNode
  14692. */
  14693. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14694. /**
  14695. * Returns the mesh pivot matrix.
  14696. * Default : Identity.
  14697. * @returns the matrix
  14698. */
  14699. getPivotMatrix(): Matrix;
  14700. /**
  14701. * Instantiate (when possible) or clone that node with its hierarchy
  14702. * @param newParent defines the new parent to use for the instance (or clone)
  14703. * @param options defines options to configure how copy is done
  14704. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14705. * @returns an instance (or a clone) of the current node with its hiearchy
  14706. */
  14707. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14708. doNotInstantiate: boolean;
  14709. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14710. /**
  14711. * Prevents the World matrix to be computed any longer
  14712. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14713. * @returns the TransformNode.
  14714. */
  14715. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14716. /**
  14717. * Allows back the World matrix computation.
  14718. * @returns the TransformNode.
  14719. */
  14720. unfreezeWorldMatrix(): this;
  14721. /**
  14722. * True if the World matrix has been frozen.
  14723. */
  14724. get isWorldMatrixFrozen(): boolean;
  14725. /**
  14726. * Retuns the mesh absolute position in the World.
  14727. * @returns a Vector3.
  14728. */
  14729. getAbsolutePosition(): Vector3;
  14730. /**
  14731. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14732. * @param absolutePosition the absolute position to set
  14733. * @returns the TransformNode.
  14734. */
  14735. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14736. /**
  14737. * Sets the mesh position in its local space.
  14738. * @param vector3 the position to set in localspace
  14739. * @returns the TransformNode.
  14740. */
  14741. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14742. /**
  14743. * Returns the mesh position in the local space from the current World matrix values.
  14744. * @returns a new Vector3.
  14745. */
  14746. getPositionExpressedInLocalSpace(): Vector3;
  14747. /**
  14748. * Translates the mesh along the passed Vector3 in its local space.
  14749. * @param vector3 the distance to translate in localspace
  14750. * @returns the TransformNode.
  14751. */
  14752. locallyTranslate(vector3: Vector3): TransformNode;
  14753. private static _lookAtVectorCache;
  14754. /**
  14755. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14756. * @param targetPoint the position (must be in same space as current mesh) to look at
  14757. * @param yawCor optional yaw (y-axis) correction in radians
  14758. * @param pitchCor optional pitch (x-axis) correction in radians
  14759. * @param rollCor optional roll (z-axis) correction in radians
  14760. * @param space the choosen space of the target
  14761. * @returns the TransformNode.
  14762. */
  14763. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14764. /**
  14765. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14766. * This Vector3 is expressed in the World space.
  14767. * @param localAxis axis to rotate
  14768. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14769. */
  14770. getDirection(localAxis: Vector3): Vector3;
  14771. /**
  14772. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14773. * localAxis is expressed in the mesh local space.
  14774. * result is computed in the Wordl space from the mesh World matrix.
  14775. * @param localAxis axis to rotate
  14776. * @param result the resulting transformnode
  14777. * @returns this TransformNode.
  14778. */
  14779. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14780. /**
  14781. * Sets this transform node rotation to the given local axis.
  14782. * @param localAxis the axis in local space
  14783. * @param yawCor optional yaw (y-axis) correction in radians
  14784. * @param pitchCor optional pitch (x-axis) correction in radians
  14785. * @param rollCor optional roll (z-axis) correction in radians
  14786. * @returns this TransformNode
  14787. */
  14788. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14789. /**
  14790. * Sets a new pivot point to the current node
  14791. * @param point defines the new pivot point to use
  14792. * @param space defines if the point is in world or local space (local by default)
  14793. * @returns the current TransformNode
  14794. */
  14795. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14796. /**
  14797. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14798. * @returns the pivot point
  14799. */
  14800. getPivotPoint(): Vector3;
  14801. /**
  14802. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14803. * @param result the vector3 to store the result
  14804. * @returns this TransformNode.
  14805. */
  14806. getPivotPointToRef(result: Vector3): TransformNode;
  14807. /**
  14808. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14809. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14810. */
  14811. getAbsolutePivotPoint(): Vector3;
  14812. /**
  14813. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14814. * @param result vector3 to store the result
  14815. * @returns this TransformNode.
  14816. */
  14817. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14818. /**
  14819. * Defines the passed node as the parent of the current node.
  14820. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14821. * @see https://doc.babylonjs.com/how_to/parenting
  14822. * @param node the node ot set as the parent
  14823. * @returns this TransformNode.
  14824. */
  14825. setParent(node: Nullable<Node>): TransformNode;
  14826. private _nonUniformScaling;
  14827. /**
  14828. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14829. */
  14830. get nonUniformScaling(): boolean;
  14831. /** @hidden */
  14832. _updateNonUniformScalingState(value: boolean): boolean;
  14833. /**
  14834. * Attach the current TransformNode to another TransformNode associated with a bone
  14835. * @param bone Bone affecting the TransformNode
  14836. * @param affectedTransformNode TransformNode associated with the bone
  14837. * @returns this object
  14838. */
  14839. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14840. /**
  14841. * Detach the transform node if its associated with a bone
  14842. * @returns this object
  14843. */
  14844. detachFromBone(): TransformNode;
  14845. private static _rotationAxisCache;
  14846. /**
  14847. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14848. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14849. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14850. * The passed axis is also normalized.
  14851. * @param axis the axis to rotate around
  14852. * @param amount the amount to rotate in radians
  14853. * @param space Space to rotate in (Default: local)
  14854. * @returns the TransformNode.
  14855. */
  14856. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14857. /**
  14858. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14859. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14860. * The passed axis is also normalized. .
  14861. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14862. * @param point the point to rotate around
  14863. * @param axis the axis to rotate around
  14864. * @param amount the amount to rotate in radians
  14865. * @returns the TransformNode
  14866. */
  14867. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14868. /**
  14869. * Translates the mesh along the axis vector for the passed distance in the given space.
  14870. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14871. * @param axis the axis to translate in
  14872. * @param distance the distance to translate
  14873. * @param space Space to rotate in (Default: local)
  14874. * @returns the TransformNode.
  14875. */
  14876. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14877. /**
  14878. * Adds a rotation step to the mesh current rotation.
  14879. * x, y, z are Euler angles expressed in radians.
  14880. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14881. * This means this rotation is made in the mesh local space only.
  14882. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14883. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14884. * ```javascript
  14885. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14886. * ```
  14887. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14888. * 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.
  14889. * @param x Rotation to add
  14890. * @param y Rotation to add
  14891. * @param z Rotation to add
  14892. * @returns the TransformNode.
  14893. */
  14894. addRotation(x: number, y: number, z: number): TransformNode;
  14895. /**
  14896. * @hidden
  14897. */
  14898. protected _getEffectiveParent(): Nullable<Node>;
  14899. /**
  14900. * Computes the world matrix of the node
  14901. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14902. * @returns the world matrix
  14903. */
  14904. computeWorldMatrix(force?: boolean): Matrix;
  14905. /**
  14906. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14907. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14908. */
  14909. resetLocalMatrix(independentOfChildren?: boolean): void;
  14910. protected _afterComputeWorldMatrix(): void;
  14911. /**
  14912. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14913. * @param func callback function to add
  14914. *
  14915. * @returns the TransformNode.
  14916. */
  14917. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14918. /**
  14919. * Removes a registered callback function.
  14920. * @param func callback function to remove
  14921. * @returns the TransformNode.
  14922. */
  14923. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14924. /**
  14925. * Gets the position of the current mesh in camera space
  14926. * @param camera defines the camera to use
  14927. * @returns a position
  14928. */
  14929. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14930. /**
  14931. * Returns the distance from the mesh to the active camera
  14932. * @param camera defines the camera to use
  14933. * @returns the distance
  14934. */
  14935. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14936. /**
  14937. * Clone the current transform node
  14938. * @param name Name of the new clone
  14939. * @param newParent New parent for the clone
  14940. * @param doNotCloneChildren Do not clone children hierarchy
  14941. * @returns the new transform node
  14942. */
  14943. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14944. /**
  14945. * Serializes the objects information.
  14946. * @param currentSerializationObject defines the object to serialize in
  14947. * @returns the serialized object
  14948. */
  14949. serialize(currentSerializationObject?: any): any;
  14950. /**
  14951. * Returns a new TransformNode object parsed from the source provided.
  14952. * @param parsedTransformNode is the source.
  14953. * @param scene the scne the object belongs to
  14954. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14955. * @returns a new TransformNode object parsed from the source provided.
  14956. */
  14957. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14958. /**
  14959. * Get all child-transformNodes of this node
  14960. * @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
  14961. * @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
  14962. * @returns an array of TransformNode
  14963. */
  14964. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14965. /**
  14966. * Releases resources associated with this transform node.
  14967. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14968. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14969. */
  14970. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14971. /**
  14972. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14973. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14974. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14975. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14976. * @returns the current mesh
  14977. */
  14978. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14979. private _syncAbsoluteScalingAndRotation;
  14980. }
  14981. }
  14982. declare module BABYLON {
  14983. /**
  14984. * Class used to override all child animations of a given target
  14985. */
  14986. export class AnimationPropertiesOverride {
  14987. /**
  14988. * Gets or sets a value indicating if animation blending must be used
  14989. */
  14990. enableBlending: boolean;
  14991. /**
  14992. * Gets or sets the blending speed to use when enableBlending is true
  14993. */
  14994. blendingSpeed: number;
  14995. /**
  14996. * Gets or sets the default loop mode to use
  14997. */
  14998. loopMode: number;
  14999. }
  15000. }
  15001. declare module BABYLON {
  15002. /**
  15003. * Class used to store bone information
  15004. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15005. */
  15006. export class Bone extends Node {
  15007. /**
  15008. * defines the bone name
  15009. */
  15010. name: string;
  15011. private static _tmpVecs;
  15012. private static _tmpQuat;
  15013. private static _tmpMats;
  15014. /**
  15015. * Gets the list of child bones
  15016. */
  15017. children: Bone[];
  15018. /** Gets the animations associated with this bone */
  15019. animations: Animation[];
  15020. /**
  15021. * Gets or sets bone length
  15022. */
  15023. length: number;
  15024. /**
  15025. * @hidden Internal only
  15026. * Set this value to map this bone to a different index in the transform matrices
  15027. * Set this value to -1 to exclude the bone from the transform matrices
  15028. */
  15029. _index: Nullable<number>;
  15030. private _skeleton;
  15031. private _localMatrix;
  15032. private _restPose;
  15033. private _baseMatrix;
  15034. private _absoluteTransform;
  15035. private _invertedAbsoluteTransform;
  15036. private _parent;
  15037. private _scalingDeterminant;
  15038. private _worldTransform;
  15039. private _localScaling;
  15040. private _localRotation;
  15041. private _localPosition;
  15042. private _needToDecompose;
  15043. private _needToCompose;
  15044. /** @hidden */
  15045. _linkedTransformNode: Nullable<TransformNode>;
  15046. /** @hidden */
  15047. _waitingTransformNodeId: Nullable<string>;
  15048. /** @hidden */
  15049. get _matrix(): Matrix;
  15050. /** @hidden */
  15051. set _matrix(value: Matrix);
  15052. /**
  15053. * Create a new bone
  15054. * @param name defines the bone name
  15055. * @param skeleton defines the parent skeleton
  15056. * @param parentBone defines the parent (can be null if the bone is the root)
  15057. * @param localMatrix defines the local matrix
  15058. * @param restPose defines the rest pose matrix
  15059. * @param baseMatrix defines the base matrix
  15060. * @param index defines index of the bone in the hiearchy
  15061. */
  15062. constructor(
  15063. /**
  15064. * defines the bone name
  15065. */
  15066. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15067. /**
  15068. * Gets the current object class name.
  15069. * @return the class name
  15070. */
  15071. getClassName(): string;
  15072. /**
  15073. * Gets the parent skeleton
  15074. * @returns a skeleton
  15075. */
  15076. getSkeleton(): Skeleton;
  15077. /**
  15078. * Gets parent bone
  15079. * @returns a bone or null if the bone is the root of the bone hierarchy
  15080. */
  15081. getParent(): Nullable<Bone>;
  15082. /**
  15083. * Returns an array containing the root bones
  15084. * @returns an array containing the root bones
  15085. */
  15086. getChildren(): Array<Bone>;
  15087. /**
  15088. * Gets the node index in matrix array generated for rendering
  15089. * @returns the node index
  15090. */
  15091. getIndex(): number;
  15092. /**
  15093. * Sets the parent bone
  15094. * @param parent defines the parent (can be null if the bone is the root)
  15095. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15096. */
  15097. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15098. /**
  15099. * Gets the local matrix
  15100. * @returns a matrix
  15101. */
  15102. getLocalMatrix(): Matrix;
  15103. /**
  15104. * Gets the base matrix (initial matrix which remains unchanged)
  15105. * @returns a matrix
  15106. */
  15107. getBaseMatrix(): Matrix;
  15108. /**
  15109. * Gets the rest pose matrix
  15110. * @returns a matrix
  15111. */
  15112. getRestPose(): Matrix;
  15113. /**
  15114. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15115. */
  15116. getWorldMatrix(): Matrix;
  15117. /**
  15118. * Sets the local matrix to rest pose matrix
  15119. */
  15120. returnToRest(): void;
  15121. /**
  15122. * Gets the inverse of the absolute transform matrix.
  15123. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15124. * @returns a matrix
  15125. */
  15126. getInvertedAbsoluteTransform(): Matrix;
  15127. /**
  15128. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15129. * @returns a matrix
  15130. */
  15131. getAbsoluteTransform(): Matrix;
  15132. /**
  15133. * Links with the given transform node.
  15134. * The local matrix of this bone is copied from the transform node every frame.
  15135. * @param transformNode defines the transform node to link to
  15136. */
  15137. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15138. /**
  15139. * Gets the node used to drive the bone's transformation
  15140. * @returns a transform node or null
  15141. */
  15142. getTransformNode(): Nullable<TransformNode>;
  15143. /** Gets or sets current position (in local space) */
  15144. get position(): Vector3;
  15145. set position(newPosition: Vector3);
  15146. /** Gets or sets current rotation (in local space) */
  15147. get rotation(): Vector3;
  15148. set rotation(newRotation: Vector3);
  15149. /** Gets or sets current rotation quaternion (in local space) */
  15150. get rotationQuaternion(): Quaternion;
  15151. set rotationQuaternion(newRotation: Quaternion);
  15152. /** Gets or sets current scaling (in local space) */
  15153. get scaling(): Vector3;
  15154. set scaling(newScaling: Vector3);
  15155. /**
  15156. * Gets the animation properties override
  15157. */
  15158. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15159. private _decompose;
  15160. private _compose;
  15161. /**
  15162. * Update the base and local matrices
  15163. * @param matrix defines the new base or local matrix
  15164. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15165. * @param updateLocalMatrix defines if the local matrix should be updated
  15166. */
  15167. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15168. /** @hidden */
  15169. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15170. /**
  15171. * Flag the bone as dirty (Forcing it to update everything)
  15172. */
  15173. markAsDirty(): void;
  15174. /** @hidden */
  15175. _markAsDirtyAndCompose(): void;
  15176. private _markAsDirtyAndDecompose;
  15177. /**
  15178. * Translate the bone in local or world space
  15179. * @param vec The amount to translate the bone
  15180. * @param space The space that the translation is in
  15181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15182. */
  15183. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15184. /**
  15185. * Set the postion of the bone in local or world space
  15186. * @param position The position to set the bone
  15187. * @param space The space that the position is in
  15188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15189. */
  15190. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15191. /**
  15192. * Set the absolute position of the bone (world space)
  15193. * @param position The position to set the bone
  15194. * @param mesh The mesh that this bone is attached to
  15195. */
  15196. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15197. /**
  15198. * Scale the bone on the x, y and z axes (in local space)
  15199. * @param x The amount to scale the bone on the x axis
  15200. * @param y The amount to scale the bone on the y axis
  15201. * @param z The amount to scale the bone on the z axis
  15202. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15203. */
  15204. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15205. /**
  15206. * Set the bone scaling in local space
  15207. * @param scale defines the scaling vector
  15208. */
  15209. setScale(scale: Vector3): void;
  15210. /**
  15211. * Gets the current scaling in local space
  15212. * @returns the current scaling vector
  15213. */
  15214. getScale(): Vector3;
  15215. /**
  15216. * Gets the current scaling in local space and stores it in a target vector
  15217. * @param result defines the target vector
  15218. */
  15219. getScaleToRef(result: Vector3): void;
  15220. /**
  15221. * Set the yaw, pitch, and roll of the bone in local or world space
  15222. * @param yaw The rotation of the bone on the y axis
  15223. * @param pitch The rotation of the bone on the x axis
  15224. * @param roll The rotation of the bone on the z axis
  15225. * @param space The space that the axes of rotation are in
  15226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15227. */
  15228. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15229. /**
  15230. * Add a rotation to the bone on an axis in local or world space
  15231. * @param axis The axis to rotate the bone on
  15232. * @param amount The amount to rotate the bone
  15233. * @param space The space that the axis is in
  15234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15235. */
  15236. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15237. /**
  15238. * Set the rotation of the bone to a particular axis angle in local or world space
  15239. * @param axis The axis to rotate the bone on
  15240. * @param angle The angle that the bone should be rotated to
  15241. * @param space The space that the axis is in
  15242. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15243. */
  15244. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15245. /**
  15246. * Set the euler rotation of the bone in local of world space
  15247. * @param rotation The euler rotation that the bone should be set to
  15248. * @param space The space that the rotation is in
  15249. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15250. */
  15251. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15252. /**
  15253. * Set the quaternion rotation of the bone in local of world space
  15254. * @param quat The quaternion rotation that the bone should be set to
  15255. * @param space The space that the rotation is in
  15256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15257. */
  15258. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15259. /**
  15260. * Set the rotation matrix of the bone in local of world space
  15261. * @param rotMat The rotation matrix that the bone should be set to
  15262. * @param space The space that the rotation is in
  15263. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15264. */
  15265. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15266. private _rotateWithMatrix;
  15267. private _getNegativeRotationToRef;
  15268. /**
  15269. * Get the position of the bone in local or world space
  15270. * @param space The space that the returned position is in
  15271. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15272. * @returns The position of the bone
  15273. */
  15274. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15275. /**
  15276. * Copy the position of the bone to a vector3 in local or world space
  15277. * @param space The space that the returned position is in
  15278. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15279. * @param result The vector3 to copy the position to
  15280. */
  15281. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15282. /**
  15283. * Get the absolute position of the bone (world space)
  15284. * @param mesh The mesh that this bone is attached to
  15285. * @returns The absolute position of the bone
  15286. */
  15287. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15288. /**
  15289. * Copy the absolute position of the bone (world space) to the result param
  15290. * @param mesh The mesh that this bone is attached to
  15291. * @param result The vector3 to copy the absolute position to
  15292. */
  15293. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15294. /**
  15295. * Compute the absolute transforms of this bone and its children
  15296. */
  15297. computeAbsoluteTransforms(): void;
  15298. /**
  15299. * Get the world direction from an axis that is in the local space of the bone
  15300. * @param localAxis The local direction that is used to compute the world direction
  15301. * @param mesh The mesh that this bone is attached to
  15302. * @returns The world direction
  15303. */
  15304. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15305. /**
  15306. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15307. * @param localAxis The local direction that is used to compute the world direction
  15308. * @param mesh The mesh that this bone is attached to
  15309. * @param result The vector3 that the world direction will be copied to
  15310. */
  15311. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15312. /**
  15313. * Get the euler rotation of the bone in local or world space
  15314. * @param space The space that the rotation should be in
  15315. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15316. * @returns The euler rotation
  15317. */
  15318. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15319. /**
  15320. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15321. * @param space The space that the rotation should be in
  15322. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15323. * @param result The vector3 that the rotation should be copied to
  15324. */
  15325. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15326. /**
  15327. * Get the quaternion rotation of the bone in either local or world space
  15328. * @param space The space that the rotation should be in
  15329. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15330. * @returns The quaternion rotation
  15331. */
  15332. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15333. /**
  15334. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15335. * @param space The space that the rotation should be in
  15336. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15337. * @param result The quaternion that the rotation should be copied to
  15338. */
  15339. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15340. /**
  15341. * Get the rotation matrix of the bone in local or world space
  15342. * @param space The space that the rotation should be in
  15343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15344. * @returns The rotation matrix
  15345. */
  15346. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15347. /**
  15348. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15349. * @param space The space that the rotation should be in
  15350. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15351. * @param result The quaternion that the rotation should be copied to
  15352. */
  15353. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15354. /**
  15355. * Get the world position of a point that is in the local space of the bone
  15356. * @param position The local position
  15357. * @param mesh The mesh that this bone is attached to
  15358. * @returns The world position
  15359. */
  15360. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15361. /**
  15362. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15363. * @param position The local position
  15364. * @param mesh The mesh that this bone is attached to
  15365. * @param result The vector3 that the world position should be copied to
  15366. */
  15367. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15368. /**
  15369. * Get the local position of a point that is in world space
  15370. * @param position The world position
  15371. * @param mesh The mesh that this bone is attached to
  15372. * @returns The local position
  15373. */
  15374. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15375. /**
  15376. * Get the local position of a point that is in world space and copy it to the result param
  15377. * @param position The world position
  15378. * @param mesh The mesh that this bone is attached to
  15379. * @param result The vector3 that the local position should be copied to
  15380. */
  15381. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15382. }
  15383. }
  15384. declare module BABYLON {
  15385. /**
  15386. * Defines a runtime animation
  15387. */
  15388. export class RuntimeAnimation {
  15389. private _events;
  15390. /**
  15391. * The current frame of the runtime animation
  15392. */
  15393. private _currentFrame;
  15394. /**
  15395. * The animation used by the runtime animation
  15396. */
  15397. private _animation;
  15398. /**
  15399. * The target of the runtime animation
  15400. */
  15401. private _target;
  15402. /**
  15403. * The initiating animatable
  15404. */
  15405. private _host;
  15406. /**
  15407. * The original value of the runtime animation
  15408. */
  15409. private _originalValue;
  15410. /**
  15411. * The original blend value of the runtime animation
  15412. */
  15413. private _originalBlendValue;
  15414. /**
  15415. * The offsets cache of the runtime animation
  15416. */
  15417. private _offsetsCache;
  15418. /**
  15419. * The high limits cache of the runtime animation
  15420. */
  15421. private _highLimitsCache;
  15422. /**
  15423. * Specifies if the runtime animation has been stopped
  15424. */
  15425. private _stopped;
  15426. /**
  15427. * The blending factor of the runtime animation
  15428. */
  15429. private _blendingFactor;
  15430. /**
  15431. * The BabylonJS scene
  15432. */
  15433. private _scene;
  15434. /**
  15435. * The current value of the runtime animation
  15436. */
  15437. private _currentValue;
  15438. /** @hidden */
  15439. _animationState: _IAnimationState;
  15440. /**
  15441. * The active target of the runtime animation
  15442. */
  15443. private _activeTargets;
  15444. private _currentActiveTarget;
  15445. private _directTarget;
  15446. /**
  15447. * The target path of the runtime animation
  15448. */
  15449. private _targetPath;
  15450. /**
  15451. * The weight of the runtime animation
  15452. */
  15453. private _weight;
  15454. /**
  15455. * The ratio offset of the runtime animation
  15456. */
  15457. private _ratioOffset;
  15458. /**
  15459. * The previous delay of the runtime animation
  15460. */
  15461. private _previousDelay;
  15462. /**
  15463. * The previous ratio of the runtime animation
  15464. */
  15465. private _previousRatio;
  15466. private _enableBlending;
  15467. private _keys;
  15468. private _minFrame;
  15469. private _maxFrame;
  15470. private _minValue;
  15471. private _maxValue;
  15472. private _targetIsArray;
  15473. /**
  15474. * Gets the current frame of the runtime animation
  15475. */
  15476. get currentFrame(): number;
  15477. /**
  15478. * Gets the weight of the runtime animation
  15479. */
  15480. get weight(): number;
  15481. /**
  15482. * Gets the current value of the runtime animation
  15483. */
  15484. get currentValue(): any;
  15485. /**
  15486. * Gets the target path of the runtime animation
  15487. */
  15488. get targetPath(): string;
  15489. /**
  15490. * Gets the actual target of the runtime animation
  15491. */
  15492. get target(): any;
  15493. /**
  15494. * Gets the additive state of the runtime animation
  15495. */
  15496. get isAdditive(): boolean;
  15497. /** @hidden */
  15498. _onLoop: () => void;
  15499. /**
  15500. * Create a new RuntimeAnimation object
  15501. * @param target defines the target of the animation
  15502. * @param animation defines the source animation object
  15503. * @param scene defines the hosting scene
  15504. * @param host defines the initiating Animatable
  15505. */
  15506. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15507. private _preparePath;
  15508. /**
  15509. * Gets the animation from the runtime animation
  15510. */
  15511. get animation(): Animation;
  15512. /**
  15513. * Resets the runtime animation to the beginning
  15514. * @param restoreOriginal defines whether to restore the target property to the original value
  15515. */
  15516. reset(restoreOriginal?: boolean): void;
  15517. /**
  15518. * Specifies if the runtime animation is stopped
  15519. * @returns Boolean specifying if the runtime animation is stopped
  15520. */
  15521. isStopped(): boolean;
  15522. /**
  15523. * Disposes of the runtime animation
  15524. */
  15525. dispose(): void;
  15526. /**
  15527. * Apply the interpolated value to the target
  15528. * @param currentValue defines the value computed by the animation
  15529. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15530. */
  15531. setValue(currentValue: any, weight: number): void;
  15532. private _getOriginalValues;
  15533. private _setValue;
  15534. /**
  15535. * Gets the loop pmode of the runtime animation
  15536. * @returns Loop Mode
  15537. */
  15538. private _getCorrectLoopMode;
  15539. /**
  15540. * Move the current animation to a given frame
  15541. * @param frame defines the frame to move to
  15542. */
  15543. goToFrame(frame: number): void;
  15544. /**
  15545. * @hidden Internal use only
  15546. */
  15547. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15548. /**
  15549. * Execute the current animation
  15550. * @param delay defines the delay to add to the current frame
  15551. * @param from defines the lower bound of the animation range
  15552. * @param to defines the upper bound of the animation range
  15553. * @param loop defines if the current animation must loop
  15554. * @param speedRatio defines the current speed ratio
  15555. * @param weight defines the weight of the animation (default is -1 so no weight)
  15556. * @param onLoop optional callback called when animation loops
  15557. * @returns a boolean indicating if the animation is running
  15558. */
  15559. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15560. }
  15561. }
  15562. declare module BABYLON {
  15563. /**
  15564. * Class used to store an actual running animation
  15565. */
  15566. export class Animatable {
  15567. /** defines the target object */
  15568. target: any;
  15569. /** defines the starting frame number (default is 0) */
  15570. fromFrame: number;
  15571. /** defines the ending frame number (default is 100) */
  15572. toFrame: number;
  15573. /** defines if the animation must loop (default is false) */
  15574. loopAnimation: boolean;
  15575. /** defines a callback to call when animation ends if it is not looping */
  15576. onAnimationEnd?: (() => void) | null | undefined;
  15577. /** defines a callback to call when animation loops */
  15578. onAnimationLoop?: (() => void) | null | undefined;
  15579. /** defines whether the animation should be evaluated additively */
  15580. isAdditive: boolean;
  15581. private _localDelayOffset;
  15582. private _pausedDelay;
  15583. private _runtimeAnimations;
  15584. private _paused;
  15585. private _scene;
  15586. private _speedRatio;
  15587. private _weight;
  15588. private _syncRoot;
  15589. /**
  15590. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15591. * This will only apply for non looping animation (default is true)
  15592. */
  15593. disposeOnEnd: boolean;
  15594. /**
  15595. * Gets a boolean indicating if the animation has started
  15596. */
  15597. animationStarted: boolean;
  15598. /**
  15599. * Observer raised when the animation ends
  15600. */
  15601. onAnimationEndObservable: Observable<Animatable>;
  15602. /**
  15603. * Observer raised when the animation loops
  15604. */
  15605. onAnimationLoopObservable: Observable<Animatable>;
  15606. /**
  15607. * Gets the root Animatable used to synchronize and normalize animations
  15608. */
  15609. get syncRoot(): Nullable<Animatable>;
  15610. /**
  15611. * Gets the current frame of the first RuntimeAnimation
  15612. * Used to synchronize Animatables
  15613. */
  15614. get masterFrame(): number;
  15615. /**
  15616. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15617. */
  15618. get weight(): number;
  15619. set weight(value: number);
  15620. /**
  15621. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15622. */
  15623. get speedRatio(): number;
  15624. set speedRatio(value: number);
  15625. /**
  15626. * Creates a new Animatable
  15627. * @param scene defines the hosting scene
  15628. * @param target defines the target object
  15629. * @param fromFrame defines the starting frame number (default is 0)
  15630. * @param toFrame defines the ending frame number (default is 100)
  15631. * @param loopAnimation defines if the animation must loop (default is false)
  15632. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15633. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15634. * @param animations defines a group of animation to add to the new Animatable
  15635. * @param onAnimationLoop defines a callback to call when animation loops
  15636. * @param isAdditive defines whether the animation should be evaluated additively
  15637. */
  15638. constructor(scene: Scene,
  15639. /** defines the target object */
  15640. target: any,
  15641. /** defines the starting frame number (default is 0) */
  15642. fromFrame?: number,
  15643. /** defines the ending frame number (default is 100) */
  15644. toFrame?: number,
  15645. /** defines if the animation must loop (default is false) */
  15646. loopAnimation?: boolean, speedRatio?: number,
  15647. /** defines a callback to call when animation ends if it is not looping */
  15648. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15649. /** defines a callback to call when animation loops */
  15650. onAnimationLoop?: (() => void) | null | undefined,
  15651. /** defines whether the animation should be evaluated additively */
  15652. isAdditive?: boolean);
  15653. /**
  15654. * Synchronize and normalize current Animatable with a source Animatable
  15655. * This is useful when using animation weights and when animations are not of the same length
  15656. * @param root defines the root Animatable to synchronize with
  15657. * @returns the current Animatable
  15658. */
  15659. syncWith(root: Animatable): Animatable;
  15660. /**
  15661. * Gets the list of runtime animations
  15662. * @returns an array of RuntimeAnimation
  15663. */
  15664. getAnimations(): RuntimeAnimation[];
  15665. /**
  15666. * Adds more animations to the current animatable
  15667. * @param target defines the target of the animations
  15668. * @param animations defines the new animations to add
  15669. */
  15670. appendAnimations(target: any, animations: Animation[]): void;
  15671. /**
  15672. * Gets the source animation for a specific property
  15673. * @param property defines the propertyu to look for
  15674. * @returns null or the source animation for the given property
  15675. */
  15676. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15677. /**
  15678. * Gets the runtime animation for a specific property
  15679. * @param property defines the propertyu to look for
  15680. * @returns null or the runtime animation for the given property
  15681. */
  15682. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15683. /**
  15684. * Resets the animatable to its original state
  15685. */
  15686. reset(): void;
  15687. /**
  15688. * Allows the animatable to blend with current running animations
  15689. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15690. * @param blendingSpeed defines the blending speed to use
  15691. */
  15692. enableBlending(blendingSpeed: number): void;
  15693. /**
  15694. * Disable animation blending
  15695. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15696. */
  15697. disableBlending(): void;
  15698. /**
  15699. * Jump directly to a given frame
  15700. * @param frame defines the frame to jump to
  15701. */
  15702. goToFrame(frame: number): void;
  15703. /**
  15704. * Pause the animation
  15705. */
  15706. pause(): void;
  15707. /**
  15708. * Restart the animation
  15709. */
  15710. restart(): void;
  15711. private _raiseOnAnimationEnd;
  15712. /**
  15713. * Stop and delete the current animation
  15714. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15715. * @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)
  15716. */
  15717. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15718. /**
  15719. * Wait asynchronously for the animation to end
  15720. * @returns a promise which will be fullfilled when the animation ends
  15721. */
  15722. waitAsync(): Promise<Animatable>;
  15723. /** @hidden */
  15724. _animate(delay: number): boolean;
  15725. }
  15726. interface Scene {
  15727. /** @hidden */
  15728. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15729. /** @hidden */
  15730. _processLateAnimationBindingsForMatrices(holder: {
  15731. totalWeight: number;
  15732. totalAdditiveWeight: number;
  15733. animations: RuntimeAnimation[];
  15734. additiveAnimations: RuntimeAnimation[];
  15735. originalValue: Matrix;
  15736. }): any;
  15737. /** @hidden */
  15738. _processLateAnimationBindingsForQuaternions(holder: {
  15739. totalWeight: number;
  15740. totalAdditiveWeight: number;
  15741. animations: RuntimeAnimation[];
  15742. additiveAnimations: RuntimeAnimation[];
  15743. originalValue: Quaternion;
  15744. }, refQuaternion: Quaternion): Quaternion;
  15745. /** @hidden */
  15746. _processLateAnimationBindings(): void;
  15747. /**
  15748. * Will start the animation sequence of a given target
  15749. * @param target defines the target
  15750. * @param from defines from which frame should animation start
  15751. * @param to defines until which frame should animation run.
  15752. * @param weight defines the weight to apply to the animation (1.0 by default)
  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 targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15758. * @param onAnimationLoop defines the callback to call when an animation loops
  15759. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15760. * @returns the animatable object created for this animation
  15761. */
  15762. 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;
  15763. /**
  15764. * Will start the animation sequence of a given target
  15765. * @param target defines the target
  15766. * @param from defines from which frame should animation start
  15767. * @param to defines until which frame should animation run.
  15768. * @param loop defines if the animation loops
  15769. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15770. * @param onAnimationEnd defines the function to be executed when the animation ends
  15771. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15772. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15773. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15774. * @param onAnimationLoop defines the callback to call when an animation loops
  15775. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15776. * @returns the animatable object created for this animation
  15777. */
  15778. 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;
  15779. /**
  15780. * Will start the animation sequence of a given target and its hierarchy
  15781. * @param target defines the target
  15782. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15783. * @param from defines from which frame should animation start
  15784. * @param to defines until which frame should animation run.
  15785. * @param loop defines if the animation loops
  15786. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15787. * @param onAnimationEnd defines the function to be executed when the animation ends
  15788. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15789. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15790. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15791. * @param onAnimationLoop defines the callback to call when an animation loops
  15792. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15793. * @returns the list of created animatables
  15794. */
  15795. 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[];
  15796. /**
  15797. * Begin a new animation on a given node
  15798. * @param target defines the target where the animation will take place
  15799. * @param animations defines the list of animations to start
  15800. * @param from defines the initial value
  15801. * @param to defines the final value
  15802. * @param loop defines if you want animation to loop (off by default)
  15803. * @param speedRatio defines the speed ratio to apply to all animations
  15804. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15805. * @param onAnimationLoop defines the callback to call when an animation loops
  15806. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15807. * @returns the list of created animatables
  15808. */
  15809. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15810. /**
  15811. * Begin a new animation on a given node and its hierarchy
  15812. * @param target defines the root node where the animation will take place
  15813. * @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.
  15814. * @param animations defines the list of animations to start
  15815. * @param from defines the initial value
  15816. * @param to defines the final value
  15817. * @param loop defines if you want animation to loop (off by default)
  15818. * @param speedRatio defines the speed ratio to apply to all animations
  15819. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15820. * @param onAnimationLoop defines the callback to call when an animation loops
  15821. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15822. * @returns the list of animatables created for all nodes
  15823. */
  15824. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15825. /**
  15826. * Gets the animatable associated with a specific target
  15827. * @param target defines the target of the animatable
  15828. * @returns the required animatable if found
  15829. */
  15830. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15831. /**
  15832. * Gets all animatables associated with a given target
  15833. * @param target defines the target to look animatables for
  15834. * @returns an array of Animatables
  15835. */
  15836. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15837. /**
  15838. * Stops and removes all animations that have been applied to the scene
  15839. */
  15840. stopAllAnimations(): void;
  15841. /**
  15842. * Gets the current delta time used by animation engine
  15843. */
  15844. deltaTime: number;
  15845. }
  15846. interface Bone {
  15847. /**
  15848. * Copy an animation range from another bone
  15849. * @param source defines the source bone
  15850. * @param rangeName defines the range name to copy
  15851. * @param frameOffset defines the frame offset
  15852. * @param rescaleAsRequired defines if rescaling must be applied if required
  15853. * @param skelDimensionsRatio defines the scaling ratio
  15854. * @returns true if operation was successful
  15855. */
  15856. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15857. }
  15858. }
  15859. declare module BABYLON {
  15860. /**
  15861. * Class used to handle skinning animations
  15862. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15863. */
  15864. export class Skeleton implements IAnimatable {
  15865. /** defines the skeleton name */
  15866. name: string;
  15867. /** defines the skeleton Id */
  15868. id: string;
  15869. /**
  15870. * Defines the list of child bones
  15871. */
  15872. bones: Bone[];
  15873. /**
  15874. * Defines an estimate of the dimension of the skeleton at rest
  15875. */
  15876. dimensionsAtRest: Vector3;
  15877. /**
  15878. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15879. */
  15880. needInitialSkinMatrix: boolean;
  15881. /**
  15882. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15883. */
  15884. overrideMesh: Nullable<AbstractMesh>;
  15885. /**
  15886. * Gets the list of animations attached to this skeleton
  15887. */
  15888. animations: Array<Animation>;
  15889. private _scene;
  15890. private _isDirty;
  15891. private _transformMatrices;
  15892. private _transformMatrixTexture;
  15893. private _meshesWithPoseMatrix;
  15894. private _animatables;
  15895. private _identity;
  15896. private _synchronizedWithMesh;
  15897. private _ranges;
  15898. private _lastAbsoluteTransformsUpdateId;
  15899. private _canUseTextureForBones;
  15900. private _uniqueId;
  15901. /** @hidden */
  15902. _numBonesWithLinkedTransformNode: number;
  15903. /** @hidden */
  15904. _hasWaitingData: Nullable<boolean>;
  15905. /**
  15906. * Specifies if the skeleton should be serialized
  15907. */
  15908. doNotSerialize: boolean;
  15909. private _useTextureToStoreBoneMatrices;
  15910. /**
  15911. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15912. * Please note that this option is not available if the hardware does not support it
  15913. */
  15914. get useTextureToStoreBoneMatrices(): boolean;
  15915. set useTextureToStoreBoneMatrices(value: boolean);
  15916. private _animationPropertiesOverride;
  15917. /**
  15918. * Gets or sets the animation properties override
  15919. */
  15920. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15921. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15922. /**
  15923. * List of inspectable custom properties (used by the Inspector)
  15924. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15925. */
  15926. inspectableCustomProperties: IInspectable[];
  15927. /**
  15928. * An observable triggered before computing the skeleton's matrices
  15929. */
  15930. onBeforeComputeObservable: Observable<Skeleton>;
  15931. /**
  15932. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15933. */
  15934. get isUsingTextureForMatrices(): boolean;
  15935. /**
  15936. * Gets the unique ID of this skeleton
  15937. */
  15938. get uniqueId(): number;
  15939. /**
  15940. * Creates a new skeleton
  15941. * @param name defines the skeleton name
  15942. * @param id defines the skeleton Id
  15943. * @param scene defines the hosting scene
  15944. */
  15945. constructor(
  15946. /** defines the skeleton name */
  15947. name: string,
  15948. /** defines the skeleton Id */
  15949. id: string, scene: Scene);
  15950. /**
  15951. * Gets the current object class name.
  15952. * @return the class name
  15953. */
  15954. getClassName(): string;
  15955. /**
  15956. * Returns an array containing the root bones
  15957. * @returns an array containing the root bones
  15958. */
  15959. getChildren(): Array<Bone>;
  15960. /**
  15961. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15962. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15963. * @returns a Float32Array containing matrices data
  15964. */
  15965. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15966. /**
  15967. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15968. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15969. * @returns a raw texture containing the data
  15970. */
  15971. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15972. /**
  15973. * Gets the current hosting scene
  15974. * @returns a scene object
  15975. */
  15976. getScene(): Scene;
  15977. /**
  15978. * Gets a string representing the current skeleton data
  15979. * @param fullDetails defines a boolean indicating if we want a verbose version
  15980. * @returns a string representing the current skeleton data
  15981. */
  15982. toString(fullDetails?: boolean): string;
  15983. /**
  15984. * Get bone's index searching by name
  15985. * @param name defines bone's name to search for
  15986. * @return the indice of the bone. Returns -1 if not found
  15987. */
  15988. getBoneIndexByName(name: string): number;
  15989. /**
  15990. * Creater a new animation range
  15991. * @param name defines the name of the range
  15992. * @param from defines the start key
  15993. * @param to defines the end key
  15994. */
  15995. createAnimationRange(name: string, from: number, to: number): void;
  15996. /**
  15997. * Delete a specific animation range
  15998. * @param name defines the name of the range
  15999. * @param deleteFrames defines if frames must be removed as well
  16000. */
  16001. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16002. /**
  16003. * Gets a specific animation range
  16004. * @param name defines the name of the range to look for
  16005. * @returns the requested animation range or null if not found
  16006. */
  16007. getAnimationRange(name: string): Nullable<AnimationRange>;
  16008. /**
  16009. * Gets the list of all animation ranges defined on this skeleton
  16010. * @returns an array
  16011. */
  16012. getAnimationRanges(): Nullable<AnimationRange>[];
  16013. /**
  16014. * Copy animation range from a source skeleton.
  16015. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16016. * @param source defines the source skeleton
  16017. * @param name defines the name of the range to copy
  16018. * @param rescaleAsRequired defines if rescaling must be applied if required
  16019. * @returns true if operation was successful
  16020. */
  16021. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16022. /**
  16023. * Forces the skeleton to go to rest pose
  16024. */
  16025. returnToRest(): void;
  16026. private _getHighestAnimationFrame;
  16027. /**
  16028. * Begin a specific animation range
  16029. * @param name defines the name of the range to start
  16030. * @param loop defines if looping must be turned on (false by default)
  16031. * @param speedRatio defines the speed ratio to apply (1 by default)
  16032. * @param onAnimationEnd defines a callback which will be called when animation will end
  16033. * @returns a new animatable
  16034. */
  16035. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16036. /**
  16037. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16038. * @param skeleton defines the Skeleton containing the animation range to convert
  16039. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16040. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16041. * @returns the original skeleton
  16042. */
  16043. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16044. /** @hidden */
  16045. _markAsDirty(): void;
  16046. /** @hidden */
  16047. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16048. /** @hidden */
  16049. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16050. private _computeTransformMatrices;
  16051. /**
  16052. * Build all resources required to render a skeleton
  16053. */
  16054. prepare(): void;
  16055. /**
  16056. * Gets the list of animatables currently running for this skeleton
  16057. * @returns an array of animatables
  16058. */
  16059. getAnimatables(): IAnimatable[];
  16060. /**
  16061. * Clone the current skeleton
  16062. * @param name defines the name of the new skeleton
  16063. * @param id defines the id of the new skeleton
  16064. * @returns the new skeleton
  16065. */
  16066. clone(name: string, id?: string): Skeleton;
  16067. /**
  16068. * Enable animation blending for this skeleton
  16069. * @param blendingSpeed defines the blending speed to apply
  16070. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16071. */
  16072. enableBlending(blendingSpeed?: number): void;
  16073. /**
  16074. * Releases all resources associated with the current skeleton
  16075. */
  16076. dispose(): void;
  16077. /**
  16078. * Serialize the skeleton in a JSON object
  16079. * @returns a JSON object
  16080. */
  16081. serialize(): any;
  16082. /**
  16083. * Creates a new skeleton from serialized data
  16084. * @param parsedSkeleton defines the serialized data
  16085. * @param scene defines the hosting scene
  16086. * @returns a new skeleton
  16087. */
  16088. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16089. /**
  16090. * Compute all node absolute transforms
  16091. * @param forceUpdate defines if computation must be done even if cache is up to date
  16092. */
  16093. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16094. /**
  16095. * Gets the root pose matrix
  16096. * @returns a matrix
  16097. */
  16098. getPoseMatrix(): Nullable<Matrix>;
  16099. /**
  16100. * Sorts bones per internal index
  16101. */
  16102. sortBones(): void;
  16103. private _sortBones;
  16104. }
  16105. }
  16106. declare module BABYLON {
  16107. /**
  16108. * Creates an instance based on a source mesh.
  16109. */
  16110. export class InstancedMesh extends AbstractMesh {
  16111. private _sourceMesh;
  16112. private _currentLOD;
  16113. /** @hidden */
  16114. _indexInSourceMeshInstanceArray: number;
  16115. constructor(name: string, source: Mesh);
  16116. /**
  16117. * Returns the string "InstancedMesh".
  16118. */
  16119. getClassName(): string;
  16120. /** Gets the list of lights affecting that mesh */
  16121. get lightSources(): Light[];
  16122. _resyncLightSources(): void;
  16123. _resyncLightSource(light: Light): void;
  16124. _removeLightSource(light: Light, dispose: boolean): void;
  16125. /**
  16126. * If the source mesh receives shadows
  16127. */
  16128. get receiveShadows(): boolean;
  16129. /**
  16130. * The material of the source mesh
  16131. */
  16132. get material(): Nullable<Material>;
  16133. /**
  16134. * Visibility of the source mesh
  16135. */
  16136. get visibility(): number;
  16137. /**
  16138. * Skeleton of the source mesh
  16139. */
  16140. get skeleton(): Nullable<Skeleton>;
  16141. /**
  16142. * Rendering ground id of the source mesh
  16143. */
  16144. get renderingGroupId(): number;
  16145. set renderingGroupId(value: number);
  16146. /**
  16147. * Returns the total number of vertices (integer).
  16148. */
  16149. getTotalVertices(): number;
  16150. /**
  16151. * Returns a positive integer : the total number of indices in this mesh geometry.
  16152. * @returns the numner of indices or zero if the mesh has no geometry.
  16153. */
  16154. getTotalIndices(): number;
  16155. /**
  16156. * The source mesh of the instance
  16157. */
  16158. get sourceMesh(): Mesh;
  16159. /**
  16160. * Creates a new InstancedMesh object from the mesh model.
  16161. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16162. * @param name defines the name of the new instance
  16163. * @returns a new InstancedMesh
  16164. */
  16165. createInstance(name: string): InstancedMesh;
  16166. /**
  16167. * Is this node ready to be used/rendered
  16168. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16169. * @return {boolean} is it ready
  16170. */
  16171. isReady(completeCheck?: boolean): boolean;
  16172. /**
  16173. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16174. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16175. * @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.
  16176. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16177. */
  16178. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16179. /**
  16180. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16181. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16182. * The `data` are either a numeric array either a Float32Array.
  16183. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16184. * 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).
  16185. * Note that a new underlying VertexBuffer object is created each call.
  16186. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16187. *
  16188. * Possible `kind` values :
  16189. * - VertexBuffer.PositionKind
  16190. * - VertexBuffer.UVKind
  16191. * - VertexBuffer.UV2Kind
  16192. * - VertexBuffer.UV3Kind
  16193. * - VertexBuffer.UV4Kind
  16194. * - VertexBuffer.UV5Kind
  16195. * - VertexBuffer.UV6Kind
  16196. * - VertexBuffer.ColorKind
  16197. * - VertexBuffer.MatricesIndicesKind
  16198. * - VertexBuffer.MatricesIndicesExtraKind
  16199. * - VertexBuffer.MatricesWeightsKind
  16200. * - VertexBuffer.MatricesWeightsExtraKind
  16201. *
  16202. * Returns the Mesh.
  16203. */
  16204. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16205. /**
  16206. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16207. * If the mesh has no geometry, it is simply returned as it is.
  16208. * The `data` are either a numeric array either a Float32Array.
  16209. * No new underlying VertexBuffer object is created.
  16210. * 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.
  16211. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16212. *
  16213. * Possible `kind` values :
  16214. * - VertexBuffer.PositionKind
  16215. * - VertexBuffer.UVKind
  16216. * - VertexBuffer.UV2Kind
  16217. * - VertexBuffer.UV3Kind
  16218. * - VertexBuffer.UV4Kind
  16219. * - VertexBuffer.UV5Kind
  16220. * - VertexBuffer.UV6Kind
  16221. * - VertexBuffer.ColorKind
  16222. * - VertexBuffer.MatricesIndicesKind
  16223. * - VertexBuffer.MatricesIndicesExtraKind
  16224. * - VertexBuffer.MatricesWeightsKind
  16225. * - VertexBuffer.MatricesWeightsExtraKind
  16226. *
  16227. * Returns the Mesh.
  16228. */
  16229. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16230. /**
  16231. * Sets the mesh indices.
  16232. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16233. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16234. * This method creates a new index buffer each call.
  16235. * Returns the Mesh.
  16236. */
  16237. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16238. /**
  16239. * Boolean : True if the mesh owns the requested kind of data.
  16240. */
  16241. isVerticesDataPresent(kind: string): boolean;
  16242. /**
  16243. * Returns an array of indices (IndicesArray).
  16244. */
  16245. getIndices(): Nullable<IndicesArray>;
  16246. get _positions(): Nullable<Vector3[]>;
  16247. /**
  16248. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16249. * This means the mesh underlying bounding box and sphere are recomputed.
  16250. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16251. * @returns the current mesh
  16252. */
  16253. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16254. /** @hidden */
  16255. _preActivate(): InstancedMesh;
  16256. /** @hidden */
  16257. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16258. /** @hidden */
  16259. _postActivate(): void;
  16260. getWorldMatrix(): Matrix;
  16261. get isAnInstance(): boolean;
  16262. /**
  16263. * Returns the current associated LOD AbstractMesh.
  16264. */
  16265. getLOD(camera: Camera): AbstractMesh;
  16266. /** @hidden */
  16267. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16268. /** @hidden */
  16269. _syncSubMeshes(): InstancedMesh;
  16270. /** @hidden */
  16271. _generatePointsArray(): boolean;
  16272. /**
  16273. * Creates a new InstancedMesh from the current mesh.
  16274. * - name (string) : the cloned mesh name
  16275. * - newParent (optional Node) : the optional Node to parent the clone to.
  16276. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16277. *
  16278. * Returns the clone.
  16279. */
  16280. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16281. /**
  16282. * Disposes the InstancedMesh.
  16283. * Returns nothing.
  16284. */
  16285. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16286. }
  16287. interface Mesh {
  16288. /**
  16289. * Register a custom buffer that will be instanced
  16290. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16291. * @param kind defines the buffer kind
  16292. * @param stride defines the stride in floats
  16293. */
  16294. registerInstancedBuffer(kind: string, stride: number): void;
  16295. /** @hidden */
  16296. _userInstancedBuffersStorage: {
  16297. data: {
  16298. [key: string]: Float32Array;
  16299. };
  16300. sizes: {
  16301. [key: string]: number;
  16302. };
  16303. vertexBuffers: {
  16304. [key: string]: Nullable<VertexBuffer>;
  16305. };
  16306. strides: {
  16307. [key: string]: number;
  16308. };
  16309. };
  16310. }
  16311. interface AbstractMesh {
  16312. /**
  16313. * Object used to store instanced buffers defined by user
  16314. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16315. */
  16316. instancedBuffers: {
  16317. [key: string]: any;
  16318. };
  16319. }
  16320. }
  16321. declare module BABYLON {
  16322. /**
  16323. * Defines the options associated with the creation of a shader material.
  16324. */
  16325. export interface IShaderMaterialOptions {
  16326. /**
  16327. * Does the material work in alpha blend mode
  16328. */
  16329. needAlphaBlending: boolean;
  16330. /**
  16331. * Does the material work in alpha test mode
  16332. */
  16333. needAlphaTesting: boolean;
  16334. /**
  16335. * The list of attribute names used in the shader
  16336. */
  16337. attributes: string[];
  16338. /**
  16339. * The list of unifrom names used in the shader
  16340. */
  16341. uniforms: string[];
  16342. /**
  16343. * The list of UBO names used in the shader
  16344. */
  16345. uniformBuffers: string[];
  16346. /**
  16347. * The list of sampler names used in the shader
  16348. */
  16349. samplers: string[];
  16350. /**
  16351. * The list of defines used in the shader
  16352. */
  16353. defines: string[];
  16354. }
  16355. /**
  16356. * 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.
  16357. *
  16358. * This returned material effects how the mesh will look based on the code in the shaders.
  16359. *
  16360. * @see http://doc.babylonjs.com/how_to/shader_material
  16361. */
  16362. export class ShaderMaterial extends Material {
  16363. private _shaderPath;
  16364. private _options;
  16365. private _textures;
  16366. private _textureArrays;
  16367. private _floats;
  16368. private _ints;
  16369. private _floatsArrays;
  16370. private _colors3;
  16371. private _colors3Arrays;
  16372. private _colors4;
  16373. private _colors4Arrays;
  16374. private _vectors2;
  16375. private _vectors3;
  16376. private _vectors4;
  16377. private _matrices;
  16378. private _matrixArrays;
  16379. private _matrices3x3;
  16380. private _matrices2x2;
  16381. private _vectors2Arrays;
  16382. private _vectors3Arrays;
  16383. private _vectors4Arrays;
  16384. private _cachedWorldViewMatrix;
  16385. private _cachedWorldViewProjectionMatrix;
  16386. private _renderId;
  16387. private _multiview;
  16388. private _cachedDefines;
  16389. /**
  16390. * Instantiate a new shader material.
  16391. * 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.
  16392. * This returned material effects how the mesh will look based on the code in the shaders.
  16393. * @see http://doc.babylonjs.com/how_to/shader_material
  16394. * @param name Define the name of the material in the scene
  16395. * @param scene Define the scene the material belongs to
  16396. * @param shaderPath Defines the route to the shader code in one of three ways:
  16397. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16398. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16399. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16400. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16401. * @param options Define the options used to create the shader
  16402. */
  16403. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16404. /**
  16405. * Gets the shader path used to define the shader code
  16406. * It can be modified to trigger a new compilation
  16407. */
  16408. get shaderPath(): any;
  16409. /**
  16410. * Sets the shader path used to define the shader code
  16411. * It can be modified to trigger a new compilation
  16412. */
  16413. set shaderPath(shaderPath: any);
  16414. /**
  16415. * Gets the options used to compile the shader.
  16416. * They can be modified to trigger a new compilation
  16417. */
  16418. get options(): IShaderMaterialOptions;
  16419. /**
  16420. * Gets the current class name of the material e.g. "ShaderMaterial"
  16421. * Mainly use in serialization.
  16422. * @returns the class name
  16423. */
  16424. getClassName(): string;
  16425. /**
  16426. * Specifies if the material will require alpha blending
  16427. * @returns a boolean specifying if alpha blending is needed
  16428. */
  16429. needAlphaBlending(): boolean;
  16430. /**
  16431. * Specifies if this material should be rendered in alpha test mode
  16432. * @returns a boolean specifying if an alpha test is needed.
  16433. */
  16434. needAlphaTesting(): boolean;
  16435. private _checkUniform;
  16436. /**
  16437. * Set a texture in the shader.
  16438. * @param name Define the name of the uniform samplers as defined in the shader
  16439. * @param texture Define the texture to bind to this sampler
  16440. * @return the material itself allowing "fluent" like uniform updates
  16441. */
  16442. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16443. /**
  16444. * Set a texture array in the shader.
  16445. * @param name Define the name of the uniform sampler array as defined in the shader
  16446. * @param textures Define the list of textures to bind to this sampler
  16447. * @return the material itself allowing "fluent" like uniform updates
  16448. */
  16449. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16450. /**
  16451. * Set a float in the shader.
  16452. * @param name Define the name of the uniform as defined in the shader
  16453. * @param value Define the value to give to the uniform
  16454. * @return the material itself allowing "fluent" like uniform updates
  16455. */
  16456. setFloat(name: string, value: number): ShaderMaterial;
  16457. /**
  16458. * Set a int in the shader.
  16459. * @param name Define the name of the uniform as defined in the shader
  16460. * @param value Define the value to give to the uniform
  16461. * @return the material itself allowing "fluent" like uniform updates
  16462. */
  16463. setInt(name: string, value: number): ShaderMaterial;
  16464. /**
  16465. * Set an array of floats in the shader.
  16466. * @param name Define the name of the uniform as defined in the shader
  16467. * @param value Define the value to give to the uniform
  16468. * @return the material itself allowing "fluent" like uniform updates
  16469. */
  16470. setFloats(name: string, value: number[]): ShaderMaterial;
  16471. /**
  16472. * Set a vec3 in the shader from a Color3.
  16473. * @param name Define the name of the uniform as defined in the shader
  16474. * @param value Define the value to give to the uniform
  16475. * @return the material itself allowing "fluent" like uniform updates
  16476. */
  16477. setColor3(name: string, value: Color3): ShaderMaterial;
  16478. /**
  16479. * Set a vec3 array in the shader from a Color3 array.
  16480. * @param name Define the name of the uniform as defined in the shader
  16481. * @param value Define the value to give to the uniform
  16482. * @return the material itself allowing "fluent" like uniform updates
  16483. */
  16484. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16485. /**
  16486. * Set a vec4 in the shader from a Color4.
  16487. * @param name Define the name of the uniform as defined in the shader
  16488. * @param value Define the value to give to the uniform
  16489. * @return the material itself allowing "fluent" like uniform updates
  16490. */
  16491. setColor4(name: string, value: Color4): ShaderMaterial;
  16492. /**
  16493. * Set a vec4 array in the shader from a Color4 array.
  16494. * @param name Define the name of the uniform as defined in the shader
  16495. * @param value Define the value to give to the uniform
  16496. * @return the material itself allowing "fluent" like uniform updates
  16497. */
  16498. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16499. /**
  16500. * Set a vec2 in the shader from a Vector2.
  16501. * @param name Define the name of the uniform as defined in the shader
  16502. * @param value Define the value to give to the uniform
  16503. * @return the material itself allowing "fluent" like uniform updates
  16504. */
  16505. setVector2(name: string, value: Vector2): ShaderMaterial;
  16506. /**
  16507. * Set a vec3 in the shader from a Vector3.
  16508. * @param name Define the name of the uniform as defined in the shader
  16509. * @param value Define the value to give to the uniform
  16510. * @return the material itself allowing "fluent" like uniform updates
  16511. */
  16512. setVector3(name: string, value: Vector3): ShaderMaterial;
  16513. /**
  16514. * Set a vec4 in the shader from a Vector4.
  16515. * @param name Define the name of the uniform as defined in the shader
  16516. * @param value Define the value to give to the uniform
  16517. * @return the material itself allowing "fluent" like uniform updates
  16518. */
  16519. setVector4(name: string, value: Vector4): ShaderMaterial;
  16520. /**
  16521. * Set a mat4 in the shader from a Matrix.
  16522. * @param name Define the name of the uniform as defined in the shader
  16523. * @param value Define the value to give to the uniform
  16524. * @return the material itself allowing "fluent" like uniform updates
  16525. */
  16526. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16527. /**
  16528. * Set a float32Array in the shader from a matrix array.
  16529. * @param name Define the name of the uniform as defined in the shader
  16530. * @param value Define the value to give to the uniform
  16531. * @return the material itself allowing "fluent" like uniform updates
  16532. */
  16533. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16534. /**
  16535. * Set a mat3 in the shader from a Float32Array.
  16536. * @param name Define the name of the uniform as defined in the shader
  16537. * @param value Define the value to give to the uniform
  16538. * @return the material itself allowing "fluent" like uniform updates
  16539. */
  16540. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16541. /**
  16542. * Set a mat2 in the shader from a Float32Array.
  16543. * @param name Define the name of the uniform as defined in the shader
  16544. * @param value Define the value to give to the uniform
  16545. * @return the material itself allowing "fluent" like uniform updates
  16546. */
  16547. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16548. /**
  16549. * Set a vec2 array in the shader from a number array.
  16550. * @param name Define the name of the uniform as defined in the shader
  16551. * @param value Define the value to give to the uniform
  16552. * @return the material itself allowing "fluent" like uniform updates
  16553. */
  16554. setArray2(name: string, value: number[]): ShaderMaterial;
  16555. /**
  16556. * Set a vec3 array in the shader from a number array.
  16557. * @param name Define the name of the uniform as defined in the shader
  16558. * @param value Define the value to give to the uniform
  16559. * @return the material itself allowing "fluent" like uniform updates
  16560. */
  16561. setArray3(name: string, value: number[]): ShaderMaterial;
  16562. /**
  16563. * Set a vec4 array in the shader from a number array.
  16564. * @param name Define the name of the uniform as defined in the shader
  16565. * @param value Define the value to give to the uniform
  16566. * @return the material itself allowing "fluent" like uniform updates
  16567. */
  16568. setArray4(name: string, value: number[]): ShaderMaterial;
  16569. private _checkCache;
  16570. /**
  16571. * Specifies that the submesh is ready to be used
  16572. * @param mesh defines the mesh to check
  16573. * @param subMesh defines which submesh to check
  16574. * @param useInstances specifies that instances should be used
  16575. * @returns a boolean indicating that the submesh is ready or not
  16576. */
  16577. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16578. /**
  16579. * Checks if the material is ready to render the requested mesh
  16580. * @param mesh Define the mesh to render
  16581. * @param useInstances Define whether or not the material is used with instances
  16582. * @returns true if ready, otherwise false
  16583. */
  16584. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16585. /**
  16586. * Binds the world matrix to the material
  16587. * @param world defines the world transformation matrix
  16588. * @param effectOverride - If provided, use this effect instead of internal effect
  16589. */
  16590. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16591. /**
  16592. * Binds the submesh to this material by preparing the effect and shader to draw
  16593. * @param world defines the world transformation matrix
  16594. * @param mesh defines the mesh containing the submesh
  16595. * @param subMesh defines the submesh to bind the material to
  16596. */
  16597. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16598. /**
  16599. * Binds the material to the mesh
  16600. * @param world defines the world transformation matrix
  16601. * @param mesh defines the mesh to bind the material to
  16602. * @param effectOverride - If provided, use this effect instead of internal effect
  16603. */
  16604. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16605. protected _afterBind(mesh?: Mesh): void;
  16606. /**
  16607. * Gets the active textures from the material
  16608. * @returns an array of textures
  16609. */
  16610. getActiveTextures(): BaseTexture[];
  16611. /**
  16612. * Specifies if the material uses a texture
  16613. * @param texture defines the texture to check against the material
  16614. * @returns a boolean specifying if the material uses the texture
  16615. */
  16616. hasTexture(texture: BaseTexture): boolean;
  16617. /**
  16618. * Makes a duplicate of the material, and gives it a new name
  16619. * @param name defines the new name for the duplicated material
  16620. * @returns the cloned material
  16621. */
  16622. clone(name: string): ShaderMaterial;
  16623. /**
  16624. * Disposes the material
  16625. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16626. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16627. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16628. */
  16629. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16630. /**
  16631. * Serializes this material in a JSON representation
  16632. * @returns the serialized material object
  16633. */
  16634. serialize(): any;
  16635. /**
  16636. * Creates a shader material from parsed shader material data
  16637. * @param source defines the JSON represnetation of the material
  16638. * @param scene defines the hosting scene
  16639. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16640. * @returns a new material
  16641. */
  16642. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16643. }
  16644. }
  16645. declare module BABYLON {
  16646. /** @hidden */
  16647. export var colorPixelShader: {
  16648. name: string;
  16649. shader: string;
  16650. };
  16651. }
  16652. declare module BABYLON {
  16653. /** @hidden */
  16654. export var colorVertexShader: {
  16655. name: string;
  16656. shader: string;
  16657. };
  16658. }
  16659. declare module BABYLON {
  16660. /**
  16661. * Line mesh
  16662. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16663. */
  16664. export class LinesMesh extends Mesh {
  16665. /**
  16666. * If vertex color should be applied to the mesh
  16667. */
  16668. readonly useVertexColor?: boolean | undefined;
  16669. /**
  16670. * If vertex alpha should be applied to the mesh
  16671. */
  16672. readonly useVertexAlpha?: boolean | undefined;
  16673. /**
  16674. * Color of the line (Default: White)
  16675. */
  16676. color: Color3;
  16677. /**
  16678. * Alpha of the line (Default: 1)
  16679. */
  16680. alpha: number;
  16681. /**
  16682. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16683. * This margin is expressed in world space coordinates, so its value may vary.
  16684. * Default value is 0.1
  16685. */
  16686. intersectionThreshold: number;
  16687. private _colorShader;
  16688. private color4;
  16689. /**
  16690. * Creates a new LinesMesh
  16691. * @param name defines the name
  16692. * @param scene defines the hosting scene
  16693. * @param parent defines the parent mesh if any
  16694. * @param source defines the optional source LinesMesh used to clone data from
  16695. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16696. * When false, achieved by calling a clone(), also passing False.
  16697. * This will make creation of children, recursive.
  16698. * @param useVertexColor defines if this LinesMesh supports vertex color
  16699. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16700. */
  16701. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16702. /**
  16703. * If vertex color should be applied to the mesh
  16704. */
  16705. useVertexColor?: boolean | undefined,
  16706. /**
  16707. * If vertex alpha should be applied to the mesh
  16708. */
  16709. useVertexAlpha?: boolean | undefined);
  16710. private _addClipPlaneDefine;
  16711. private _removeClipPlaneDefine;
  16712. isReady(): boolean;
  16713. /**
  16714. * Returns the string "LineMesh"
  16715. */
  16716. getClassName(): string;
  16717. /**
  16718. * @hidden
  16719. */
  16720. get material(): Material;
  16721. /**
  16722. * @hidden
  16723. */
  16724. set material(value: Material);
  16725. /**
  16726. * @hidden
  16727. */
  16728. get checkCollisions(): boolean;
  16729. /** @hidden */
  16730. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16731. /** @hidden */
  16732. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16733. /**
  16734. * Disposes of the line mesh
  16735. * @param doNotRecurse If children should be disposed
  16736. */
  16737. dispose(doNotRecurse?: boolean): void;
  16738. /**
  16739. * Returns a new LineMesh object cloned from the current one.
  16740. */
  16741. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16742. /**
  16743. * Creates a new InstancedLinesMesh object from the mesh model.
  16744. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16745. * @param name defines the name of the new instance
  16746. * @returns a new InstancedLinesMesh
  16747. */
  16748. createInstance(name: string): InstancedLinesMesh;
  16749. }
  16750. /**
  16751. * Creates an instance based on a source LinesMesh
  16752. */
  16753. export class InstancedLinesMesh extends InstancedMesh {
  16754. /**
  16755. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16756. * This margin is expressed in world space coordinates, so its value may vary.
  16757. * Initilized with the intersectionThreshold value of the source LinesMesh
  16758. */
  16759. intersectionThreshold: number;
  16760. constructor(name: string, source: LinesMesh);
  16761. /**
  16762. * Returns the string "InstancedLinesMesh".
  16763. */
  16764. getClassName(): string;
  16765. }
  16766. }
  16767. declare module BABYLON {
  16768. /** @hidden */
  16769. export var linePixelShader: {
  16770. name: string;
  16771. shader: string;
  16772. };
  16773. }
  16774. declare module BABYLON {
  16775. /** @hidden */
  16776. export var lineVertexShader: {
  16777. name: string;
  16778. shader: string;
  16779. };
  16780. }
  16781. declare module BABYLON {
  16782. interface AbstractMesh {
  16783. /**
  16784. * Gets the edgesRenderer associated with the mesh
  16785. */
  16786. edgesRenderer: Nullable<EdgesRenderer>;
  16787. }
  16788. interface LinesMesh {
  16789. /**
  16790. * Enables the edge rendering mode on the mesh.
  16791. * This mode makes the mesh edges visible
  16792. * @param epsilon defines the maximal distance between two angles to detect a face
  16793. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16794. * @returns the currentAbstractMesh
  16795. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16796. */
  16797. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16798. }
  16799. interface InstancedLinesMesh {
  16800. /**
  16801. * Enables the edge rendering mode on the mesh.
  16802. * This mode makes the mesh edges visible
  16803. * @param epsilon defines the maximal distance between two angles to detect a face
  16804. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16805. * @returns the current InstancedLinesMesh
  16806. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16807. */
  16808. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16809. }
  16810. /**
  16811. * Defines the minimum contract an Edges renderer should follow.
  16812. */
  16813. export interface IEdgesRenderer extends IDisposable {
  16814. /**
  16815. * Gets or sets a boolean indicating if the edgesRenderer is active
  16816. */
  16817. isEnabled: boolean;
  16818. /**
  16819. * Renders the edges of the attached mesh,
  16820. */
  16821. render(): void;
  16822. /**
  16823. * Checks wether or not the edges renderer is ready to render.
  16824. * @return true if ready, otherwise false.
  16825. */
  16826. isReady(): boolean;
  16827. }
  16828. /**
  16829. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16830. */
  16831. export class EdgesRenderer implements IEdgesRenderer {
  16832. /**
  16833. * Define the size of the edges with an orthographic camera
  16834. */
  16835. edgesWidthScalerForOrthographic: number;
  16836. /**
  16837. * Define the size of the edges with a perspective camera
  16838. */
  16839. edgesWidthScalerForPerspective: number;
  16840. protected _source: AbstractMesh;
  16841. protected _linesPositions: number[];
  16842. protected _linesNormals: number[];
  16843. protected _linesIndices: number[];
  16844. protected _epsilon: number;
  16845. protected _indicesCount: number;
  16846. protected _lineShader: ShaderMaterial;
  16847. protected _ib: DataBuffer;
  16848. protected _buffers: {
  16849. [key: string]: Nullable<VertexBuffer>;
  16850. };
  16851. protected _checkVerticesInsteadOfIndices: boolean;
  16852. private _meshRebuildObserver;
  16853. private _meshDisposeObserver;
  16854. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16855. isEnabled: boolean;
  16856. /**
  16857. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16858. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16859. * @param source Mesh used to create edges
  16860. * @param epsilon sum of angles in adjacency to check for edge
  16861. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16862. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16863. */
  16864. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16865. protected _prepareRessources(): void;
  16866. /** @hidden */
  16867. _rebuild(): void;
  16868. /**
  16869. * Releases the required resources for the edges renderer
  16870. */
  16871. dispose(): void;
  16872. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16873. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16874. /**
  16875. * Checks if the pair of p0 and p1 is en edge
  16876. * @param faceIndex
  16877. * @param edge
  16878. * @param faceNormals
  16879. * @param p0
  16880. * @param p1
  16881. * @private
  16882. */
  16883. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16884. /**
  16885. * push line into the position, normal and index buffer
  16886. * @protected
  16887. */
  16888. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16889. /**
  16890. * Generates lines edges from adjacencjes
  16891. * @private
  16892. */
  16893. _generateEdgesLines(): void;
  16894. /**
  16895. * Checks wether or not the edges renderer is ready to render.
  16896. * @return true if ready, otherwise false.
  16897. */
  16898. isReady(): boolean;
  16899. /**
  16900. * Renders the edges of the attached mesh,
  16901. */
  16902. render(): void;
  16903. }
  16904. /**
  16905. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16906. */
  16907. export class LineEdgesRenderer extends EdgesRenderer {
  16908. /**
  16909. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16910. * @param source LineMesh used to generate edges
  16911. * @param epsilon not important (specified angle for edge detection)
  16912. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16913. */
  16914. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16915. /**
  16916. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16917. */
  16918. _generateEdgesLines(): void;
  16919. }
  16920. }
  16921. declare module BABYLON {
  16922. /**
  16923. * This represents the object necessary to create a rendering group.
  16924. * This is exclusively used and created by the rendering manager.
  16925. * To modify the behavior, you use the available helpers in your scene or meshes.
  16926. * @hidden
  16927. */
  16928. export class RenderingGroup {
  16929. index: number;
  16930. private static _zeroVector;
  16931. private _scene;
  16932. private _opaqueSubMeshes;
  16933. private _transparentSubMeshes;
  16934. private _alphaTestSubMeshes;
  16935. private _depthOnlySubMeshes;
  16936. private _particleSystems;
  16937. private _spriteManagers;
  16938. private _opaqueSortCompareFn;
  16939. private _alphaTestSortCompareFn;
  16940. private _transparentSortCompareFn;
  16941. private _renderOpaque;
  16942. private _renderAlphaTest;
  16943. private _renderTransparent;
  16944. /** @hidden */
  16945. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16946. onBeforeTransparentRendering: () => void;
  16947. /**
  16948. * Set the opaque sort comparison function.
  16949. * If null the sub meshes will be render in the order they were created
  16950. */
  16951. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16952. /**
  16953. * Set the alpha test sort comparison function.
  16954. * If null the sub meshes will be render in the order they were created
  16955. */
  16956. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16957. /**
  16958. * Set the transparent sort comparison function.
  16959. * If null the sub meshes will be render in the order they were created
  16960. */
  16961. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16962. /**
  16963. * Creates a new rendering group.
  16964. * @param index The rendering group index
  16965. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16966. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16967. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16968. */
  16969. 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>);
  16970. /**
  16971. * Render all the sub meshes contained in the group.
  16972. * @param customRenderFunction Used to override the default render behaviour of the group.
  16973. * @returns true if rendered some submeshes.
  16974. */
  16975. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16976. /**
  16977. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16978. * @param subMeshes The submeshes to render
  16979. */
  16980. private renderOpaqueSorted;
  16981. /**
  16982. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16983. * @param subMeshes The submeshes to render
  16984. */
  16985. private renderAlphaTestSorted;
  16986. /**
  16987. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16988. * @param subMeshes The submeshes to render
  16989. */
  16990. private renderTransparentSorted;
  16991. /**
  16992. * Renders the submeshes in a specified order.
  16993. * @param subMeshes The submeshes to sort before render
  16994. * @param sortCompareFn The comparison function use to sort
  16995. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16996. * @param transparent Specifies to activate blending if true
  16997. */
  16998. private static renderSorted;
  16999. /**
  17000. * Renders the submeshes in the order they were dispatched (no sort applied).
  17001. * @param subMeshes The submeshes to render
  17002. */
  17003. private static renderUnsorted;
  17004. /**
  17005. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17006. * are rendered back to front if in the same alpha index.
  17007. *
  17008. * @param a The first submesh
  17009. * @param b The second submesh
  17010. * @returns The result of the comparison
  17011. */
  17012. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17013. /**
  17014. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17015. * are rendered back to front.
  17016. *
  17017. * @param a The first submesh
  17018. * @param b The second submesh
  17019. * @returns The result of the comparison
  17020. */
  17021. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17022. /**
  17023. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17024. * are rendered front to back (prevent overdraw).
  17025. *
  17026. * @param a The first submesh
  17027. * @param b The second submesh
  17028. * @returns The result of the comparison
  17029. */
  17030. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17031. /**
  17032. * Resets the different lists of submeshes to prepare a new frame.
  17033. */
  17034. prepare(): void;
  17035. dispose(): void;
  17036. /**
  17037. * Inserts the submesh in its correct queue depending on its material.
  17038. * @param subMesh The submesh to dispatch
  17039. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17040. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17041. */
  17042. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17043. dispatchSprites(spriteManager: ISpriteManager): void;
  17044. dispatchParticles(particleSystem: IParticleSystem): void;
  17045. private _renderParticles;
  17046. private _renderSprites;
  17047. }
  17048. }
  17049. declare module BABYLON {
  17050. /**
  17051. * Interface describing the different options available in the rendering manager
  17052. * regarding Auto Clear between groups.
  17053. */
  17054. export interface IRenderingManagerAutoClearSetup {
  17055. /**
  17056. * Defines whether or not autoclear is enable.
  17057. */
  17058. autoClear: boolean;
  17059. /**
  17060. * Defines whether or not to autoclear the depth buffer.
  17061. */
  17062. depth: boolean;
  17063. /**
  17064. * Defines whether or not to autoclear the stencil buffer.
  17065. */
  17066. stencil: boolean;
  17067. }
  17068. /**
  17069. * This class is used by the onRenderingGroupObservable
  17070. */
  17071. export class RenderingGroupInfo {
  17072. /**
  17073. * The Scene that being rendered
  17074. */
  17075. scene: Scene;
  17076. /**
  17077. * The camera currently used for the rendering pass
  17078. */
  17079. camera: Nullable<Camera>;
  17080. /**
  17081. * The ID of the renderingGroup being processed
  17082. */
  17083. renderingGroupId: number;
  17084. }
  17085. /**
  17086. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17087. * It is enable to manage the different groups as well as the different necessary sort functions.
  17088. * This should not be used directly aside of the few static configurations
  17089. */
  17090. export class RenderingManager {
  17091. /**
  17092. * The max id used for rendering groups (not included)
  17093. */
  17094. static MAX_RENDERINGGROUPS: number;
  17095. /**
  17096. * The min id used for rendering groups (included)
  17097. */
  17098. static MIN_RENDERINGGROUPS: number;
  17099. /**
  17100. * Used to globally prevent autoclearing scenes.
  17101. */
  17102. static AUTOCLEAR: boolean;
  17103. /**
  17104. * @hidden
  17105. */
  17106. _useSceneAutoClearSetup: boolean;
  17107. private _scene;
  17108. private _renderingGroups;
  17109. private _depthStencilBufferAlreadyCleaned;
  17110. private _autoClearDepthStencil;
  17111. private _customOpaqueSortCompareFn;
  17112. private _customAlphaTestSortCompareFn;
  17113. private _customTransparentSortCompareFn;
  17114. private _renderingGroupInfo;
  17115. /**
  17116. * Instantiates a new rendering group for a particular scene
  17117. * @param scene Defines the scene the groups belongs to
  17118. */
  17119. constructor(scene: Scene);
  17120. private _clearDepthStencilBuffer;
  17121. /**
  17122. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17123. * @hidden
  17124. */
  17125. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17126. /**
  17127. * Resets the different information of the group to prepare a new frame
  17128. * @hidden
  17129. */
  17130. reset(): void;
  17131. /**
  17132. * Dispose and release the group and its associated resources.
  17133. * @hidden
  17134. */
  17135. dispose(): void;
  17136. /**
  17137. * Clear the info related to rendering groups preventing retention points during dispose.
  17138. */
  17139. freeRenderingGroups(): void;
  17140. private _prepareRenderingGroup;
  17141. /**
  17142. * Add a sprite manager to the rendering manager in order to render it this frame.
  17143. * @param spriteManager Define the sprite manager to render
  17144. */
  17145. dispatchSprites(spriteManager: ISpriteManager): void;
  17146. /**
  17147. * Add a particle system to the rendering manager in order to render it this frame.
  17148. * @param particleSystem Define the particle system to render
  17149. */
  17150. dispatchParticles(particleSystem: IParticleSystem): void;
  17151. /**
  17152. * Add a submesh to the manager in order to render it this frame
  17153. * @param subMesh The submesh to dispatch
  17154. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17155. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17156. */
  17157. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17158. /**
  17159. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17160. * This allowed control for front to back rendering or reversly depending of the special needs.
  17161. *
  17162. * @param renderingGroupId The rendering group id corresponding to its index
  17163. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17164. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17165. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17166. */
  17167. 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;
  17168. /**
  17169. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17170. *
  17171. * @param renderingGroupId The rendering group id corresponding to its index
  17172. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17173. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17174. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17175. */
  17176. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17177. /**
  17178. * Gets the current auto clear configuration for one rendering group of the rendering
  17179. * manager.
  17180. * @param index the rendering group index to get the information for
  17181. * @returns The auto clear setup for the requested rendering group
  17182. */
  17183. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17184. }
  17185. }
  17186. declare module BABYLON {
  17187. /**
  17188. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17189. */
  17190. export interface ICustomShaderOptions {
  17191. /**
  17192. * Gets or sets the custom shader name to use
  17193. */
  17194. shaderName: string;
  17195. /**
  17196. * The list of attribute names used in the shader
  17197. */
  17198. attributes?: string[];
  17199. /**
  17200. * The list of unifrom names used in the shader
  17201. */
  17202. uniforms?: string[];
  17203. /**
  17204. * The list of sampler names used in the shader
  17205. */
  17206. samplers?: string[];
  17207. /**
  17208. * The list of defines used in the shader
  17209. */
  17210. defines?: string[];
  17211. }
  17212. /**
  17213. * Interface to implement to create a shadow generator compatible with BJS.
  17214. */
  17215. export interface IShadowGenerator {
  17216. /**
  17217. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17218. * @returns The render target texture if present otherwise, null
  17219. */
  17220. getShadowMap(): Nullable<RenderTargetTexture>;
  17221. /**
  17222. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17223. * @param subMesh The submesh we want to render in the shadow map
  17224. * @param useInstances Defines wether will draw in the map using instances
  17225. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17226. * @returns true if ready otherwise, false
  17227. */
  17228. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17229. /**
  17230. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17231. * @param defines Defines of the material we want to update
  17232. * @param lightIndex Index of the light in the enabled light list of the material
  17233. */
  17234. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17235. /**
  17236. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17237. * defined in the generator but impacting the effect).
  17238. * It implies the unifroms available on the materials are the standard BJS ones.
  17239. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17240. * @param effect The effect we are binfing the information for
  17241. */
  17242. bindShadowLight(lightIndex: string, effect: Effect): void;
  17243. /**
  17244. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17245. * (eq to shadow prjection matrix * light transform matrix)
  17246. * @returns The transform matrix used to create the shadow map
  17247. */
  17248. getTransformMatrix(): Matrix;
  17249. /**
  17250. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17251. * Cube and 2D textures for instance.
  17252. */
  17253. recreateShadowMap(): void;
  17254. /**
  17255. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17256. * @param onCompiled Callback triggered at the and of the effects compilation
  17257. * @param options Sets of optional options forcing the compilation with different modes
  17258. */
  17259. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17260. useInstances: boolean;
  17261. }>): void;
  17262. /**
  17263. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17264. * @param options Sets of optional options forcing the compilation with different modes
  17265. * @returns A promise that resolves when the compilation completes
  17266. */
  17267. forceCompilationAsync(options?: Partial<{
  17268. useInstances: boolean;
  17269. }>): Promise<void>;
  17270. /**
  17271. * Serializes the shadow generator setup to a json object.
  17272. * @returns The serialized JSON object
  17273. */
  17274. serialize(): any;
  17275. /**
  17276. * Disposes the Shadow map and related Textures and effects.
  17277. */
  17278. dispose(): void;
  17279. }
  17280. /**
  17281. * Default implementation IShadowGenerator.
  17282. * This is the main object responsible of generating shadows in the framework.
  17283. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17284. */
  17285. export class ShadowGenerator implements IShadowGenerator {
  17286. /**
  17287. * Name of the shadow generator class
  17288. */
  17289. static CLASSNAME: string;
  17290. /**
  17291. * Shadow generator mode None: no filtering applied.
  17292. */
  17293. static readonly FILTER_NONE: number;
  17294. /**
  17295. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17296. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17297. */
  17298. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17299. /**
  17300. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17301. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17302. */
  17303. static readonly FILTER_POISSONSAMPLING: number;
  17304. /**
  17305. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17306. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17307. */
  17308. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17309. /**
  17310. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17311. * edge artifacts on steep falloff.
  17312. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17313. */
  17314. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17315. /**
  17316. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17317. * edge artifacts on steep falloff.
  17318. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17319. */
  17320. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17321. /**
  17322. * Shadow generator mode PCF: Percentage Closer Filtering
  17323. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17324. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17325. */
  17326. static readonly FILTER_PCF: number;
  17327. /**
  17328. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17329. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17330. * Contact Hardening
  17331. */
  17332. static readonly FILTER_PCSS: number;
  17333. /**
  17334. * Reserved for PCF and PCSS
  17335. * Highest Quality.
  17336. *
  17337. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17338. *
  17339. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17340. */
  17341. static readonly QUALITY_HIGH: number;
  17342. /**
  17343. * Reserved for PCF and PCSS
  17344. * Good tradeoff for quality/perf cross devices
  17345. *
  17346. * Execute PCF on a 3*3 kernel.
  17347. *
  17348. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17349. */
  17350. static readonly QUALITY_MEDIUM: number;
  17351. /**
  17352. * Reserved for PCF and PCSS
  17353. * The lowest quality but the fastest.
  17354. *
  17355. * Execute PCF on a 1*1 kernel.
  17356. *
  17357. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17358. */
  17359. static readonly QUALITY_LOW: number;
  17360. /** Gets or sets the custom shader name to use */
  17361. customShaderOptions: ICustomShaderOptions;
  17362. /**
  17363. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17364. */
  17365. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17366. /**
  17367. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17368. */
  17369. onAfterShadowMapRenderObservable: Observable<Effect>;
  17370. /**
  17371. * Observable triggered before a mesh is rendered in the shadow map.
  17372. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17373. */
  17374. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17375. /**
  17376. * Observable triggered after a mesh is rendered in the shadow map.
  17377. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17378. */
  17379. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17380. protected _bias: number;
  17381. /**
  17382. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17383. */
  17384. get bias(): number;
  17385. /**
  17386. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17387. */
  17388. set bias(bias: number);
  17389. protected _normalBias: number;
  17390. /**
  17391. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17392. */
  17393. get normalBias(): number;
  17394. /**
  17395. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17396. */
  17397. set normalBias(normalBias: number);
  17398. protected _blurBoxOffset: number;
  17399. /**
  17400. * Gets the blur box offset: offset applied during the blur pass.
  17401. * Only useful if useKernelBlur = false
  17402. */
  17403. get blurBoxOffset(): number;
  17404. /**
  17405. * Sets the blur box offset: offset applied during the blur pass.
  17406. * Only useful if useKernelBlur = false
  17407. */
  17408. set blurBoxOffset(value: number);
  17409. protected _blurScale: number;
  17410. /**
  17411. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17412. * 2 means half of the size.
  17413. */
  17414. get blurScale(): number;
  17415. /**
  17416. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17417. * 2 means half of the size.
  17418. */
  17419. set blurScale(value: number);
  17420. protected _blurKernel: number;
  17421. /**
  17422. * Gets the blur kernel: kernel size of the blur pass.
  17423. * Only useful if useKernelBlur = true
  17424. */
  17425. get blurKernel(): number;
  17426. /**
  17427. * Sets the blur kernel: kernel size of the blur pass.
  17428. * Only useful if useKernelBlur = true
  17429. */
  17430. set blurKernel(value: number);
  17431. protected _useKernelBlur: boolean;
  17432. /**
  17433. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17434. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17435. */
  17436. get useKernelBlur(): boolean;
  17437. /**
  17438. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17439. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17440. */
  17441. set useKernelBlur(value: boolean);
  17442. protected _depthScale: number;
  17443. /**
  17444. * Gets the depth scale used in ESM mode.
  17445. */
  17446. get depthScale(): number;
  17447. /**
  17448. * Sets the depth scale used in ESM mode.
  17449. * This can override the scale stored on the light.
  17450. */
  17451. set depthScale(value: number);
  17452. protected _validateFilter(filter: number): number;
  17453. protected _filter: number;
  17454. /**
  17455. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17456. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17457. */
  17458. get filter(): number;
  17459. /**
  17460. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17461. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17462. */
  17463. set filter(value: number);
  17464. /**
  17465. * Gets if the current filter is set to Poisson Sampling.
  17466. */
  17467. get usePoissonSampling(): boolean;
  17468. /**
  17469. * Sets the current filter to Poisson Sampling.
  17470. */
  17471. set usePoissonSampling(value: boolean);
  17472. /**
  17473. * Gets if the current filter is set to ESM.
  17474. */
  17475. get useExponentialShadowMap(): boolean;
  17476. /**
  17477. * Sets the current filter is to ESM.
  17478. */
  17479. set useExponentialShadowMap(value: boolean);
  17480. /**
  17481. * Gets if the current filter is set to filtered ESM.
  17482. */
  17483. get useBlurExponentialShadowMap(): boolean;
  17484. /**
  17485. * Gets if the current filter is set to filtered ESM.
  17486. */
  17487. set useBlurExponentialShadowMap(value: boolean);
  17488. /**
  17489. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17490. * exponential to prevent steep falloff artifacts).
  17491. */
  17492. get useCloseExponentialShadowMap(): boolean;
  17493. /**
  17494. * Sets the current filter to "close ESM" (using the inverse of the
  17495. * exponential to prevent steep falloff artifacts).
  17496. */
  17497. set useCloseExponentialShadowMap(value: boolean);
  17498. /**
  17499. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17500. * exponential to prevent steep falloff artifacts).
  17501. */
  17502. get useBlurCloseExponentialShadowMap(): boolean;
  17503. /**
  17504. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17505. * exponential to prevent steep falloff artifacts).
  17506. */
  17507. set useBlurCloseExponentialShadowMap(value: boolean);
  17508. /**
  17509. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17510. */
  17511. get usePercentageCloserFiltering(): boolean;
  17512. /**
  17513. * Sets the current filter to "PCF" (percentage closer filtering).
  17514. */
  17515. set usePercentageCloserFiltering(value: boolean);
  17516. protected _filteringQuality: number;
  17517. /**
  17518. * Gets the PCF or PCSS Quality.
  17519. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17520. */
  17521. get filteringQuality(): number;
  17522. /**
  17523. * Sets the PCF or PCSS Quality.
  17524. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17525. */
  17526. set filteringQuality(filteringQuality: number);
  17527. /**
  17528. * Gets if the current filter is set to "PCSS" (contact hardening).
  17529. */
  17530. get useContactHardeningShadow(): boolean;
  17531. /**
  17532. * Sets the current filter to "PCSS" (contact hardening).
  17533. */
  17534. set useContactHardeningShadow(value: boolean);
  17535. protected _contactHardeningLightSizeUVRatio: number;
  17536. /**
  17537. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17538. * Using a ratio helps keeping shape stability independently of the map size.
  17539. *
  17540. * It does not account for the light projection as it was having too much
  17541. * instability during the light setup or during light position changes.
  17542. *
  17543. * Only valid if useContactHardeningShadow is true.
  17544. */
  17545. get contactHardeningLightSizeUVRatio(): number;
  17546. /**
  17547. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17548. * Using a ratio helps keeping shape stability independently of the map size.
  17549. *
  17550. * It does not account for the light projection as it was having too much
  17551. * instability during the light setup or during light position changes.
  17552. *
  17553. * Only valid if useContactHardeningShadow is true.
  17554. */
  17555. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17556. protected _darkness: number;
  17557. /** Gets or sets the actual darkness of a shadow */
  17558. get darkness(): number;
  17559. set darkness(value: number);
  17560. /**
  17561. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17562. * 0 means strongest and 1 would means no shadow.
  17563. * @returns the darkness.
  17564. */
  17565. getDarkness(): number;
  17566. /**
  17567. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17568. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17569. * @returns the shadow generator allowing fluent coding.
  17570. */
  17571. setDarkness(darkness: number): ShadowGenerator;
  17572. protected _transparencyShadow: boolean;
  17573. /** Gets or sets the ability to have transparent shadow */
  17574. get transparencyShadow(): boolean;
  17575. set transparencyShadow(value: boolean);
  17576. /**
  17577. * Sets the ability to have transparent shadow (boolean).
  17578. * @param transparent True if transparent else False
  17579. * @returns the shadow generator allowing fluent coding
  17580. */
  17581. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17582. /**
  17583. * Enables or disables shadows with varying strength based on the transparency
  17584. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17585. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17586. * mesh.visibility * alphaTexture.a
  17587. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17588. */
  17589. enableSoftTransparentShadow: boolean;
  17590. protected _shadowMap: Nullable<RenderTargetTexture>;
  17591. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17592. /**
  17593. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17594. * @returns The render target texture if present otherwise, null
  17595. */
  17596. getShadowMap(): Nullable<RenderTargetTexture>;
  17597. /**
  17598. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17599. * @returns The render target texture if the shadow map is present otherwise, null
  17600. */
  17601. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17602. /**
  17603. * Gets the class name of that object
  17604. * @returns "ShadowGenerator"
  17605. */
  17606. getClassName(): string;
  17607. /**
  17608. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17609. * @param mesh Mesh to add
  17610. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17611. * @returns the Shadow Generator itself
  17612. */
  17613. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17614. /**
  17615. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17616. * @param mesh Mesh to remove
  17617. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17618. * @returns the Shadow Generator itself
  17619. */
  17620. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17621. /**
  17622. * Controls the extent to which the shadows fade out at the edge of the frustum
  17623. */
  17624. frustumEdgeFalloff: number;
  17625. protected _light: IShadowLight;
  17626. /**
  17627. * Returns the associated light object.
  17628. * @returns the light generating the shadow
  17629. */
  17630. getLight(): IShadowLight;
  17631. /**
  17632. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17633. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17634. * It might on the other hand introduce peter panning.
  17635. */
  17636. forceBackFacesOnly: boolean;
  17637. protected _scene: Scene;
  17638. protected _lightDirection: Vector3;
  17639. protected _effect: Effect;
  17640. protected _viewMatrix: Matrix;
  17641. protected _projectionMatrix: Matrix;
  17642. protected _transformMatrix: Matrix;
  17643. protected _cachedPosition: Vector3;
  17644. protected _cachedDirection: Vector3;
  17645. protected _cachedDefines: string;
  17646. protected _currentRenderID: number;
  17647. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17648. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17649. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17650. protected _blurPostProcesses: PostProcess[];
  17651. protected _mapSize: number;
  17652. protected _currentFaceIndex: number;
  17653. protected _currentFaceIndexCache: number;
  17654. protected _textureType: number;
  17655. protected _defaultTextureMatrix: Matrix;
  17656. protected _storedUniqueId: Nullable<number>;
  17657. /** @hidden */
  17658. static _SceneComponentInitialization: (scene: Scene) => void;
  17659. /**
  17660. * Creates a ShadowGenerator object.
  17661. * A ShadowGenerator is the required tool to use the shadows.
  17662. * Each light casting shadows needs to use its own ShadowGenerator.
  17663. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17664. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17665. * @param light The light object generating the shadows.
  17666. * @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.
  17667. */
  17668. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17669. protected _initializeGenerator(): void;
  17670. protected _createTargetRenderTexture(): void;
  17671. protected _initializeShadowMap(): void;
  17672. protected _initializeBlurRTTAndPostProcesses(): void;
  17673. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17674. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17675. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17676. protected _applyFilterValues(): void;
  17677. /**
  17678. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17679. * @param onCompiled Callback triggered at the and of the effects compilation
  17680. * @param options Sets of optional options forcing the compilation with different modes
  17681. */
  17682. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17683. useInstances: boolean;
  17684. }>): void;
  17685. /**
  17686. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17687. * @param options Sets of optional options forcing the compilation with different modes
  17688. * @returns A promise that resolves when the compilation completes
  17689. */
  17690. forceCompilationAsync(options?: Partial<{
  17691. useInstances: boolean;
  17692. }>): Promise<void>;
  17693. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17694. private _prepareShadowDefines;
  17695. /**
  17696. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17697. * @param subMesh The submesh we want to render in the shadow map
  17698. * @param useInstances Defines wether will draw in the map using instances
  17699. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17700. * @returns true if ready otherwise, false
  17701. */
  17702. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17703. /**
  17704. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17705. * @param defines Defines of the material we want to update
  17706. * @param lightIndex Index of the light in the enabled light list of the material
  17707. */
  17708. prepareDefines(defines: any, lightIndex: number): void;
  17709. /**
  17710. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17711. * defined in the generator but impacting the effect).
  17712. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17713. * @param effect The effect we are binfing the information for
  17714. */
  17715. bindShadowLight(lightIndex: string, effect: Effect): void;
  17716. /**
  17717. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17718. * (eq to shadow prjection matrix * light transform matrix)
  17719. * @returns The transform matrix used to create the shadow map
  17720. */
  17721. getTransformMatrix(): Matrix;
  17722. /**
  17723. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17724. * Cube and 2D textures for instance.
  17725. */
  17726. recreateShadowMap(): void;
  17727. protected _disposeBlurPostProcesses(): void;
  17728. protected _disposeRTTandPostProcesses(): void;
  17729. /**
  17730. * Disposes the ShadowGenerator.
  17731. * Returns nothing.
  17732. */
  17733. dispose(): void;
  17734. /**
  17735. * Serializes the shadow generator setup to a json object.
  17736. * @returns The serialized JSON object
  17737. */
  17738. serialize(): any;
  17739. /**
  17740. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17741. * @param parsedShadowGenerator The JSON object to parse
  17742. * @param scene The scene to create the shadow map for
  17743. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17744. * @returns The parsed shadow generator
  17745. */
  17746. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17747. }
  17748. }
  17749. declare module BABYLON {
  17750. /**
  17751. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17752. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17753. * 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.
  17754. */
  17755. export abstract class Light extends Node {
  17756. /**
  17757. * Falloff Default: light is falling off following the material specification:
  17758. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17759. */
  17760. static readonly FALLOFF_DEFAULT: number;
  17761. /**
  17762. * Falloff Physical: light is falling off following the inverse squared distance law.
  17763. */
  17764. static readonly FALLOFF_PHYSICAL: number;
  17765. /**
  17766. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17767. * to enhance interoperability with other engines.
  17768. */
  17769. static readonly FALLOFF_GLTF: number;
  17770. /**
  17771. * Falloff Standard: light is falling off like in the standard material
  17772. * to enhance interoperability with other materials.
  17773. */
  17774. static readonly FALLOFF_STANDARD: number;
  17775. /**
  17776. * If every light affecting the material is in this lightmapMode,
  17777. * material.lightmapTexture adds or multiplies
  17778. * (depends on material.useLightmapAsShadowmap)
  17779. * after every other light calculations.
  17780. */
  17781. static readonly LIGHTMAP_DEFAULT: number;
  17782. /**
  17783. * material.lightmapTexture as only diffuse lighting from this light
  17784. * adds only specular lighting from this light
  17785. * adds dynamic shadows
  17786. */
  17787. static readonly LIGHTMAP_SPECULAR: number;
  17788. /**
  17789. * material.lightmapTexture as only lighting
  17790. * no light calculation from this light
  17791. * only adds dynamic shadows from this light
  17792. */
  17793. static readonly LIGHTMAP_SHADOWSONLY: number;
  17794. /**
  17795. * Each light type uses the default quantity according to its type:
  17796. * point/spot lights use luminous intensity
  17797. * directional lights use illuminance
  17798. */
  17799. static readonly INTENSITYMODE_AUTOMATIC: number;
  17800. /**
  17801. * lumen (lm)
  17802. */
  17803. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17804. /**
  17805. * candela (lm/sr)
  17806. */
  17807. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17808. /**
  17809. * lux (lm/m^2)
  17810. */
  17811. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17812. /**
  17813. * nit (cd/m^2)
  17814. */
  17815. static readonly INTENSITYMODE_LUMINANCE: number;
  17816. /**
  17817. * Light type const id of the point light.
  17818. */
  17819. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17820. /**
  17821. * Light type const id of the directional light.
  17822. */
  17823. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17824. /**
  17825. * Light type const id of the spot light.
  17826. */
  17827. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17828. /**
  17829. * Light type const id of the hemispheric light.
  17830. */
  17831. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17832. /**
  17833. * Diffuse gives the basic color to an object.
  17834. */
  17835. diffuse: Color3;
  17836. /**
  17837. * Specular produces a highlight color on an object.
  17838. * Note: This is note affecting PBR materials.
  17839. */
  17840. specular: Color3;
  17841. /**
  17842. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17843. * falling off base on range or angle.
  17844. * This can be set to any values in Light.FALLOFF_x.
  17845. *
  17846. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17847. * other types of materials.
  17848. */
  17849. falloffType: number;
  17850. /**
  17851. * Strength of the light.
  17852. * Note: By default it is define in the framework own unit.
  17853. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17854. */
  17855. intensity: number;
  17856. private _range;
  17857. protected _inverseSquaredRange: number;
  17858. /**
  17859. * Defines how far from the source the light is impacting in scene units.
  17860. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17861. */
  17862. get range(): number;
  17863. /**
  17864. * Defines how far from the source the light is impacting in scene units.
  17865. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17866. */
  17867. set range(value: number);
  17868. /**
  17869. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17870. * of light.
  17871. */
  17872. private _photometricScale;
  17873. private _intensityMode;
  17874. /**
  17875. * Gets the photometric scale used to interpret the intensity.
  17876. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17877. */
  17878. get intensityMode(): number;
  17879. /**
  17880. * Sets the photometric scale used to interpret the intensity.
  17881. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17882. */
  17883. set intensityMode(value: number);
  17884. private _radius;
  17885. /**
  17886. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17887. */
  17888. get radius(): number;
  17889. /**
  17890. * sets the light radius used by PBR Materials to simulate soft area lights.
  17891. */
  17892. set radius(value: number);
  17893. private _renderPriority;
  17894. /**
  17895. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17896. * exceeding the number allowed of the materials.
  17897. */
  17898. renderPriority: number;
  17899. private _shadowEnabled;
  17900. /**
  17901. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17902. * the current shadow generator.
  17903. */
  17904. get shadowEnabled(): boolean;
  17905. /**
  17906. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17907. * the current shadow generator.
  17908. */
  17909. set shadowEnabled(value: boolean);
  17910. private _includedOnlyMeshes;
  17911. /**
  17912. * Gets the only meshes impacted by this light.
  17913. */
  17914. get includedOnlyMeshes(): AbstractMesh[];
  17915. /**
  17916. * Sets the only meshes impacted by this light.
  17917. */
  17918. set includedOnlyMeshes(value: AbstractMesh[]);
  17919. private _excludedMeshes;
  17920. /**
  17921. * Gets the meshes not impacted by this light.
  17922. */
  17923. get excludedMeshes(): AbstractMesh[];
  17924. /**
  17925. * Sets the meshes not impacted by this light.
  17926. */
  17927. set excludedMeshes(value: AbstractMesh[]);
  17928. private _excludeWithLayerMask;
  17929. /**
  17930. * Gets the layer id use to find what meshes are not impacted by the light.
  17931. * Inactive if 0
  17932. */
  17933. get excludeWithLayerMask(): number;
  17934. /**
  17935. * Sets the layer id use to find what meshes are not impacted by the light.
  17936. * Inactive if 0
  17937. */
  17938. set excludeWithLayerMask(value: number);
  17939. private _includeOnlyWithLayerMask;
  17940. /**
  17941. * Gets the layer id use to find what meshes are impacted by the light.
  17942. * Inactive if 0
  17943. */
  17944. get includeOnlyWithLayerMask(): number;
  17945. /**
  17946. * Sets the layer id use to find what meshes are impacted by the light.
  17947. * Inactive if 0
  17948. */
  17949. set includeOnlyWithLayerMask(value: number);
  17950. private _lightmapMode;
  17951. /**
  17952. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17953. */
  17954. get lightmapMode(): number;
  17955. /**
  17956. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17957. */
  17958. set lightmapMode(value: number);
  17959. /**
  17960. * Shadow generator associted to the light.
  17961. * @hidden Internal use only.
  17962. */
  17963. _shadowGenerator: Nullable<IShadowGenerator>;
  17964. /**
  17965. * @hidden Internal use only.
  17966. */
  17967. _excludedMeshesIds: string[];
  17968. /**
  17969. * @hidden Internal use only.
  17970. */
  17971. _includedOnlyMeshesIds: string[];
  17972. /**
  17973. * The current light unifom buffer.
  17974. * @hidden Internal use only.
  17975. */
  17976. _uniformBuffer: UniformBuffer;
  17977. /** @hidden */
  17978. _renderId: number;
  17979. /**
  17980. * Creates a Light object in the scene.
  17981. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17982. * @param name The firendly name of the light
  17983. * @param scene The scene the light belongs too
  17984. */
  17985. constructor(name: string, scene: Scene);
  17986. protected abstract _buildUniformLayout(): void;
  17987. /**
  17988. * Sets the passed Effect "effect" with the Light information.
  17989. * @param effect The effect to update
  17990. * @param lightIndex The index of the light in the effect to update
  17991. * @returns The light
  17992. */
  17993. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17994. /**
  17995. * Sets the passed Effect "effect" with the Light textures.
  17996. * @param effect The effect to update
  17997. * @param lightIndex The index of the light in the effect to update
  17998. * @returns The light
  17999. */
  18000. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18001. /**
  18002. * Binds the lights information from the scene to the effect for the given mesh.
  18003. * @param lightIndex Light index
  18004. * @param scene The scene where the light belongs to
  18005. * @param effect The effect we are binding the data to
  18006. * @param useSpecular Defines if specular is supported
  18007. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18008. */
  18009. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18010. /**
  18011. * Sets the passed Effect "effect" with the Light information.
  18012. * @param effect The effect to update
  18013. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18014. * @returns The light
  18015. */
  18016. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18017. /**
  18018. * Returns the string "Light".
  18019. * @returns the class name
  18020. */
  18021. getClassName(): string;
  18022. /** @hidden */
  18023. readonly _isLight: boolean;
  18024. /**
  18025. * Converts the light information to a readable string for debug purpose.
  18026. * @param fullDetails Supports for multiple levels of logging within scene loading
  18027. * @returns the human readable light info
  18028. */
  18029. toString(fullDetails?: boolean): string;
  18030. /** @hidden */
  18031. protected _syncParentEnabledState(): void;
  18032. /**
  18033. * Set the enabled state of this node.
  18034. * @param value - the new enabled state
  18035. */
  18036. setEnabled(value: boolean): void;
  18037. /**
  18038. * Returns the Light associated shadow generator if any.
  18039. * @return the associated shadow generator.
  18040. */
  18041. getShadowGenerator(): Nullable<IShadowGenerator>;
  18042. /**
  18043. * Returns a Vector3, the absolute light position in the World.
  18044. * @returns the world space position of the light
  18045. */
  18046. getAbsolutePosition(): Vector3;
  18047. /**
  18048. * Specifies if the light will affect the passed mesh.
  18049. * @param mesh The mesh to test against the light
  18050. * @return true the mesh is affected otherwise, false.
  18051. */
  18052. canAffectMesh(mesh: AbstractMesh): boolean;
  18053. /**
  18054. * Sort function to order lights for rendering.
  18055. * @param a First Light object to compare to second.
  18056. * @param b Second Light object to compare first.
  18057. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18058. */
  18059. static CompareLightsPriority(a: Light, b: Light): number;
  18060. /**
  18061. * Releases resources associated with this node.
  18062. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18063. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18064. */
  18065. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18066. /**
  18067. * Returns the light type ID (integer).
  18068. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18069. */
  18070. getTypeID(): number;
  18071. /**
  18072. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18073. * @returns the scaled intensity in intensity mode unit
  18074. */
  18075. getScaledIntensity(): number;
  18076. /**
  18077. * Returns a new Light object, named "name", from the current one.
  18078. * @param name The name of the cloned light
  18079. * @param newParent The parent of this light, if it has one
  18080. * @returns the new created light
  18081. */
  18082. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18083. /**
  18084. * Serializes the current light into a Serialization object.
  18085. * @returns the serialized object.
  18086. */
  18087. serialize(): any;
  18088. /**
  18089. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18090. * This new light is named "name" and added to the passed scene.
  18091. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18092. * @param name The friendly name of the light
  18093. * @param scene The scene the new light will belong to
  18094. * @returns the constructor function
  18095. */
  18096. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18097. /**
  18098. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18099. * @param parsedLight The JSON representation of the light
  18100. * @param scene The scene to create the parsed light in
  18101. * @returns the created light after parsing
  18102. */
  18103. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18104. private _hookArrayForExcluded;
  18105. private _hookArrayForIncludedOnly;
  18106. private _resyncMeshes;
  18107. /**
  18108. * Forces the meshes to update their light related information in their rendering used effects
  18109. * @hidden Internal Use Only
  18110. */
  18111. _markMeshesAsLightDirty(): void;
  18112. /**
  18113. * Recomputes the cached photometric scale if needed.
  18114. */
  18115. private _computePhotometricScale;
  18116. /**
  18117. * Returns the Photometric Scale according to the light type and intensity mode.
  18118. */
  18119. private _getPhotometricScale;
  18120. /**
  18121. * Reorder the light in the scene according to their defined priority.
  18122. * @hidden Internal Use Only
  18123. */
  18124. _reorderLightsInScene(): void;
  18125. /**
  18126. * Prepares the list of defines specific to the light type.
  18127. * @param defines the list of defines
  18128. * @param lightIndex defines the index of the light for the effect
  18129. */
  18130. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18131. }
  18132. }
  18133. declare module BABYLON {
  18134. /**
  18135. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18136. * This is the base of the follow, arc rotate cameras and Free camera
  18137. * @see http://doc.babylonjs.com/features/cameras
  18138. */
  18139. export class TargetCamera extends Camera {
  18140. private static _RigCamTransformMatrix;
  18141. private static _TargetTransformMatrix;
  18142. private static _TargetFocalPoint;
  18143. /**
  18144. * Define the current direction the camera is moving to
  18145. */
  18146. cameraDirection: Vector3;
  18147. /**
  18148. * Define the current rotation the camera is rotating to
  18149. */
  18150. cameraRotation: Vector2;
  18151. /**
  18152. * When set, the up vector of the camera will be updated by the rotation of the camera
  18153. */
  18154. updateUpVectorFromRotation: boolean;
  18155. private _tmpQuaternion;
  18156. /**
  18157. * Define the current rotation of the camera
  18158. */
  18159. rotation: Vector3;
  18160. /**
  18161. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18162. */
  18163. rotationQuaternion: Quaternion;
  18164. /**
  18165. * Define the current speed of the camera
  18166. */
  18167. speed: number;
  18168. /**
  18169. * Add constraint to the camera to prevent it to move freely in all directions and
  18170. * around all axis.
  18171. */
  18172. noRotationConstraint: boolean;
  18173. /**
  18174. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18175. * panning
  18176. */
  18177. invertRotation: boolean;
  18178. /**
  18179. * Speed multiplier for inverse camera panning
  18180. */
  18181. inverseRotationSpeed: number;
  18182. /**
  18183. * Define the current target of the camera as an object or a position.
  18184. */
  18185. lockedTarget: any;
  18186. /** @hidden */
  18187. _currentTarget: Vector3;
  18188. /** @hidden */
  18189. _initialFocalDistance: number;
  18190. /** @hidden */
  18191. _viewMatrix: Matrix;
  18192. /** @hidden */
  18193. _camMatrix: Matrix;
  18194. /** @hidden */
  18195. _cameraTransformMatrix: Matrix;
  18196. /** @hidden */
  18197. _cameraRotationMatrix: Matrix;
  18198. /** @hidden */
  18199. _referencePoint: Vector3;
  18200. /** @hidden */
  18201. _transformedReferencePoint: Vector3;
  18202. protected _globalCurrentTarget: Vector3;
  18203. protected _globalCurrentUpVector: Vector3;
  18204. /** @hidden */
  18205. _reset: () => void;
  18206. private _defaultUp;
  18207. /**
  18208. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18209. * This is the base of the follow, arc rotate cameras and Free camera
  18210. * @see http://doc.babylonjs.com/features/cameras
  18211. * @param name Defines the name of the camera in the scene
  18212. * @param position Defines the start position of the camera in the scene
  18213. * @param scene Defines the scene the camera belongs to
  18214. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18215. */
  18216. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18217. /**
  18218. * Gets the position in front of the camera at a given distance.
  18219. * @param distance The distance from the camera we want the position to be
  18220. * @returns the position
  18221. */
  18222. getFrontPosition(distance: number): Vector3;
  18223. /** @hidden */
  18224. _getLockedTargetPosition(): Nullable<Vector3>;
  18225. private _storedPosition;
  18226. private _storedRotation;
  18227. private _storedRotationQuaternion;
  18228. /**
  18229. * Store current camera state of the camera (fov, position, rotation, etc..)
  18230. * @returns the camera
  18231. */
  18232. storeState(): Camera;
  18233. /**
  18234. * Restored camera state. You must call storeState() first
  18235. * @returns whether it was successful or not
  18236. * @hidden
  18237. */
  18238. _restoreStateValues(): boolean;
  18239. /** @hidden */
  18240. _initCache(): void;
  18241. /** @hidden */
  18242. _updateCache(ignoreParentClass?: boolean): void;
  18243. /** @hidden */
  18244. _isSynchronizedViewMatrix(): boolean;
  18245. /** @hidden */
  18246. _computeLocalCameraSpeed(): number;
  18247. /**
  18248. * Defines the target the camera should look at.
  18249. * @param target Defines the new target as a Vector or a mesh
  18250. */
  18251. setTarget(target: Vector3): void;
  18252. /**
  18253. * Return the current target position of the camera. This value is expressed in local space.
  18254. * @returns the target position
  18255. */
  18256. getTarget(): Vector3;
  18257. /** @hidden */
  18258. _decideIfNeedsToMove(): boolean;
  18259. /** @hidden */
  18260. _updatePosition(): void;
  18261. /** @hidden */
  18262. _checkInputs(): void;
  18263. protected _updateCameraRotationMatrix(): void;
  18264. /**
  18265. * 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)
  18266. * @returns the current camera
  18267. */
  18268. private _rotateUpVectorWithCameraRotationMatrix;
  18269. private _cachedRotationZ;
  18270. private _cachedQuaternionRotationZ;
  18271. /** @hidden */
  18272. _getViewMatrix(): Matrix;
  18273. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18274. /**
  18275. * @hidden
  18276. */
  18277. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18278. /**
  18279. * @hidden
  18280. */
  18281. _updateRigCameras(): void;
  18282. private _getRigCamPositionAndTarget;
  18283. /**
  18284. * Gets the current object class name.
  18285. * @return the class name
  18286. */
  18287. getClassName(): string;
  18288. }
  18289. }
  18290. declare module BABYLON {
  18291. /**
  18292. * Gather the list of keyboard event types as constants.
  18293. */
  18294. export class KeyboardEventTypes {
  18295. /**
  18296. * The keydown event is fired when a key becomes active (pressed).
  18297. */
  18298. static readonly KEYDOWN: number;
  18299. /**
  18300. * The keyup event is fired when a key has been released.
  18301. */
  18302. static readonly KEYUP: number;
  18303. }
  18304. /**
  18305. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18306. */
  18307. export class KeyboardInfo {
  18308. /**
  18309. * Defines the type of event (KeyboardEventTypes)
  18310. */
  18311. type: number;
  18312. /**
  18313. * Defines the related dom event
  18314. */
  18315. event: KeyboardEvent;
  18316. /**
  18317. * Instantiates a new keyboard info.
  18318. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18319. * @param type Defines the type of event (KeyboardEventTypes)
  18320. * @param event Defines the related dom event
  18321. */
  18322. constructor(
  18323. /**
  18324. * Defines the type of event (KeyboardEventTypes)
  18325. */
  18326. type: number,
  18327. /**
  18328. * Defines the related dom event
  18329. */
  18330. event: KeyboardEvent);
  18331. }
  18332. /**
  18333. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18334. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18335. */
  18336. export class KeyboardInfoPre extends KeyboardInfo {
  18337. /**
  18338. * Defines the type of event (KeyboardEventTypes)
  18339. */
  18340. type: number;
  18341. /**
  18342. * Defines the related dom event
  18343. */
  18344. event: KeyboardEvent;
  18345. /**
  18346. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18347. */
  18348. skipOnPointerObservable: boolean;
  18349. /**
  18350. * Instantiates a new keyboard pre info.
  18351. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18352. * @param type Defines the type of event (KeyboardEventTypes)
  18353. * @param event Defines the related dom event
  18354. */
  18355. constructor(
  18356. /**
  18357. * Defines the type of event (KeyboardEventTypes)
  18358. */
  18359. type: number,
  18360. /**
  18361. * Defines the related dom event
  18362. */
  18363. event: KeyboardEvent);
  18364. }
  18365. }
  18366. declare module BABYLON {
  18367. /**
  18368. * Manage the keyboard inputs to control the movement of a free camera.
  18369. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18370. */
  18371. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18372. /**
  18373. * Defines the camera the input is attached to.
  18374. */
  18375. camera: FreeCamera;
  18376. /**
  18377. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18378. */
  18379. keysUp: number[];
  18380. /**
  18381. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18382. */
  18383. keysUpward: number[];
  18384. /**
  18385. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18386. */
  18387. keysDown: number[];
  18388. /**
  18389. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18390. */
  18391. keysDownward: number[];
  18392. /**
  18393. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18394. */
  18395. keysLeft: number[];
  18396. /**
  18397. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18398. */
  18399. keysRight: number[];
  18400. private _keys;
  18401. private _onCanvasBlurObserver;
  18402. private _onKeyboardObserver;
  18403. private _engine;
  18404. private _scene;
  18405. /**
  18406. * Attach the input controls to a specific dom element to get the input from.
  18407. * @param element Defines the element the controls should be listened from
  18408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18409. */
  18410. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18411. /**
  18412. * Detach the current controls from the specified dom element.
  18413. * @param element Defines the element to stop listening the inputs from
  18414. */
  18415. detachControl(element: Nullable<HTMLElement>): void;
  18416. /**
  18417. * Update the current camera state depending on the inputs that have been used this frame.
  18418. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18419. */
  18420. checkInputs(): void;
  18421. /**
  18422. * Gets the class name of the current intput.
  18423. * @returns the class name
  18424. */
  18425. getClassName(): string;
  18426. /** @hidden */
  18427. _onLostFocus(): void;
  18428. /**
  18429. * Get the friendly name associated with the input class.
  18430. * @returns the input friendly name
  18431. */
  18432. getSimpleName(): string;
  18433. }
  18434. }
  18435. declare module BABYLON {
  18436. /**
  18437. * Gather the list of pointer event types as constants.
  18438. */
  18439. export class PointerEventTypes {
  18440. /**
  18441. * 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.
  18442. */
  18443. static readonly POINTERDOWN: number;
  18444. /**
  18445. * The pointerup event is fired when a pointer is no longer active.
  18446. */
  18447. static readonly POINTERUP: number;
  18448. /**
  18449. * The pointermove event is fired when a pointer changes coordinates.
  18450. */
  18451. static readonly POINTERMOVE: number;
  18452. /**
  18453. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18454. */
  18455. static readonly POINTERWHEEL: number;
  18456. /**
  18457. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18458. */
  18459. static readonly POINTERPICK: number;
  18460. /**
  18461. * The pointertap event is fired when a the object has been touched and released without drag.
  18462. */
  18463. static readonly POINTERTAP: number;
  18464. /**
  18465. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18466. */
  18467. static readonly POINTERDOUBLETAP: number;
  18468. }
  18469. /**
  18470. * Base class of pointer info types.
  18471. */
  18472. export class PointerInfoBase {
  18473. /**
  18474. * Defines the type of event (PointerEventTypes)
  18475. */
  18476. type: number;
  18477. /**
  18478. * Defines the related dom event
  18479. */
  18480. event: PointerEvent | MouseWheelEvent;
  18481. /**
  18482. * Instantiates the base class of pointers info.
  18483. * @param type Defines the type of event (PointerEventTypes)
  18484. * @param event Defines the related dom event
  18485. */
  18486. constructor(
  18487. /**
  18488. * Defines the type of event (PointerEventTypes)
  18489. */
  18490. type: number,
  18491. /**
  18492. * Defines the related dom event
  18493. */
  18494. event: PointerEvent | MouseWheelEvent);
  18495. }
  18496. /**
  18497. * This class is used to store pointer related info for the onPrePointerObservable event.
  18498. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18499. */
  18500. export class PointerInfoPre extends PointerInfoBase {
  18501. /**
  18502. * Ray from a pointer if availible (eg. 6dof controller)
  18503. */
  18504. ray: Nullable<Ray>;
  18505. /**
  18506. * Defines the local position of the pointer on the canvas.
  18507. */
  18508. localPosition: Vector2;
  18509. /**
  18510. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18511. */
  18512. skipOnPointerObservable: boolean;
  18513. /**
  18514. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18515. * @param type Defines the type of event (PointerEventTypes)
  18516. * @param event Defines the related dom event
  18517. * @param localX Defines the local x coordinates of the pointer when the event occured
  18518. * @param localY Defines the local y coordinates of the pointer when the event occured
  18519. */
  18520. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18521. }
  18522. /**
  18523. * This type contains all the data related to a pointer event in Babylon.js.
  18524. * 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.
  18525. */
  18526. export class PointerInfo extends PointerInfoBase {
  18527. /**
  18528. * Defines the picking info associated to the info (if any)\
  18529. */
  18530. pickInfo: Nullable<PickingInfo>;
  18531. /**
  18532. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18533. * @param type Defines the type of event (PointerEventTypes)
  18534. * @param event Defines the related dom event
  18535. * @param pickInfo Defines the picking info associated to the info (if any)\
  18536. */
  18537. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18538. /**
  18539. * Defines the picking info associated to the info (if any)\
  18540. */
  18541. pickInfo: Nullable<PickingInfo>);
  18542. }
  18543. /**
  18544. * Data relating to a touch event on the screen.
  18545. */
  18546. export interface PointerTouch {
  18547. /**
  18548. * X coordinate of touch.
  18549. */
  18550. x: number;
  18551. /**
  18552. * Y coordinate of touch.
  18553. */
  18554. y: number;
  18555. /**
  18556. * Id of touch. Unique for each finger.
  18557. */
  18558. pointerId: number;
  18559. /**
  18560. * Event type passed from DOM.
  18561. */
  18562. type: any;
  18563. }
  18564. }
  18565. declare module BABYLON {
  18566. /**
  18567. * Manage the mouse inputs to control the movement of a free camera.
  18568. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18569. */
  18570. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18571. /**
  18572. * Define if touch is enabled in the mouse input
  18573. */
  18574. touchEnabled: boolean;
  18575. /**
  18576. * Defines the camera the input is attached to.
  18577. */
  18578. camera: FreeCamera;
  18579. /**
  18580. * Defines the buttons associated with the input to handle camera move.
  18581. */
  18582. buttons: number[];
  18583. /**
  18584. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18585. */
  18586. angularSensibility: number;
  18587. private _pointerInput;
  18588. private _onMouseMove;
  18589. private _observer;
  18590. private previousPosition;
  18591. /**
  18592. * Observable for when a pointer move event occurs containing the move offset
  18593. */
  18594. onPointerMovedObservable: Observable<{
  18595. offsetX: number;
  18596. offsetY: number;
  18597. }>;
  18598. /**
  18599. * @hidden
  18600. * If the camera should be rotated automatically based on pointer movement
  18601. */
  18602. _allowCameraRotation: boolean;
  18603. /**
  18604. * Manage the mouse inputs to control the movement of a free camera.
  18605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18606. * @param touchEnabled Defines if touch is enabled or not
  18607. */
  18608. constructor(
  18609. /**
  18610. * Define if touch is enabled in the mouse input
  18611. */
  18612. touchEnabled?: boolean);
  18613. /**
  18614. * Attach the input controls to a specific dom element to get the input from.
  18615. * @param element Defines the element the controls should be listened from
  18616. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18617. */
  18618. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18619. /**
  18620. * Called on JS contextmenu event.
  18621. * Override this method to provide functionality.
  18622. */
  18623. protected onContextMenu(evt: PointerEvent): void;
  18624. /**
  18625. * Detach the current controls from the specified dom element.
  18626. * @param element Defines the element to stop listening the inputs from
  18627. */
  18628. detachControl(element: Nullable<HTMLElement>): void;
  18629. /**
  18630. * Gets the class name of the current intput.
  18631. * @returns the class name
  18632. */
  18633. getClassName(): string;
  18634. /**
  18635. * Get the friendly name associated with the input class.
  18636. * @returns the input friendly name
  18637. */
  18638. getSimpleName(): string;
  18639. }
  18640. }
  18641. declare module BABYLON {
  18642. /**
  18643. * Manage the touch inputs to control the movement of a free camera.
  18644. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18645. */
  18646. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18647. /**
  18648. * Defines the camera the input is attached to.
  18649. */
  18650. camera: FreeCamera;
  18651. /**
  18652. * Defines the touch sensibility for rotation.
  18653. * The higher the faster.
  18654. */
  18655. touchAngularSensibility: number;
  18656. /**
  18657. * Defines the touch sensibility for move.
  18658. * The higher the faster.
  18659. */
  18660. touchMoveSensibility: number;
  18661. private _offsetX;
  18662. private _offsetY;
  18663. private _pointerPressed;
  18664. private _pointerInput;
  18665. private _observer;
  18666. private _onLostFocus;
  18667. /**
  18668. * Attach the input controls to a specific dom element to get the input from.
  18669. * @param element Defines the element the controls should be listened from
  18670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18671. */
  18672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18673. /**
  18674. * Detach the current controls from the specified dom element.
  18675. * @param element Defines the element to stop listening the inputs from
  18676. */
  18677. detachControl(element: Nullable<HTMLElement>): void;
  18678. /**
  18679. * Update the current camera state depending on the inputs that have been used this frame.
  18680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18681. */
  18682. checkInputs(): void;
  18683. /**
  18684. * Gets the class name of the current intput.
  18685. * @returns the class name
  18686. */
  18687. getClassName(): string;
  18688. /**
  18689. * Get the friendly name associated with the input class.
  18690. * @returns the input friendly name
  18691. */
  18692. getSimpleName(): string;
  18693. }
  18694. }
  18695. declare module BABYLON {
  18696. /**
  18697. * Default Inputs manager for the FreeCamera.
  18698. * It groups all the default supported inputs for ease of use.
  18699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18700. */
  18701. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18702. /**
  18703. * @hidden
  18704. */
  18705. _mouseInput: Nullable<FreeCameraMouseInput>;
  18706. /**
  18707. * Instantiates a new FreeCameraInputsManager.
  18708. * @param camera Defines the camera the inputs belong to
  18709. */
  18710. constructor(camera: FreeCamera);
  18711. /**
  18712. * Add keyboard input support to the input manager.
  18713. * @returns the current input manager
  18714. */
  18715. addKeyboard(): FreeCameraInputsManager;
  18716. /**
  18717. * Add mouse input support to the input manager.
  18718. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18719. * @returns the current input manager
  18720. */
  18721. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18722. /**
  18723. * Removes the mouse input support from the manager
  18724. * @returns the current input manager
  18725. */
  18726. removeMouse(): FreeCameraInputsManager;
  18727. /**
  18728. * Add touch input support to the input manager.
  18729. * @returns the current input manager
  18730. */
  18731. addTouch(): FreeCameraInputsManager;
  18732. /**
  18733. * Remove all attached input methods from a camera
  18734. */
  18735. clear(): void;
  18736. }
  18737. }
  18738. declare module BABYLON {
  18739. /**
  18740. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18741. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18742. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18743. */
  18744. export class FreeCamera extends TargetCamera {
  18745. /**
  18746. * Define the collision ellipsoid of the camera.
  18747. * This is helpful to simulate a camera body like the player body around the camera
  18748. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18749. */
  18750. ellipsoid: Vector3;
  18751. /**
  18752. * Define an offset for the position of the ellipsoid around the camera.
  18753. * This can be helpful to determine the center of the body near the gravity center of the body
  18754. * instead of its head.
  18755. */
  18756. ellipsoidOffset: Vector3;
  18757. /**
  18758. * Enable or disable collisions of the camera with the rest of the scene objects.
  18759. */
  18760. checkCollisions: boolean;
  18761. /**
  18762. * Enable or disable gravity on the camera.
  18763. */
  18764. applyGravity: boolean;
  18765. /**
  18766. * Define the input manager associated to the camera.
  18767. */
  18768. inputs: FreeCameraInputsManager;
  18769. /**
  18770. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18771. * Higher values reduce sensitivity.
  18772. */
  18773. get angularSensibility(): number;
  18774. /**
  18775. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18776. * Higher values reduce sensitivity.
  18777. */
  18778. set angularSensibility(value: number);
  18779. /**
  18780. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18781. */
  18782. get keysUp(): number[];
  18783. set keysUp(value: number[]);
  18784. /**
  18785. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18786. */
  18787. get keysUpward(): number[];
  18788. set keysUpward(value: number[]);
  18789. /**
  18790. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18791. */
  18792. get keysDown(): number[];
  18793. set keysDown(value: number[]);
  18794. /**
  18795. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18796. */
  18797. get keysDownward(): number[];
  18798. set keysDownward(value: number[]);
  18799. /**
  18800. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18801. */
  18802. get keysLeft(): number[];
  18803. set keysLeft(value: number[]);
  18804. /**
  18805. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18806. */
  18807. get keysRight(): number[];
  18808. set keysRight(value: number[]);
  18809. /**
  18810. * Event raised when the camera collide with a mesh in the scene.
  18811. */
  18812. onCollide: (collidedMesh: AbstractMesh) => void;
  18813. private _collider;
  18814. private _needMoveForGravity;
  18815. private _oldPosition;
  18816. private _diffPosition;
  18817. private _newPosition;
  18818. /** @hidden */
  18819. _localDirection: Vector3;
  18820. /** @hidden */
  18821. _transformedDirection: Vector3;
  18822. /**
  18823. * Instantiates a Free Camera.
  18824. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18825. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18826. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18827. * @param name Define the name of the camera in the scene
  18828. * @param position Define the start position of the camera in the scene
  18829. * @param scene Define the scene the camera belongs to
  18830. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18831. */
  18832. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18833. /**
  18834. * Attached controls to the current camera.
  18835. * @param element Defines the element the controls should be listened from
  18836. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18837. */
  18838. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18839. /**
  18840. * Detach the current controls from the camera.
  18841. * The camera will stop reacting to inputs.
  18842. * @param element Defines the element to stop listening the inputs from
  18843. */
  18844. detachControl(element: HTMLElement): void;
  18845. private _collisionMask;
  18846. /**
  18847. * Define a collision mask to limit the list of object the camera can collide with
  18848. */
  18849. get collisionMask(): number;
  18850. set collisionMask(mask: number);
  18851. /** @hidden */
  18852. _collideWithWorld(displacement: Vector3): void;
  18853. private _onCollisionPositionChange;
  18854. /** @hidden */
  18855. _checkInputs(): void;
  18856. /** @hidden */
  18857. _decideIfNeedsToMove(): boolean;
  18858. /** @hidden */
  18859. _updatePosition(): void;
  18860. /**
  18861. * Destroy the camera and release the current resources hold by it.
  18862. */
  18863. dispose(): void;
  18864. /**
  18865. * Gets the current object class name.
  18866. * @return the class name
  18867. */
  18868. getClassName(): string;
  18869. }
  18870. }
  18871. declare module BABYLON {
  18872. /**
  18873. * Represents a gamepad control stick position
  18874. */
  18875. export class StickValues {
  18876. /**
  18877. * The x component of the control stick
  18878. */
  18879. x: number;
  18880. /**
  18881. * The y component of the control stick
  18882. */
  18883. y: number;
  18884. /**
  18885. * Initializes the gamepad x and y control stick values
  18886. * @param x The x component of the gamepad control stick value
  18887. * @param y The y component of the gamepad control stick value
  18888. */
  18889. constructor(
  18890. /**
  18891. * The x component of the control stick
  18892. */
  18893. x: number,
  18894. /**
  18895. * The y component of the control stick
  18896. */
  18897. y: number);
  18898. }
  18899. /**
  18900. * An interface which manages callbacks for gamepad button changes
  18901. */
  18902. export interface GamepadButtonChanges {
  18903. /**
  18904. * Called when a gamepad has been changed
  18905. */
  18906. changed: boolean;
  18907. /**
  18908. * Called when a gamepad press event has been triggered
  18909. */
  18910. pressChanged: boolean;
  18911. /**
  18912. * Called when a touch event has been triggered
  18913. */
  18914. touchChanged: boolean;
  18915. /**
  18916. * Called when a value has changed
  18917. */
  18918. valueChanged: boolean;
  18919. }
  18920. /**
  18921. * Represents a gamepad
  18922. */
  18923. export class Gamepad {
  18924. /**
  18925. * The id of the gamepad
  18926. */
  18927. id: string;
  18928. /**
  18929. * The index of the gamepad
  18930. */
  18931. index: number;
  18932. /**
  18933. * The browser gamepad
  18934. */
  18935. browserGamepad: any;
  18936. /**
  18937. * Specifies what type of gamepad this represents
  18938. */
  18939. type: number;
  18940. private _leftStick;
  18941. private _rightStick;
  18942. /** @hidden */
  18943. _isConnected: boolean;
  18944. private _leftStickAxisX;
  18945. private _leftStickAxisY;
  18946. private _rightStickAxisX;
  18947. private _rightStickAxisY;
  18948. /**
  18949. * Triggered when the left control stick has been changed
  18950. */
  18951. private _onleftstickchanged;
  18952. /**
  18953. * Triggered when the right control stick has been changed
  18954. */
  18955. private _onrightstickchanged;
  18956. /**
  18957. * Represents a gamepad controller
  18958. */
  18959. static GAMEPAD: number;
  18960. /**
  18961. * Represents a generic controller
  18962. */
  18963. static GENERIC: number;
  18964. /**
  18965. * Represents an XBox controller
  18966. */
  18967. static XBOX: number;
  18968. /**
  18969. * Represents a pose-enabled controller
  18970. */
  18971. static POSE_ENABLED: number;
  18972. /**
  18973. * Represents an Dual Shock controller
  18974. */
  18975. static DUALSHOCK: number;
  18976. /**
  18977. * Specifies whether the left control stick should be Y-inverted
  18978. */
  18979. protected _invertLeftStickY: boolean;
  18980. /**
  18981. * Specifies if the gamepad has been connected
  18982. */
  18983. get isConnected(): boolean;
  18984. /**
  18985. * Initializes the gamepad
  18986. * @param id The id of the gamepad
  18987. * @param index The index of the gamepad
  18988. * @param browserGamepad The browser gamepad
  18989. * @param leftStickX The x component of the left joystick
  18990. * @param leftStickY The y component of the left joystick
  18991. * @param rightStickX The x component of the right joystick
  18992. * @param rightStickY The y component of the right joystick
  18993. */
  18994. constructor(
  18995. /**
  18996. * The id of the gamepad
  18997. */
  18998. id: string,
  18999. /**
  19000. * The index of the gamepad
  19001. */
  19002. index: number,
  19003. /**
  19004. * The browser gamepad
  19005. */
  19006. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19007. /**
  19008. * Callback triggered when the left joystick has changed
  19009. * @param callback
  19010. */
  19011. onleftstickchanged(callback: (values: StickValues) => void): void;
  19012. /**
  19013. * Callback triggered when the right joystick has changed
  19014. * @param callback
  19015. */
  19016. onrightstickchanged(callback: (values: StickValues) => void): void;
  19017. /**
  19018. * Gets the left joystick
  19019. */
  19020. get leftStick(): StickValues;
  19021. /**
  19022. * Sets the left joystick values
  19023. */
  19024. set leftStick(newValues: StickValues);
  19025. /**
  19026. * Gets the right joystick
  19027. */
  19028. get rightStick(): StickValues;
  19029. /**
  19030. * Sets the right joystick value
  19031. */
  19032. set rightStick(newValues: StickValues);
  19033. /**
  19034. * Updates the gamepad joystick positions
  19035. */
  19036. update(): void;
  19037. /**
  19038. * Disposes the gamepad
  19039. */
  19040. dispose(): void;
  19041. }
  19042. /**
  19043. * Represents a generic gamepad
  19044. */
  19045. export class GenericPad extends Gamepad {
  19046. private _buttons;
  19047. private _onbuttondown;
  19048. private _onbuttonup;
  19049. /**
  19050. * Observable triggered when a button has been pressed
  19051. */
  19052. onButtonDownObservable: Observable<number>;
  19053. /**
  19054. * Observable triggered when a button has been released
  19055. */
  19056. onButtonUpObservable: Observable<number>;
  19057. /**
  19058. * Callback triggered when a button has been pressed
  19059. * @param callback Called when a button has been pressed
  19060. */
  19061. onbuttondown(callback: (buttonPressed: number) => void): void;
  19062. /**
  19063. * Callback triggered when a button has been released
  19064. * @param callback Called when a button has been released
  19065. */
  19066. onbuttonup(callback: (buttonReleased: number) => void): void;
  19067. /**
  19068. * Initializes the generic gamepad
  19069. * @param id The id of the generic gamepad
  19070. * @param index The index of the generic gamepad
  19071. * @param browserGamepad The browser gamepad
  19072. */
  19073. constructor(id: string, index: number, browserGamepad: any);
  19074. private _setButtonValue;
  19075. /**
  19076. * Updates the generic gamepad
  19077. */
  19078. update(): void;
  19079. /**
  19080. * Disposes the generic gamepad
  19081. */
  19082. dispose(): void;
  19083. }
  19084. }
  19085. declare module BABYLON {
  19086. /**
  19087. * Defines the types of pose enabled controllers that are supported
  19088. */
  19089. export enum PoseEnabledControllerType {
  19090. /**
  19091. * HTC Vive
  19092. */
  19093. VIVE = 0,
  19094. /**
  19095. * Oculus Rift
  19096. */
  19097. OCULUS = 1,
  19098. /**
  19099. * Windows mixed reality
  19100. */
  19101. WINDOWS = 2,
  19102. /**
  19103. * Samsung gear VR
  19104. */
  19105. GEAR_VR = 3,
  19106. /**
  19107. * Google Daydream
  19108. */
  19109. DAYDREAM = 4,
  19110. /**
  19111. * Generic
  19112. */
  19113. GENERIC = 5
  19114. }
  19115. /**
  19116. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19117. */
  19118. export interface MutableGamepadButton {
  19119. /**
  19120. * Value of the button/trigger
  19121. */
  19122. value: number;
  19123. /**
  19124. * If the button/trigger is currently touched
  19125. */
  19126. touched: boolean;
  19127. /**
  19128. * If the button/trigger is currently pressed
  19129. */
  19130. pressed: boolean;
  19131. }
  19132. /**
  19133. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19134. * @hidden
  19135. */
  19136. export interface ExtendedGamepadButton extends GamepadButton {
  19137. /**
  19138. * If the button/trigger is currently pressed
  19139. */
  19140. readonly pressed: boolean;
  19141. /**
  19142. * If the button/trigger is currently touched
  19143. */
  19144. readonly touched: boolean;
  19145. /**
  19146. * Value of the button/trigger
  19147. */
  19148. readonly value: number;
  19149. }
  19150. /** @hidden */
  19151. export interface _GamePadFactory {
  19152. /**
  19153. * Returns whether or not the current gamepad can be created for this type of controller.
  19154. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19155. * @returns true if it can be created, otherwise false
  19156. */
  19157. canCreate(gamepadInfo: any): boolean;
  19158. /**
  19159. * Creates a new instance of the Gamepad.
  19160. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19161. * @returns the new gamepad instance
  19162. */
  19163. create(gamepadInfo: any): Gamepad;
  19164. }
  19165. /**
  19166. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19167. */
  19168. export class PoseEnabledControllerHelper {
  19169. /** @hidden */
  19170. static _ControllerFactories: _GamePadFactory[];
  19171. /** @hidden */
  19172. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19173. /**
  19174. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19175. * @param vrGamepad the gamepad to initialized
  19176. * @returns a vr controller of the type the gamepad identified as
  19177. */
  19178. static InitiateController(vrGamepad: any): Gamepad;
  19179. }
  19180. /**
  19181. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19182. */
  19183. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19184. /**
  19185. * If the controller is used in a webXR session
  19186. */
  19187. isXR: boolean;
  19188. private _deviceRoomPosition;
  19189. private _deviceRoomRotationQuaternion;
  19190. /**
  19191. * The device position in babylon space
  19192. */
  19193. devicePosition: Vector3;
  19194. /**
  19195. * The device rotation in babylon space
  19196. */
  19197. deviceRotationQuaternion: Quaternion;
  19198. /**
  19199. * The scale factor of the device in babylon space
  19200. */
  19201. deviceScaleFactor: number;
  19202. /**
  19203. * (Likely devicePosition should be used instead) The device position in its room space
  19204. */
  19205. position: Vector3;
  19206. /**
  19207. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19208. */
  19209. rotationQuaternion: Quaternion;
  19210. /**
  19211. * The type of controller (Eg. Windows mixed reality)
  19212. */
  19213. controllerType: PoseEnabledControllerType;
  19214. protected _calculatedPosition: Vector3;
  19215. private _calculatedRotation;
  19216. /**
  19217. * The raw pose from the device
  19218. */
  19219. rawPose: DevicePose;
  19220. private _trackPosition;
  19221. private _maxRotationDistFromHeadset;
  19222. private _draggedRoomRotation;
  19223. /**
  19224. * @hidden
  19225. */
  19226. _disableTrackPosition(fixedPosition: Vector3): void;
  19227. /**
  19228. * Internal, the mesh attached to the controller
  19229. * @hidden
  19230. */
  19231. _mesh: Nullable<AbstractMesh>;
  19232. private _poseControlledCamera;
  19233. private _leftHandSystemQuaternion;
  19234. /**
  19235. * Internal, matrix used to convert room space to babylon space
  19236. * @hidden
  19237. */
  19238. _deviceToWorld: Matrix;
  19239. /**
  19240. * Node to be used when casting a ray from the controller
  19241. * @hidden
  19242. */
  19243. _pointingPoseNode: Nullable<TransformNode>;
  19244. /**
  19245. * Name of the child mesh that can be used to cast a ray from the controller
  19246. */
  19247. static readonly POINTING_POSE: string;
  19248. /**
  19249. * Creates a new PoseEnabledController from a gamepad
  19250. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19251. */
  19252. constructor(browserGamepad: any);
  19253. private _workingMatrix;
  19254. /**
  19255. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19256. */
  19257. update(): void;
  19258. /**
  19259. * Updates only the pose device and mesh without doing any button event checking
  19260. */
  19261. protected _updatePoseAndMesh(): void;
  19262. /**
  19263. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19264. * @param poseData raw pose fromthe device
  19265. */
  19266. updateFromDevice(poseData: DevicePose): void;
  19267. /**
  19268. * @hidden
  19269. */
  19270. _meshAttachedObservable: Observable<AbstractMesh>;
  19271. /**
  19272. * Attaches a mesh to the controller
  19273. * @param mesh the mesh to be attached
  19274. */
  19275. attachToMesh(mesh: AbstractMesh): void;
  19276. /**
  19277. * Attaches the controllers mesh to a camera
  19278. * @param camera the camera the mesh should be attached to
  19279. */
  19280. attachToPoseControlledCamera(camera: TargetCamera): void;
  19281. /**
  19282. * Disposes of the controller
  19283. */
  19284. dispose(): void;
  19285. /**
  19286. * The mesh that is attached to the controller
  19287. */
  19288. get mesh(): Nullable<AbstractMesh>;
  19289. /**
  19290. * Gets the ray of the controller in the direction the controller is pointing
  19291. * @param length the length the resulting ray should be
  19292. * @returns a ray in the direction the controller is pointing
  19293. */
  19294. getForwardRay(length?: number): Ray;
  19295. }
  19296. }
  19297. declare module BABYLON {
  19298. /**
  19299. * Defines the WebVRController object that represents controllers tracked in 3D space
  19300. */
  19301. export abstract class WebVRController extends PoseEnabledController {
  19302. /**
  19303. * Internal, the default controller model for the controller
  19304. */
  19305. protected _defaultModel: Nullable<AbstractMesh>;
  19306. /**
  19307. * Fired when the trigger state has changed
  19308. */
  19309. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19310. /**
  19311. * Fired when the main button state has changed
  19312. */
  19313. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19314. /**
  19315. * Fired when the secondary button state has changed
  19316. */
  19317. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19318. /**
  19319. * Fired when the pad state has changed
  19320. */
  19321. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19322. /**
  19323. * Fired when controllers stick values have changed
  19324. */
  19325. onPadValuesChangedObservable: Observable<StickValues>;
  19326. /**
  19327. * Array of button availible on the controller
  19328. */
  19329. protected _buttons: Array<MutableGamepadButton>;
  19330. private _onButtonStateChange;
  19331. /**
  19332. * Fired when a controller button's state has changed
  19333. * @param callback the callback containing the button that was modified
  19334. */
  19335. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19336. /**
  19337. * X and Y axis corresponding to the controllers joystick
  19338. */
  19339. pad: StickValues;
  19340. /**
  19341. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19342. */
  19343. hand: string;
  19344. /**
  19345. * The default controller model for the controller
  19346. */
  19347. get defaultModel(): Nullable<AbstractMesh>;
  19348. /**
  19349. * Creates a new WebVRController from a gamepad
  19350. * @param vrGamepad the gamepad that the WebVRController should be created from
  19351. */
  19352. constructor(vrGamepad: any);
  19353. /**
  19354. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19355. */
  19356. update(): void;
  19357. /**
  19358. * Function to be called when a button is modified
  19359. */
  19360. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19361. /**
  19362. * Loads a mesh and attaches it to the controller
  19363. * @param scene the scene the mesh should be added to
  19364. * @param meshLoaded callback for when the mesh has been loaded
  19365. */
  19366. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19367. private _setButtonValue;
  19368. private _changes;
  19369. private _checkChanges;
  19370. /**
  19371. * Disposes of th webVRCOntroller
  19372. */
  19373. dispose(): void;
  19374. }
  19375. }
  19376. declare module BABYLON {
  19377. /**
  19378. * The HemisphericLight simulates the ambient environment light,
  19379. * so the passed direction is the light reflection direction, not the incoming direction.
  19380. */
  19381. export class HemisphericLight extends Light {
  19382. /**
  19383. * The groundColor is the light in the opposite direction to the one specified during creation.
  19384. * 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.
  19385. */
  19386. groundColor: Color3;
  19387. /**
  19388. * The light reflection direction, not the incoming direction.
  19389. */
  19390. direction: Vector3;
  19391. /**
  19392. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19393. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19394. * The HemisphericLight can't cast shadows.
  19395. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19396. * @param name The friendly name of the light
  19397. * @param direction The direction of the light reflection
  19398. * @param scene The scene the light belongs to
  19399. */
  19400. constructor(name: string, direction: Vector3, scene: Scene);
  19401. protected _buildUniformLayout(): void;
  19402. /**
  19403. * Returns the string "HemisphericLight".
  19404. * @return The class name
  19405. */
  19406. getClassName(): string;
  19407. /**
  19408. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19409. * Returns the updated direction.
  19410. * @param target The target the direction should point to
  19411. * @return The computed direction
  19412. */
  19413. setDirectionToTarget(target: Vector3): Vector3;
  19414. /**
  19415. * Returns the shadow generator associated to the light.
  19416. * @returns Always null for hemispheric lights because it does not support shadows.
  19417. */
  19418. getShadowGenerator(): Nullable<IShadowGenerator>;
  19419. /**
  19420. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19421. * @param effect The effect to update
  19422. * @param lightIndex The index of the light in the effect to update
  19423. * @returns The hemispheric light
  19424. */
  19425. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19426. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19427. /**
  19428. * Computes the world matrix of the node
  19429. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19430. * @param useWasUpdatedFlag defines a reserved property
  19431. * @returns the world matrix
  19432. */
  19433. computeWorldMatrix(): Matrix;
  19434. /**
  19435. * Returns the integer 3.
  19436. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19437. */
  19438. getTypeID(): number;
  19439. /**
  19440. * Prepares the list of defines specific to the light type.
  19441. * @param defines the list of defines
  19442. * @param lightIndex defines the index of the light for the effect
  19443. */
  19444. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19445. }
  19446. }
  19447. declare module BABYLON {
  19448. /** @hidden */
  19449. export var vrMultiviewToSingleviewPixelShader: {
  19450. name: string;
  19451. shader: string;
  19452. };
  19453. }
  19454. declare module BABYLON {
  19455. /**
  19456. * Renders to multiple views with a single draw call
  19457. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19458. */
  19459. export class MultiviewRenderTarget extends RenderTargetTexture {
  19460. /**
  19461. * Creates a multiview render target
  19462. * @param scene scene used with the render target
  19463. * @param size the size of the render target (used for each view)
  19464. */
  19465. constructor(scene: Scene, size?: number | {
  19466. width: number;
  19467. height: number;
  19468. } | {
  19469. ratio: number;
  19470. });
  19471. /**
  19472. * @hidden
  19473. * @param faceIndex the face index, if its a cube texture
  19474. */
  19475. _bindFrameBuffer(faceIndex?: number): void;
  19476. /**
  19477. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19478. * @returns the view count
  19479. */
  19480. getViewCount(): number;
  19481. }
  19482. }
  19483. declare module BABYLON {
  19484. interface Engine {
  19485. /**
  19486. * Creates a new multiview render target
  19487. * @param width defines the width of the texture
  19488. * @param height defines the height of the texture
  19489. * @returns the created multiview texture
  19490. */
  19491. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19492. /**
  19493. * Binds a multiview framebuffer to be drawn to
  19494. * @param multiviewTexture texture to bind
  19495. */
  19496. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19497. }
  19498. interface Camera {
  19499. /**
  19500. * @hidden
  19501. * 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)
  19502. */
  19503. _useMultiviewToSingleView: boolean;
  19504. /**
  19505. * @hidden
  19506. * 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)
  19507. */
  19508. _multiviewTexture: Nullable<RenderTargetTexture>;
  19509. /**
  19510. * @hidden
  19511. * ensures the multiview texture of the camera exists and has the specified width/height
  19512. * @param width height to set on the multiview texture
  19513. * @param height width to set on the multiview texture
  19514. */
  19515. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19516. }
  19517. interface Scene {
  19518. /** @hidden */
  19519. _transformMatrixR: Matrix;
  19520. /** @hidden */
  19521. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19522. /** @hidden */
  19523. _createMultiviewUbo(): void;
  19524. /** @hidden */
  19525. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19526. /** @hidden */
  19527. _renderMultiviewToSingleView(camera: Camera): void;
  19528. }
  19529. }
  19530. declare module BABYLON {
  19531. /**
  19532. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19533. * This will not be used for webXR as it supports displaying texture arrays directly
  19534. */
  19535. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19536. /**
  19537. * Initializes a VRMultiviewToSingleview
  19538. * @param name name of the post process
  19539. * @param camera camera to be applied to
  19540. * @param scaleFactor scaling factor to the size of the output texture
  19541. */
  19542. constructor(name: string, camera: Camera, scaleFactor: number);
  19543. }
  19544. }
  19545. declare module BABYLON {
  19546. /**
  19547. * Interface used to define additional presentation attributes
  19548. */
  19549. export interface IVRPresentationAttributes {
  19550. /**
  19551. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19552. */
  19553. highRefreshRate: boolean;
  19554. /**
  19555. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19556. */
  19557. foveationLevel: number;
  19558. }
  19559. interface Engine {
  19560. /** @hidden */
  19561. _vrDisplay: any;
  19562. /** @hidden */
  19563. _vrSupported: boolean;
  19564. /** @hidden */
  19565. _oldSize: Size;
  19566. /** @hidden */
  19567. _oldHardwareScaleFactor: number;
  19568. /** @hidden */
  19569. _vrExclusivePointerMode: boolean;
  19570. /** @hidden */
  19571. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19572. /** @hidden */
  19573. _onVRDisplayPointerRestricted: () => void;
  19574. /** @hidden */
  19575. _onVRDisplayPointerUnrestricted: () => void;
  19576. /** @hidden */
  19577. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19578. /** @hidden */
  19579. _onVrDisplayDisconnect: Nullable<() => void>;
  19580. /** @hidden */
  19581. _onVrDisplayPresentChange: Nullable<() => void>;
  19582. /**
  19583. * Observable signaled when VR display mode changes
  19584. */
  19585. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19586. /**
  19587. * Observable signaled when VR request present is complete
  19588. */
  19589. onVRRequestPresentComplete: Observable<boolean>;
  19590. /**
  19591. * Observable signaled when VR request present starts
  19592. */
  19593. onVRRequestPresentStart: Observable<Engine>;
  19594. /**
  19595. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19596. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19597. */
  19598. isInVRExclusivePointerMode: boolean;
  19599. /**
  19600. * Gets a boolean indicating if a webVR device was detected
  19601. * @returns true if a webVR device was detected
  19602. */
  19603. isVRDevicePresent(): boolean;
  19604. /**
  19605. * Gets the current webVR device
  19606. * @returns the current webVR device (or null)
  19607. */
  19608. getVRDevice(): any;
  19609. /**
  19610. * Initializes a webVR display and starts listening to display change events
  19611. * The onVRDisplayChangedObservable will be notified upon these changes
  19612. * @returns A promise containing a VRDisplay and if vr is supported
  19613. */
  19614. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19615. /** @hidden */
  19616. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19617. /**
  19618. * Gets or sets the presentation attributes used to configure VR rendering
  19619. */
  19620. vrPresentationAttributes?: IVRPresentationAttributes;
  19621. /**
  19622. * Call this function to switch to webVR mode
  19623. * Will do nothing if webVR is not supported or if there is no webVR device
  19624. * @param options the webvr options provided to the camera. mainly used for multiview
  19625. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19626. */
  19627. enableVR(options: WebVROptions): void;
  19628. /** @hidden */
  19629. _onVRFullScreenTriggered(): void;
  19630. }
  19631. }
  19632. declare module BABYLON {
  19633. /**
  19634. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19635. * IMPORTANT!! The data is right-hand data.
  19636. * @export
  19637. * @interface DevicePose
  19638. */
  19639. export interface DevicePose {
  19640. /**
  19641. * The position of the device, values in array are [x,y,z].
  19642. */
  19643. readonly position: Nullable<Float32Array>;
  19644. /**
  19645. * The linearVelocity of the device, values in array are [x,y,z].
  19646. */
  19647. readonly linearVelocity: Nullable<Float32Array>;
  19648. /**
  19649. * The linearAcceleration of the device, values in array are [x,y,z].
  19650. */
  19651. readonly linearAcceleration: Nullable<Float32Array>;
  19652. /**
  19653. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19654. */
  19655. readonly orientation: Nullable<Float32Array>;
  19656. /**
  19657. * The angularVelocity of the device, values in array are [x,y,z].
  19658. */
  19659. readonly angularVelocity: Nullable<Float32Array>;
  19660. /**
  19661. * The angularAcceleration of the device, values in array are [x,y,z].
  19662. */
  19663. readonly angularAcceleration: Nullable<Float32Array>;
  19664. }
  19665. /**
  19666. * Interface representing a pose controlled object in Babylon.
  19667. * A pose controlled object has both regular pose values as well as pose values
  19668. * from an external device such as a VR head mounted display
  19669. */
  19670. export interface PoseControlled {
  19671. /**
  19672. * The position of the object in babylon space.
  19673. */
  19674. position: Vector3;
  19675. /**
  19676. * The rotation quaternion of the object in babylon space.
  19677. */
  19678. rotationQuaternion: Quaternion;
  19679. /**
  19680. * The position of the device in babylon space.
  19681. */
  19682. devicePosition?: Vector3;
  19683. /**
  19684. * The rotation quaternion of the device in babylon space.
  19685. */
  19686. deviceRotationQuaternion: Quaternion;
  19687. /**
  19688. * The raw pose coming from the device.
  19689. */
  19690. rawPose: Nullable<DevicePose>;
  19691. /**
  19692. * The scale of the device to be used when translating from device space to babylon space.
  19693. */
  19694. deviceScaleFactor: number;
  19695. /**
  19696. * Updates the poseControlled values based on the input device pose.
  19697. * @param poseData the pose data to update the object with
  19698. */
  19699. updateFromDevice(poseData: DevicePose): void;
  19700. }
  19701. /**
  19702. * Set of options to customize the webVRCamera
  19703. */
  19704. export interface WebVROptions {
  19705. /**
  19706. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19707. */
  19708. trackPosition?: boolean;
  19709. /**
  19710. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19711. */
  19712. positionScale?: number;
  19713. /**
  19714. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19715. */
  19716. displayName?: string;
  19717. /**
  19718. * Should the native controller meshes be initialized. (default: true)
  19719. */
  19720. controllerMeshes?: boolean;
  19721. /**
  19722. * Creating a default HemiLight only on controllers. (default: true)
  19723. */
  19724. defaultLightingOnControllers?: boolean;
  19725. /**
  19726. * If you don't want to use the default VR button of the helper. (default: false)
  19727. */
  19728. useCustomVRButton?: boolean;
  19729. /**
  19730. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19731. */
  19732. customVRButton?: HTMLButtonElement;
  19733. /**
  19734. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19735. */
  19736. rayLength?: number;
  19737. /**
  19738. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19739. */
  19740. defaultHeight?: number;
  19741. /**
  19742. * If multiview should be used if availible (default: false)
  19743. */
  19744. useMultiview?: boolean;
  19745. }
  19746. /**
  19747. * This represents a WebVR camera.
  19748. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19749. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19750. */
  19751. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19752. private webVROptions;
  19753. /**
  19754. * @hidden
  19755. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19756. */
  19757. _vrDevice: any;
  19758. /**
  19759. * The rawPose of the vrDevice.
  19760. */
  19761. rawPose: Nullable<DevicePose>;
  19762. private _onVREnabled;
  19763. private _specsVersion;
  19764. private _attached;
  19765. private _frameData;
  19766. protected _descendants: Array<Node>;
  19767. private _deviceRoomPosition;
  19768. /** @hidden */
  19769. _deviceRoomRotationQuaternion: Quaternion;
  19770. private _standingMatrix;
  19771. /**
  19772. * Represents device position in babylon space.
  19773. */
  19774. devicePosition: Vector3;
  19775. /**
  19776. * Represents device rotation in babylon space.
  19777. */
  19778. deviceRotationQuaternion: Quaternion;
  19779. /**
  19780. * The scale of the device to be used when translating from device space to babylon space.
  19781. */
  19782. deviceScaleFactor: number;
  19783. private _deviceToWorld;
  19784. private _worldToDevice;
  19785. /**
  19786. * References to the webVR controllers for the vrDevice.
  19787. */
  19788. controllers: Array<WebVRController>;
  19789. /**
  19790. * Emits an event when a controller is attached.
  19791. */
  19792. onControllersAttachedObservable: Observable<WebVRController[]>;
  19793. /**
  19794. * Emits an event when a controller's mesh has been loaded;
  19795. */
  19796. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19797. /**
  19798. * Emits an event when the HMD's pose has been updated.
  19799. */
  19800. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19801. private _poseSet;
  19802. /**
  19803. * If the rig cameras be used as parent instead of this camera.
  19804. */
  19805. rigParenting: boolean;
  19806. private _lightOnControllers;
  19807. private _defaultHeight?;
  19808. /**
  19809. * Instantiates a WebVRFreeCamera.
  19810. * @param name The name of the WebVRFreeCamera
  19811. * @param position The starting anchor position for the camera
  19812. * @param scene The scene the camera belongs to
  19813. * @param webVROptions a set of customizable options for the webVRCamera
  19814. */
  19815. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19816. /**
  19817. * Gets the device distance from the ground in meters.
  19818. * @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.
  19819. */
  19820. deviceDistanceToRoomGround(): number;
  19821. /**
  19822. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19823. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19824. */
  19825. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19826. /**
  19827. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19828. * @returns A promise with a boolean set to if the standing matrix is supported.
  19829. */
  19830. useStandingMatrixAsync(): Promise<boolean>;
  19831. /**
  19832. * Disposes the camera
  19833. */
  19834. dispose(): void;
  19835. /**
  19836. * Gets a vrController by name.
  19837. * @param name The name of the controller to retreive
  19838. * @returns the controller matching the name specified or null if not found
  19839. */
  19840. getControllerByName(name: string): Nullable<WebVRController>;
  19841. private _leftController;
  19842. /**
  19843. * The controller corresponding to the users left hand.
  19844. */
  19845. get leftController(): Nullable<WebVRController>;
  19846. private _rightController;
  19847. /**
  19848. * The controller corresponding to the users right hand.
  19849. */
  19850. get rightController(): Nullable<WebVRController>;
  19851. /**
  19852. * Casts a ray forward from the vrCamera's gaze.
  19853. * @param length Length of the ray (default: 100)
  19854. * @returns the ray corresponding to the gaze
  19855. */
  19856. getForwardRay(length?: number): Ray;
  19857. /**
  19858. * @hidden
  19859. * Updates the camera based on device's frame data
  19860. */
  19861. _checkInputs(): void;
  19862. /**
  19863. * Updates the poseControlled values based on the input device pose.
  19864. * @param poseData Pose coming from the device
  19865. */
  19866. updateFromDevice(poseData: DevicePose): void;
  19867. private _htmlElementAttached;
  19868. private _detachIfAttached;
  19869. /**
  19870. * WebVR's attach control will start broadcasting frames to the device.
  19871. * Note that in certain browsers (chrome for example) this function must be called
  19872. * within a user-interaction callback. Example:
  19873. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19874. *
  19875. * @param element html element to attach the vrDevice to
  19876. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19877. */
  19878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19879. /**
  19880. * Detaches the camera from the html element and disables VR
  19881. *
  19882. * @param element html element to detach from
  19883. */
  19884. detachControl(element: HTMLElement): void;
  19885. /**
  19886. * @returns the name of this class
  19887. */
  19888. getClassName(): string;
  19889. /**
  19890. * Calls resetPose on the vrDisplay
  19891. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19892. */
  19893. resetToCurrentRotation(): void;
  19894. /**
  19895. * @hidden
  19896. * Updates the rig cameras (left and right eye)
  19897. */
  19898. _updateRigCameras(): void;
  19899. private _workingVector;
  19900. private _oneVector;
  19901. private _workingMatrix;
  19902. private updateCacheCalled;
  19903. private _correctPositionIfNotTrackPosition;
  19904. /**
  19905. * @hidden
  19906. * Updates the cached values of the camera
  19907. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19908. */
  19909. _updateCache(ignoreParentClass?: boolean): void;
  19910. /**
  19911. * @hidden
  19912. * Get current device position in babylon world
  19913. */
  19914. _computeDevicePosition(): void;
  19915. /**
  19916. * Updates the current device position and rotation in the babylon world
  19917. */
  19918. update(): void;
  19919. /**
  19920. * @hidden
  19921. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19922. * @returns an identity matrix
  19923. */
  19924. _getViewMatrix(): Matrix;
  19925. private _tmpMatrix;
  19926. /**
  19927. * This function is called by the two RIG cameras.
  19928. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19929. * @hidden
  19930. */
  19931. _getWebVRViewMatrix(): Matrix;
  19932. /** @hidden */
  19933. _getWebVRProjectionMatrix(): Matrix;
  19934. private _onGamepadConnectedObserver;
  19935. private _onGamepadDisconnectedObserver;
  19936. private _updateCacheWhenTrackingDisabledObserver;
  19937. /**
  19938. * Initializes the controllers and their meshes
  19939. */
  19940. initControllers(): void;
  19941. }
  19942. }
  19943. declare module BABYLON {
  19944. /**
  19945. * "Static Class" containing the most commonly used helper while dealing with material for
  19946. * rendering purpose.
  19947. *
  19948. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19949. *
  19950. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19951. */
  19952. export class MaterialHelper {
  19953. /**
  19954. * Bind the current view position to an effect.
  19955. * @param effect The effect to be bound
  19956. * @param scene The scene the eyes position is used from
  19957. * @param variableName name of the shader variable that will hold the eye position
  19958. */
  19959. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19960. /**
  19961. * Helps preparing the defines values about the UVs in used in the effect.
  19962. * UVs are shared as much as we can accross channels in the shaders.
  19963. * @param texture The texture we are preparing the UVs for
  19964. * @param defines The defines to update
  19965. * @param key The channel key "diffuse", "specular"... used in the shader
  19966. */
  19967. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19968. /**
  19969. * Binds a texture matrix value to its corrsponding uniform
  19970. * @param texture The texture to bind the matrix for
  19971. * @param uniformBuffer The uniform buffer receivin the data
  19972. * @param key The channel key "diffuse", "specular"... used in the shader
  19973. */
  19974. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19975. /**
  19976. * Gets the current status of the fog (should it be enabled?)
  19977. * @param mesh defines the mesh to evaluate for fog support
  19978. * @param scene defines the hosting scene
  19979. * @returns true if fog must be enabled
  19980. */
  19981. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  19982. /**
  19983. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  19984. * @param mesh defines the current mesh
  19985. * @param scene defines the current scene
  19986. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  19987. * @param pointsCloud defines if point cloud rendering has to be turned on
  19988. * @param fogEnabled defines if fog has to be turned on
  19989. * @param alphaTest defines if alpha testing has to be turned on
  19990. * @param defines defines the current list of defines
  19991. */
  19992. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  19993. /**
  19994. * Helper used to prepare the list of defines associated with frame values for shader compilation
  19995. * @param scene defines the current scene
  19996. * @param engine defines the current engine
  19997. * @param defines specifies the list of active defines
  19998. * @param useInstances defines if instances have to be turned on
  19999. * @param useClipPlane defines if clip plane have to be turned on
  20000. */
  20001. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  20002. /**
  20003. * Prepares the defines for bones
  20004. * @param mesh The mesh containing the geometry data we will draw
  20005. * @param defines The defines to update
  20006. */
  20007. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20008. /**
  20009. * Prepares the defines for morph targets
  20010. * @param mesh The mesh containing the geometry data we will draw
  20011. * @param defines The defines to update
  20012. */
  20013. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20014. /**
  20015. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20016. * @param mesh The mesh containing the geometry data we will draw
  20017. * @param defines The defines to update
  20018. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20019. * @param useBones Precise whether bones should be used or not (override mesh info)
  20020. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20021. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20022. * @returns false if defines are considered not dirty and have not been checked
  20023. */
  20024. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20025. /**
  20026. * Prepares the defines related to multiview
  20027. * @param scene The scene we are intending to draw
  20028. * @param defines The defines to update
  20029. */
  20030. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20031. /**
  20032. * Prepares the defines related to the light information passed in parameter
  20033. * @param scene The scene we are intending to draw
  20034. * @param mesh The mesh the effect is compiling for
  20035. * @param light The light the effect is compiling for
  20036. * @param lightIndex The index of the light
  20037. * @param defines The defines to update
  20038. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20039. * @param state Defines the current state regarding what is needed (normals, etc...)
  20040. */
  20041. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20042. needNormals: boolean;
  20043. needRebuild: boolean;
  20044. shadowEnabled: boolean;
  20045. specularEnabled: boolean;
  20046. lightmapMode: boolean;
  20047. }): void;
  20048. /**
  20049. * Prepares the defines related to the light information passed in parameter
  20050. * @param scene The scene we are intending to draw
  20051. * @param mesh The mesh the effect is compiling for
  20052. * @param defines The defines to update
  20053. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20054. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20055. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20056. * @returns true if normals will be required for the rest of the effect
  20057. */
  20058. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20059. /**
  20060. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20061. * @param lightIndex defines the light index
  20062. * @param uniformsList The uniform list
  20063. * @param samplersList The sampler list
  20064. * @param projectedLightTexture defines if projected texture must be used
  20065. * @param uniformBuffersList defines an optional list of uniform buffers
  20066. */
  20067. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20068. /**
  20069. * Prepares the uniforms and samplers list to be used in the effect
  20070. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20071. * @param samplersList The sampler list
  20072. * @param defines The defines helping in the list generation
  20073. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20074. */
  20075. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20076. /**
  20077. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20078. * @param defines The defines to update while falling back
  20079. * @param fallbacks The authorized effect fallbacks
  20080. * @param maxSimultaneousLights The maximum number of lights allowed
  20081. * @param rank the current rank of the Effect
  20082. * @returns The newly affected rank
  20083. */
  20084. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20085. private static _TmpMorphInfluencers;
  20086. /**
  20087. * Prepares the list of attributes required for morph targets according to the effect defines.
  20088. * @param attribs The current list of supported attribs
  20089. * @param mesh The mesh to prepare the morph targets attributes for
  20090. * @param influencers The number of influencers
  20091. */
  20092. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20093. /**
  20094. * Prepares the list of attributes required for morph targets according to the effect defines.
  20095. * @param attribs The current list of supported attribs
  20096. * @param mesh The mesh to prepare the morph targets attributes for
  20097. * @param defines The current Defines of the effect
  20098. */
  20099. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20100. /**
  20101. * Prepares the list of attributes required for bones according to the effect defines.
  20102. * @param attribs The current list of supported attribs
  20103. * @param mesh The mesh to prepare the bones attributes for
  20104. * @param defines The current Defines of the effect
  20105. * @param fallbacks The current efffect fallback strategy
  20106. */
  20107. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20108. /**
  20109. * Check and prepare the list of attributes required for instances according to the effect defines.
  20110. * @param attribs The current list of supported attribs
  20111. * @param defines The current MaterialDefines of the effect
  20112. */
  20113. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20114. /**
  20115. * Add the list of attributes required for instances to the attribs array.
  20116. * @param attribs The current list of supported attribs
  20117. */
  20118. static PushAttributesForInstances(attribs: string[]): void;
  20119. /**
  20120. * Binds the light information to the effect.
  20121. * @param light The light containing the generator
  20122. * @param effect The effect we are binding the data to
  20123. * @param lightIndex The light index in the effect used to render
  20124. */
  20125. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20126. /**
  20127. * Binds the lights information from the scene to the effect for the given mesh.
  20128. * @param light Light to bind
  20129. * @param lightIndex Light index
  20130. * @param scene The scene where the light belongs to
  20131. * @param effect The effect we are binding the data to
  20132. * @param useSpecular Defines if specular is supported
  20133. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20134. */
  20135. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20136. /**
  20137. * Binds the lights information from the scene to the effect for the given mesh.
  20138. * @param scene The scene the lights belongs to
  20139. * @param mesh The mesh we are binding the information to render
  20140. * @param effect The effect we are binding the data to
  20141. * @param defines The generated defines for the effect
  20142. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20143. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20144. */
  20145. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20146. private static _tempFogColor;
  20147. /**
  20148. * Binds the fog information from the scene to the effect for the given mesh.
  20149. * @param scene The scene the lights belongs to
  20150. * @param mesh The mesh we are binding the information to render
  20151. * @param effect The effect we are binding the data to
  20152. * @param linearSpace Defines if the fog effect is applied in linear space
  20153. */
  20154. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20155. /**
  20156. * Binds the bones information from the mesh to the effect.
  20157. * @param mesh The mesh we are binding the information to render
  20158. * @param effect The effect we are binding the data to
  20159. */
  20160. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20161. /**
  20162. * Binds the morph targets information from the mesh to the effect.
  20163. * @param abstractMesh The mesh we are binding the information to render
  20164. * @param effect The effect we are binding the data to
  20165. */
  20166. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20167. /**
  20168. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20169. * @param defines The generated defines used in the effect
  20170. * @param effect The effect we are binding the data to
  20171. * @param scene The scene we are willing to render with logarithmic scale for
  20172. */
  20173. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20174. /**
  20175. * Binds the clip plane information from the scene to the effect.
  20176. * @param scene The scene the clip plane information are extracted from
  20177. * @param effect The effect we are binding the data to
  20178. */
  20179. static BindClipPlane(effect: Effect, scene: Scene): void;
  20180. }
  20181. }
  20182. declare module BABYLON {
  20183. /**
  20184. * Block used to expose an input value
  20185. */
  20186. export class InputBlock extends NodeMaterialBlock {
  20187. private _mode;
  20188. private _associatedVariableName;
  20189. private _storedValue;
  20190. private _valueCallback;
  20191. private _type;
  20192. private _animationType;
  20193. /** Gets or set a value used to limit the range of float values */
  20194. min: number;
  20195. /** Gets or set a value used to limit the range of float values */
  20196. max: number;
  20197. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20198. isBoolean: boolean;
  20199. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20200. matrixMode: number;
  20201. /** @hidden */
  20202. _systemValue: Nullable<NodeMaterialSystemValues>;
  20203. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20204. visibleInInspector: boolean;
  20205. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20206. isConstant: boolean;
  20207. /** Gets or sets the group to use to display this block in the Inspector */
  20208. groupInInspector: string;
  20209. /** Gets an observable raised when the value is changed */
  20210. onValueChangedObservable: Observable<InputBlock>;
  20211. /**
  20212. * Gets or sets the connection point type (default is float)
  20213. */
  20214. get type(): NodeMaterialBlockConnectionPointTypes;
  20215. /**
  20216. * Creates a new InputBlock
  20217. * @param name defines the block name
  20218. * @param target defines the target of that block (Vertex by default)
  20219. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20220. */
  20221. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20222. /**
  20223. * Gets the output component
  20224. */
  20225. get output(): NodeMaterialConnectionPoint;
  20226. /**
  20227. * Set the source of this connection point to a vertex attribute
  20228. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20229. * @returns the current connection point
  20230. */
  20231. setAsAttribute(attributeName?: string): InputBlock;
  20232. /**
  20233. * Set the source of this connection point to a system value
  20234. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20235. * @returns the current connection point
  20236. */
  20237. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20238. /**
  20239. * Gets or sets the value of that point.
  20240. * Please note that this value will be ignored if valueCallback is defined
  20241. */
  20242. get value(): any;
  20243. set value(value: any);
  20244. /**
  20245. * Gets or sets a callback used to get the value of that point.
  20246. * Please note that setting this value will force the connection point to ignore the value property
  20247. */
  20248. get valueCallback(): () => any;
  20249. set valueCallback(value: () => any);
  20250. /**
  20251. * Gets or sets the associated variable name in the shader
  20252. */
  20253. get associatedVariableName(): string;
  20254. set associatedVariableName(value: string);
  20255. /** Gets or sets the type of animation applied to the input */
  20256. get animationType(): AnimatedInputBlockTypes;
  20257. set animationType(value: AnimatedInputBlockTypes);
  20258. /**
  20259. * Gets a boolean indicating that this connection point not defined yet
  20260. */
  20261. get isUndefined(): boolean;
  20262. /**
  20263. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20264. * In this case the connection point name must be the name of the uniform to use.
  20265. * Can only be set on inputs
  20266. */
  20267. get isUniform(): boolean;
  20268. set isUniform(value: boolean);
  20269. /**
  20270. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20271. * In this case the connection point name must be the name of the attribute to use
  20272. * Can only be set on inputs
  20273. */
  20274. get isAttribute(): boolean;
  20275. set isAttribute(value: boolean);
  20276. /**
  20277. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20278. * Can only be set on exit points
  20279. */
  20280. get isVarying(): boolean;
  20281. set isVarying(value: boolean);
  20282. /**
  20283. * Gets a boolean indicating that the current connection point is a system value
  20284. */
  20285. get isSystemValue(): boolean;
  20286. /**
  20287. * Gets or sets the current well known value or null if not defined as a system value
  20288. */
  20289. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20290. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20291. /**
  20292. * Gets the current class name
  20293. * @returns the class name
  20294. */
  20295. getClassName(): string;
  20296. /**
  20297. * Animate the input if animationType !== None
  20298. * @param scene defines the rendering scene
  20299. */
  20300. animate(scene: Scene): void;
  20301. private _emitDefine;
  20302. initialize(state: NodeMaterialBuildState): void;
  20303. /**
  20304. * Set the input block to its default value (based on its type)
  20305. */
  20306. setDefaultValue(): void;
  20307. private _emitConstant;
  20308. /** @hidden */
  20309. get _noContextSwitch(): boolean;
  20310. private _emit;
  20311. /** @hidden */
  20312. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20313. /** @hidden */
  20314. _transmit(effect: Effect, scene: Scene): void;
  20315. protected _buildBlock(state: NodeMaterialBuildState): void;
  20316. protected _dumpPropertiesCode(): string;
  20317. dispose(): void;
  20318. serialize(): any;
  20319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20320. }
  20321. }
  20322. declare module BABYLON {
  20323. /**
  20324. * Enum used to define the compatibility state between two connection points
  20325. */
  20326. export enum NodeMaterialConnectionPointCompatibilityStates {
  20327. /** Points are compatibles */
  20328. Compatible = 0,
  20329. /** Points are incompatible because of their types */
  20330. TypeIncompatible = 1,
  20331. /** Points are incompatible because of their targets (vertex vs fragment) */
  20332. TargetIncompatible = 2
  20333. }
  20334. /**
  20335. * Defines the direction of a connection point
  20336. */
  20337. export enum NodeMaterialConnectionPointDirection {
  20338. /** Input */
  20339. Input = 0,
  20340. /** Output */
  20341. Output = 1
  20342. }
  20343. /**
  20344. * Defines a connection point for a block
  20345. */
  20346. export class NodeMaterialConnectionPoint {
  20347. /** @hidden */
  20348. _ownerBlock: NodeMaterialBlock;
  20349. /** @hidden */
  20350. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20351. private _endpoints;
  20352. private _associatedVariableName;
  20353. private _direction;
  20354. /** @hidden */
  20355. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20356. /** @hidden */
  20357. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20358. private _type;
  20359. /** @hidden */
  20360. _enforceAssociatedVariableName: boolean;
  20361. /** Gets the direction of the point */
  20362. get direction(): NodeMaterialConnectionPointDirection;
  20363. /** Indicates that this connection point needs dual validation before being connected to another point */
  20364. needDualDirectionValidation: boolean;
  20365. /**
  20366. * Gets or sets the additional types supported by this connection point
  20367. */
  20368. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20369. /**
  20370. * Gets or sets the additional types excluded by this connection point
  20371. */
  20372. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20373. /**
  20374. * Observable triggered when this point is connected
  20375. */
  20376. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20377. /**
  20378. * Gets or sets the associated variable name in the shader
  20379. */
  20380. get associatedVariableName(): string;
  20381. set associatedVariableName(value: string);
  20382. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20383. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20384. /**
  20385. * Gets or sets the connection point type (default is float)
  20386. */
  20387. get type(): NodeMaterialBlockConnectionPointTypes;
  20388. set type(value: NodeMaterialBlockConnectionPointTypes);
  20389. /**
  20390. * Gets or sets the connection point name
  20391. */
  20392. name: string;
  20393. /**
  20394. * Gets or sets the connection point name
  20395. */
  20396. displayName: string;
  20397. /**
  20398. * Gets or sets a boolean indicating that this connection point can be omitted
  20399. */
  20400. isOptional: boolean;
  20401. /**
  20402. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20403. */
  20404. define: string;
  20405. /** @hidden */
  20406. _prioritizeVertex: boolean;
  20407. private _target;
  20408. /** Gets or sets the target of that connection point */
  20409. get target(): NodeMaterialBlockTargets;
  20410. set target(value: NodeMaterialBlockTargets);
  20411. /**
  20412. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20413. */
  20414. get isConnected(): boolean;
  20415. /**
  20416. * Gets a boolean indicating that the current point is connected to an input block
  20417. */
  20418. get isConnectedToInputBlock(): boolean;
  20419. /**
  20420. * Gets a the connected input block (if any)
  20421. */
  20422. get connectInputBlock(): Nullable<InputBlock>;
  20423. /** Get the other side of the connection (if any) */
  20424. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20425. /** Get the block that owns this connection point */
  20426. get ownerBlock(): NodeMaterialBlock;
  20427. /** Get the block connected on the other side of this connection (if any) */
  20428. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20429. /** Get the block connected on the endpoints of this connection (if any) */
  20430. get connectedBlocks(): Array<NodeMaterialBlock>;
  20431. /** Gets the list of connected endpoints */
  20432. get endpoints(): NodeMaterialConnectionPoint[];
  20433. /** Gets a boolean indicating if that output point is connected to at least one input */
  20434. get hasEndpoints(): boolean;
  20435. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20436. get isConnectedInVertexShader(): boolean;
  20437. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20438. get isConnectedInFragmentShader(): boolean;
  20439. /**
  20440. * Creates a block suitable to be used as an input for this input point.
  20441. * If null is returned, a block based on the point type will be created.
  20442. * @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
  20443. */
  20444. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20445. /**
  20446. * Creates a new connection point
  20447. * @param name defines the connection point name
  20448. * @param ownerBlock defines the block hosting this connection point
  20449. * @param direction defines the direction of the connection point
  20450. */
  20451. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20452. /**
  20453. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20454. * @returns the class name
  20455. */
  20456. getClassName(): string;
  20457. /**
  20458. * Gets a boolean indicating if the current point can be connected to another point
  20459. * @param connectionPoint defines the other connection point
  20460. * @returns a boolean
  20461. */
  20462. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20463. /**
  20464. * Gets a number indicating if the current point can be connected to another point
  20465. * @param connectionPoint defines the other connection point
  20466. * @returns a number defining the compatibility state
  20467. */
  20468. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20469. /**
  20470. * Connect this point to another connection point
  20471. * @param connectionPoint defines the other connection point
  20472. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20473. * @returns the current connection point
  20474. */
  20475. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20476. /**
  20477. * Disconnect this point from one of his endpoint
  20478. * @param endpoint defines the other connection point
  20479. * @returns the current connection point
  20480. */
  20481. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20482. /**
  20483. * Serializes this point in a JSON representation
  20484. * @param isInput defines if the connection point is an input (default is true)
  20485. * @returns the serialized point object
  20486. */
  20487. serialize(isInput?: boolean): any;
  20488. /**
  20489. * Release resources
  20490. */
  20491. dispose(): void;
  20492. }
  20493. }
  20494. declare module BABYLON {
  20495. /**
  20496. * Enum used to define the material modes
  20497. */
  20498. export enum NodeMaterialModes {
  20499. /** Regular material */
  20500. Material = 0,
  20501. /** For post process */
  20502. PostProcess = 1,
  20503. /** For particle system */
  20504. Particle = 2
  20505. }
  20506. }
  20507. declare module BABYLON {
  20508. /**
  20509. * Block used to read a texture from a sampler
  20510. */
  20511. export class TextureBlock extends NodeMaterialBlock {
  20512. private _defineName;
  20513. private _linearDefineName;
  20514. private _gammaDefineName;
  20515. private _tempTextureRead;
  20516. private _samplerName;
  20517. private _transformedUVName;
  20518. private _textureTransformName;
  20519. private _textureInfoName;
  20520. private _mainUVName;
  20521. private _mainUVDefineName;
  20522. private _fragmentOnly;
  20523. /**
  20524. * Gets or sets the texture associated with the node
  20525. */
  20526. texture: Nullable<Texture>;
  20527. /**
  20528. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20529. */
  20530. convertToGammaSpace: boolean;
  20531. /**
  20532. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20533. */
  20534. convertToLinearSpace: boolean;
  20535. /**
  20536. * Create a new TextureBlock
  20537. * @param name defines the block name
  20538. */
  20539. constructor(name: string, fragmentOnly?: boolean);
  20540. /**
  20541. * Gets the current class name
  20542. * @returns the class name
  20543. */
  20544. getClassName(): string;
  20545. /**
  20546. * Gets the uv input component
  20547. */
  20548. get uv(): NodeMaterialConnectionPoint;
  20549. /**
  20550. * Gets the rgba output component
  20551. */
  20552. get rgba(): NodeMaterialConnectionPoint;
  20553. /**
  20554. * Gets the rgb output component
  20555. */
  20556. get rgb(): NodeMaterialConnectionPoint;
  20557. /**
  20558. * Gets the r output component
  20559. */
  20560. get r(): NodeMaterialConnectionPoint;
  20561. /**
  20562. * Gets the g output component
  20563. */
  20564. get g(): NodeMaterialConnectionPoint;
  20565. /**
  20566. * Gets the b output component
  20567. */
  20568. get b(): NodeMaterialConnectionPoint;
  20569. /**
  20570. * Gets the a output component
  20571. */
  20572. get a(): NodeMaterialConnectionPoint;
  20573. get target(): NodeMaterialBlockTargets;
  20574. autoConfigure(material: NodeMaterial): void;
  20575. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20576. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20577. isReady(): boolean;
  20578. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20579. private get _isMixed();
  20580. private _injectVertexCode;
  20581. private _writeTextureRead;
  20582. private _writeOutput;
  20583. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20584. protected _dumpPropertiesCode(): string;
  20585. serialize(): any;
  20586. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20587. }
  20588. }
  20589. declare module BABYLON {
  20590. /** @hidden */
  20591. export var reflectionFunction: {
  20592. name: string;
  20593. shader: string;
  20594. };
  20595. }
  20596. declare module BABYLON {
  20597. /**
  20598. * Base block used to read a reflection texture from a sampler
  20599. */
  20600. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20601. /** @hidden */
  20602. _define3DName: string;
  20603. /** @hidden */
  20604. _defineCubicName: string;
  20605. /** @hidden */
  20606. _defineExplicitName: string;
  20607. /** @hidden */
  20608. _defineProjectionName: string;
  20609. /** @hidden */
  20610. _defineLocalCubicName: string;
  20611. /** @hidden */
  20612. _defineSphericalName: string;
  20613. /** @hidden */
  20614. _definePlanarName: string;
  20615. /** @hidden */
  20616. _defineEquirectangularName: string;
  20617. /** @hidden */
  20618. _defineMirroredEquirectangularFixedName: string;
  20619. /** @hidden */
  20620. _defineEquirectangularFixedName: string;
  20621. /** @hidden */
  20622. _defineSkyboxName: string;
  20623. /** @hidden */
  20624. _defineOppositeZ: string;
  20625. /** @hidden */
  20626. _cubeSamplerName: string;
  20627. /** @hidden */
  20628. _2DSamplerName: string;
  20629. protected _positionUVWName: string;
  20630. protected _directionWName: string;
  20631. protected _reflectionVectorName: string;
  20632. /** @hidden */
  20633. _reflectionCoordsName: string;
  20634. /** @hidden */
  20635. _reflectionMatrixName: string;
  20636. protected _reflectionColorName: string;
  20637. /**
  20638. * Gets or sets the texture associated with the node
  20639. */
  20640. texture: Nullable<BaseTexture>;
  20641. /**
  20642. * Create a new ReflectionTextureBaseBlock
  20643. * @param name defines the block name
  20644. */
  20645. constructor(name: string);
  20646. /**
  20647. * Gets the current class name
  20648. * @returns the class name
  20649. */
  20650. getClassName(): string;
  20651. /**
  20652. * Gets the world position input component
  20653. */
  20654. abstract get position(): NodeMaterialConnectionPoint;
  20655. /**
  20656. * Gets the world position input component
  20657. */
  20658. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20659. /**
  20660. * Gets the world normal input component
  20661. */
  20662. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20663. /**
  20664. * Gets the world input component
  20665. */
  20666. abstract get world(): NodeMaterialConnectionPoint;
  20667. /**
  20668. * Gets the camera (or eye) position component
  20669. */
  20670. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20671. /**
  20672. * Gets the view input component
  20673. */
  20674. abstract get view(): NodeMaterialConnectionPoint;
  20675. protected _getTexture(): Nullable<BaseTexture>;
  20676. autoConfigure(material: NodeMaterial): void;
  20677. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20678. isReady(): boolean;
  20679. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20680. /**
  20681. * Gets the code to inject in the vertex shader
  20682. * @param state current state of the node material building
  20683. * @returns the shader code
  20684. */
  20685. handleVertexSide(state: NodeMaterialBuildState): string;
  20686. /**
  20687. * Handles the inits for the fragment code path
  20688. * @param state node material build state
  20689. */
  20690. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20691. /**
  20692. * Generates the reflection coords code for the fragment code path
  20693. * @param worldNormalVarName name of the world normal variable
  20694. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20695. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20696. * @returns the shader code
  20697. */
  20698. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20699. /**
  20700. * Generates the reflection color code for the fragment code path
  20701. * @param lodVarName name of the lod variable
  20702. * @param swizzleLookupTexture swizzle to use for the final color variable
  20703. * @returns the shader code
  20704. */
  20705. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20706. /**
  20707. * Generates the code corresponding to the connected output points
  20708. * @param state node material build state
  20709. * @param varName name of the variable to output
  20710. * @returns the shader code
  20711. */
  20712. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20713. protected _buildBlock(state: NodeMaterialBuildState): this;
  20714. protected _dumpPropertiesCode(): string;
  20715. serialize(): any;
  20716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20717. }
  20718. }
  20719. declare module BABYLON {
  20720. /**
  20721. * Defines a connection point to be used for points with a custom object type
  20722. */
  20723. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20724. private _blockType;
  20725. private _blockName;
  20726. private _nameForCheking?;
  20727. /**
  20728. * Creates a new connection point
  20729. * @param name defines the connection point name
  20730. * @param ownerBlock defines the block hosting this connection point
  20731. * @param direction defines the direction of the connection point
  20732. */
  20733. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20734. /**
  20735. * Gets a number indicating if the current point can be connected to another point
  20736. * @param connectionPoint defines the other connection point
  20737. * @returns a number defining the compatibility state
  20738. */
  20739. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20740. /**
  20741. * Creates a block suitable to be used as an input for this input point.
  20742. * If null is returned, a block based on the point type will be created.
  20743. * @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
  20744. */
  20745. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20746. }
  20747. }
  20748. declare module BABYLON {
  20749. /**
  20750. * Enum defining the type of properties that can be edited in the property pages in the NME
  20751. */
  20752. export enum PropertyTypeForEdition {
  20753. /** property is a boolean */
  20754. Boolean = 0,
  20755. /** property is a float */
  20756. Float = 1,
  20757. /** property is a Vector2 */
  20758. Vector2 = 2,
  20759. /** property is a list of values */
  20760. List = 3
  20761. }
  20762. /**
  20763. * Interface that defines an option in a variable of type list
  20764. */
  20765. export interface IEditablePropertyListOption {
  20766. /** label of the option */
  20767. "label": string;
  20768. /** value of the option */
  20769. "value": number;
  20770. }
  20771. /**
  20772. * Interface that defines the options available for an editable property
  20773. */
  20774. export interface IEditablePropertyOption {
  20775. /** min value */
  20776. "min"?: number;
  20777. /** max value */
  20778. "max"?: number;
  20779. /** notifiers: indicates which actions to take when the property is changed */
  20780. "notifiers"?: {
  20781. /** the material should be rebuilt */
  20782. "rebuild"?: boolean;
  20783. /** the preview should be updated */
  20784. "update"?: boolean;
  20785. };
  20786. /** list of the options for a variable of type list */
  20787. "options"?: IEditablePropertyListOption[];
  20788. }
  20789. /**
  20790. * Interface that describes an editable property
  20791. */
  20792. export interface IPropertyDescriptionForEdition {
  20793. /** name of the property */
  20794. "propertyName": string;
  20795. /** display name of the property */
  20796. "displayName": string;
  20797. /** type of the property */
  20798. "type": PropertyTypeForEdition;
  20799. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20800. "groupName": string;
  20801. /** options for the property */
  20802. "options": IEditablePropertyOption;
  20803. }
  20804. /**
  20805. * Decorator that flags a property in a node material block as being editable
  20806. */
  20807. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20808. }
  20809. declare module BABYLON {
  20810. /**
  20811. * Block used to implement the refraction part of the sub surface module of the PBR material
  20812. */
  20813. export class RefractionBlock extends NodeMaterialBlock {
  20814. /** @hidden */
  20815. _define3DName: string;
  20816. /** @hidden */
  20817. _refractionMatrixName: string;
  20818. /** @hidden */
  20819. _defineLODRefractionAlpha: string;
  20820. /** @hidden */
  20821. _defineLinearSpecularRefraction: string;
  20822. /** @hidden */
  20823. _defineOppositeZ: string;
  20824. /** @hidden */
  20825. _cubeSamplerName: string;
  20826. /** @hidden */
  20827. _2DSamplerName: string;
  20828. /** @hidden */
  20829. _vRefractionMicrosurfaceInfosName: string;
  20830. /** @hidden */
  20831. _vRefractionInfosName: string;
  20832. private _scene;
  20833. /**
  20834. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20835. * Materials half opaque for instance using refraction could benefit from this control.
  20836. */
  20837. linkRefractionWithTransparency: boolean;
  20838. /**
  20839. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20840. */
  20841. invertRefractionY: boolean;
  20842. /**
  20843. * Gets or sets the texture associated with the node
  20844. */
  20845. texture: Nullable<BaseTexture>;
  20846. /**
  20847. * Create a new RefractionBlock
  20848. * @param name defines the block name
  20849. */
  20850. constructor(name: string);
  20851. /**
  20852. * Gets the current class name
  20853. * @returns the class name
  20854. */
  20855. getClassName(): string;
  20856. /**
  20857. * Gets the intensity input component
  20858. */
  20859. get intensity(): NodeMaterialConnectionPoint;
  20860. /**
  20861. * Gets the index of refraction input component
  20862. */
  20863. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20864. /**
  20865. * Gets the tint at distance input component
  20866. */
  20867. get tintAtDistance(): NodeMaterialConnectionPoint;
  20868. /**
  20869. * Gets the view input component
  20870. */
  20871. get view(): NodeMaterialConnectionPoint;
  20872. /**
  20873. * Gets the refraction object output component
  20874. */
  20875. get refraction(): NodeMaterialConnectionPoint;
  20876. /**
  20877. * Returns true if the block has a texture
  20878. */
  20879. get hasTexture(): boolean;
  20880. protected _getTexture(): Nullable<BaseTexture>;
  20881. autoConfigure(material: NodeMaterial): void;
  20882. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20883. isReady(): boolean;
  20884. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20885. /**
  20886. * Gets the main code of the block (fragment side)
  20887. * @param state current state of the node material building
  20888. * @returns the shader code
  20889. */
  20890. getCode(state: NodeMaterialBuildState): string;
  20891. protected _buildBlock(state: NodeMaterialBuildState): this;
  20892. protected _dumpPropertiesCode(): string;
  20893. serialize(): any;
  20894. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20895. }
  20896. }
  20897. declare module BABYLON {
  20898. /**
  20899. * Base block used as input for post process
  20900. */
  20901. export class CurrentScreenBlock extends NodeMaterialBlock {
  20902. private _samplerName;
  20903. private _linearDefineName;
  20904. private _gammaDefineName;
  20905. private _mainUVName;
  20906. private _tempTextureRead;
  20907. /**
  20908. * Gets or sets the texture associated with the node
  20909. */
  20910. texture: Nullable<BaseTexture>;
  20911. /**
  20912. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20913. */
  20914. convertToGammaSpace: boolean;
  20915. /**
  20916. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20917. */
  20918. convertToLinearSpace: boolean;
  20919. /**
  20920. * Create a new CurrentScreenBlock
  20921. * @param name defines the block name
  20922. */
  20923. constructor(name: string);
  20924. /**
  20925. * Gets the current class name
  20926. * @returns the class name
  20927. */
  20928. getClassName(): string;
  20929. /**
  20930. * Gets the uv input component
  20931. */
  20932. get uv(): NodeMaterialConnectionPoint;
  20933. /**
  20934. * Gets the rgba output component
  20935. */
  20936. get rgba(): NodeMaterialConnectionPoint;
  20937. /**
  20938. * Gets the rgb output component
  20939. */
  20940. get rgb(): NodeMaterialConnectionPoint;
  20941. /**
  20942. * Gets the r output component
  20943. */
  20944. get r(): NodeMaterialConnectionPoint;
  20945. /**
  20946. * Gets the g output component
  20947. */
  20948. get g(): NodeMaterialConnectionPoint;
  20949. /**
  20950. * Gets the b output component
  20951. */
  20952. get b(): NodeMaterialConnectionPoint;
  20953. /**
  20954. * Gets the a output component
  20955. */
  20956. get a(): NodeMaterialConnectionPoint;
  20957. /**
  20958. * Initialize the block and prepare the context for build
  20959. * @param state defines the state that will be used for the build
  20960. */
  20961. initialize(state: NodeMaterialBuildState): void;
  20962. get target(): NodeMaterialBlockTargets;
  20963. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20964. isReady(): boolean;
  20965. private _injectVertexCode;
  20966. private _writeTextureRead;
  20967. private _writeOutput;
  20968. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20969. serialize(): any;
  20970. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20971. }
  20972. }
  20973. declare module BABYLON {
  20974. /**
  20975. * Base block used for the particle texture
  20976. */
  20977. export class ParticleTextureBlock extends NodeMaterialBlock {
  20978. private _samplerName;
  20979. private _linearDefineName;
  20980. private _gammaDefineName;
  20981. private _tempTextureRead;
  20982. /**
  20983. * Gets or sets the texture associated with the node
  20984. */
  20985. texture: Nullable<BaseTexture>;
  20986. /**
  20987. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20988. */
  20989. convertToGammaSpace: boolean;
  20990. /**
  20991. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20992. */
  20993. convertToLinearSpace: boolean;
  20994. /**
  20995. * Create a new ParticleTextureBlock
  20996. * @param name defines the block name
  20997. */
  20998. constructor(name: string);
  20999. /**
  21000. * Gets the current class name
  21001. * @returns the class name
  21002. */
  21003. getClassName(): string;
  21004. /**
  21005. * Gets the uv input component
  21006. */
  21007. get uv(): NodeMaterialConnectionPoint;
  21008. /**
  21009. * Gets the rgba output component
  21010. */
  21011. get rgba(): NodeMaterialConnectionPoint;
  21012. /**
  21013. * Gets the rgb output component
  21014. */
  21015. get rgb(): NodeMaterialConnectionPoint;
  21016. /**
  21017. * Gets the r output component
  21018. */
  21019. get r(): NodeMaterialConnectionPoint;
  21020. /**
  21021. * Gets the g output component
  21022. */
  21023. get g(): NodeMaterialConnectionPoint;
  21024. /**
  21025. * Gets the b output component
  21026. */
  21027. get b(): NodeMaterialConnectionPoint;
  21028. /**
  21029. * Gets the a output component
  21030. */
  21031. get a(): NodeMaterialConnectionPoint;
  21032. /**
  21033. * Initialize the block and prepare the context for build
  21034. * @param state defines the state that will be used for the build
  21035. */
  21036. initialize(state: NodeMaterialBuildState): void;
  21037. autoConfigure(material: NodeMaterial): void;
  21038. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21039. isReady(): boolean;
  21040. private _writeOutput;
  21041. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21042. serialize(): any;
  21043. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21044. }
  21045. }
  21046. declare module BABYLON {
  21047. /**
  21048. * Class used to store shared data between 2 NodeMaterialBuildState
  21049. */
  21050. export class NodeMaterialBuildStateSharedData {
  21051. /**
  21052. * Gets the list of emitted varyings
  21053. */
  21054. temps: string[];
  21055. /**
  21056. * Gets the list of emitted varyings
  21057. */
  21058. varyings: string[];
  21059. /**
  21060. * Gets the varying declaration string
  21061. */
  21062. varyingDeclaration: string;
  21063. /**
  21064. * Input blocks
  21065. */
  21066. inputBlocks: InputBlock[];
  21067. /**
  21068. * Input blocks
  21069. */
  21070. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21071. /**
  21072. * Bindable blocks (Blocks that need to set data to the effect)
  21073. */
  21074. bindableBlocks: NodeMaterialBlock[];
  21075. /**
  21076. * List of blocks that can provide a compilation fallback
  21077. */
  21078. blocksWithFallbacks: NodeMaterialBlock[];
  21079. /**
  21080. * List of blocks that can provide a define update
  21081. */
  21082. blocksWithDefines: NodeMaterialBlock[];
  21083. /**
  21084. * List of blocks that can provide a repeatable content
  21085. */
  21086. repeatableContentBlocks: NodeMaterialBlock[];
  21087. /**
  21088. * List of blocks that can provide a dynamic list of uniforms
  21089. */
  21090. dynamicUniformBlocks: NodeMaterialBlock[];
  21091. /**
  21092. * List of blocks that can block the isReady function for the material
  21093. */
  21094. blockingBlocks: NodeMaterialBlock[];
  21095. /**
  21096. * Gets the list of animated inputs
  21097. */
  21098. animatedInputs: InputBlock[];
  21099. /**
  21100. * Build Id used to avoid multiple recompilations
  21101. */
  21102. buildId: number;
  21103. /** List of emitted variables */
  21104. variableNames: {
  21105. [key: string]: number;
  21106. };
  21107. /** List of emitted defines */
  21108. defineNames: {
  21109. [key: string]: number;
  21110. };
  21111. /** Should emit comments? */
  21112. emitComments: boolean;
  21113. /** Emit build activity */
  21114. verbose: boolean;
  21115. /** Gets or sets the hosting scene */
  21116. scene: Scene;
  21117. /**
  21118. * Gets the compilation hints emitted at compilation time
  21119. */
  21120. hints: {
  21121. needWorldViewMatrix: boolean;
  21122. needWorldViewProjectionMatrix: boolean;
  21123. needAlphaBlending: boolean;
  21124. needAlphaTesting: boolean;
  21125. };
  21126. /**
  21127. * List of compilation checks
  21128. */
  21129. checks: {
  21130. emitVertex: boolean;
  21131. emitFragment: boolean;
  21132. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21133. };
  21134. /**
  21135. * Is vertex program allowed to be empty?
  21136. */
  21137. allowEmptyVertexProgram: boolean;
  21138. /** Creates a new shared data */
  21139. constructor();
  21140. /**
  21141. * Emits console errors and exceptions if there is a failing check
  21142. */
  21143. emitErrors(): void;
  21144. }
  21145. }
  21146. declare module BABYLON {
  21147. /**
  21148. * Class used to store node based material build state
  21149. */
  21150. export class NodeMaterialBuildState {
  21151. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21152. supportUniformBuffers: boolean;
  21153. /**
  21154. * Gets the list of emitted attributes
  21155. */
  21156. attributes: string[];
  21157. /**
  21158. * Gets the list of emitted uniforms
  21159. */
  21160. uniforms: string[];
  21161. /**
  21162. * Gets the list of emitted constants
  21163. */
  21164. constants: string[];
  21165. /**
  21166. * Gets the list of emitted samplers
  21167. */
  21168. samplers: string[];
  21169. /**
  21170. * Gets the list of emitted functions
  21171. */
  21172. functions: {
  21173. [key: string]: string;
  21174. };
  21175. /**
  21176. * Gets the list of emitted extensions
  21177. */
  21178. extensions: {
  21179. [key: string]: string;
  21180. };
  21181. /**
  21182. * Gets the target of the compilation state
  21183. */
  21184. target: NodeMaterialBlockTargets;
  21185. /**
  21186. * Gets the list of emitted counters
  21187. */
  21188. counters: {
  21189. [key: string]: number;
  21190. };
  21191. /**
  21192. * Shared data between multiple NodeMaterialBuildState instances
  21193. */
  21194. sharedData: NodeMaterialBuildStateSharedData;
  21195. /** @hidden */
  21196. _vertexState: NodeMaterialBuildState;
  21197. /** @hidden */
  21198. _attributeDeclaration: string;
  21199. /** @hidden */
  21200. _uniformDeclaration: string;
  21201. /** @hidden */
  21202. _constantDeclaration: string;
  21203. /** @hidden */
  21204. _samplerDeclaration: string;
  21205. /** @hidden */
  21206. _varyingTransfer: string;
  21207. /** @hidden */
  21208. _injectAtEnd: string;
  21209. private _repeatableContentAnchorIndex;
  21210. /** @hidden */
  21211. _builtCompilationString: string;
  21212. /**
  21213. * Gets the emitted compilation strings
  21214. */
  21215. compilationString: string;
  21216. /**
  21217. * Finalize the compilation strings
  21218. * @param state defines the current compilation state
  21219. */
  21220. finalize(state: NodeMaterialBuildState): void;
  21221. /** @hidden */
  21222. get _repeatableContentAnchor(): string;
  21223. /** @hidden */
  21224. _getFreeVariableName(prefix: string): string;
  21225. /** @hidden */
  21226. _getFreeDefineName(prefix: string): string;
  21227. /** @hidden */
  21228. _excludeVariableName(name: string): void;
  21229. /** @hidden */
  21230. _emit2DSampler(name: string): void;
  21231. /** @hidden */
  21232. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21233. /** @hidden */
  21234. _emitExtension(name: string, extension: string, define?: string): void;
  21235. /** @hidden */
  21236. _emitFunction(name: string, code: string, comments: string): void;
  21237. /** @hidden */
  21238. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21239. replaceStrings?: {
  21240. search: RegExp;
  21241. replace: string;
  21242. }[];
  21243. repeatKey?: string;
  21244. }): string;
  21245. /** @hidden */
  21246. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21247. repeatKey?: string;
  21248. removeAttributes?: boolean;
  21249. removeUniforms?: boolean;
  21250. removeVaryings?: boolean;
  21251. removeIfDef?: boolean;
  21252. replaceStrings?: {
  21253. search: RegExp;
  21254. replace: string;
  21255. }[];
  21256. }, storeKey?: string): void;
  21257. /** @hidden */
  21258. _registerTempVariable(name: string): boolean;
  21259. /** @hidden */
  21260. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21261. /** @hidden */
  21262. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21263. /** @hidden */
  21264. _emitFloat(value: number): string;
  21265. }
  21266. }
  21267. declare module BABYLON {
  21268. /**
  21269. * Helper class used to generate session unique ID
  21270. */
  21271. export class UniqueIdGenerator {
  21272. private static _UniqueIdCounter;
  21273. /**
  21274. * Gets an unique (relatively to the current scene) Id
  21275. */
  21276. static get UniqueId(): number;
  21277. }
  21278. }
  21279. declare module BABYLON {
  21280. /**
  21281. * Defines a block that can be used inside a node based material
  21282. */
  21283. export class NodeMaterialBlock {
  21284. private _buildId;
  21285. private _buildTarget;
  21286. private _target;
  21287. private _isFinalMerger;
  21288. private _isInput;
  21289. protected _isUnique: boolean;
  21290. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21291. inputsAreExclusive: boolean;
  21292. /** @hidden */
  21293. _codeVariableName: string;
  21294. /** @hidden */
  21295. _inputs: NodeMaterialConnectionPoint[];
  21296. /** @hidden */
  21297. _outputs: NodeMaterialConnectionPoint[];
  21298. /** @hidden */
  21299. _preparationId: number;
  21300. /**
  21301. * Gets or sets the name of the block
  21302. */
  21303. name: string;
  21304. /**
  21305. * Gets or sets the unique id of the node
  21306. */
  21307. uniqueId: number;
  21308. /**
  21309. * Gets or sets the comments associated with this block
  21310. */
  21311. comments: string;
  21312. /**
  21313. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21314. */
  21315. get isUnique(): boolean;
  21316. /**
  21317. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21318. */
  21319. get isFinalMerger(): boolean;
  21320. /**
  21321. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21322. */
  21323. get isInput(): boolean;
  21324. /**
  21325. * Gets or sets the build Id
  21326. */
  21327. get buildId(): number;
  21328. set buildId(value: number);
  21329. /**
  21330. * Gets or sets the target of the block
  21331. */
  21332. get target(): NodeMaterialBlockTargets;
  21333. set target(value: NodeMaterialBlockTargets);
  21334. /**
  21335. * Gets the list of input points
  21336. */
  21337. get inputs(): NodeMaterialConnectionPoint[];
  21338. /** Gets the list of output points */
  21339. get outputs(): NodeMaterialConnectionPoint[];
  21340. /**
  21341. * Find an input by its name
  21342. * @param name defines the name of the input to look for
  21343. * @returns the input or null if not found
  21344. */
  21345. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21346. /**
  21347. * Find an output by its name
  21348. * @param name defines the name of the outputto look for
  21349. * @returns the output or null if not found
  21350. */
  21351. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21352. /**
  21353. * Creates a new NodeMaterialBlock
  21354. * @param name defines the block name
  21355. * @param target defines the target of that block (Vertex by default)
  21356. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21357. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21358. */
  21359. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21360. /**
  21361. * Initialize the block and prepare the context for build
  21362. * @param state defines the state that will be used for the build
  21363. */
  21364. initialize(state: NodeMaterialBuildState): void;
  21365. /**
  21366. * Bind data to effect. Will only be called for blocks with isBindable === true
  21367. * @param effect defines the effect to bind data to
  21368. * @param nodeMaterial defines the hosting NodeMaterial
  21369. * @param mesh defines the mesh that will be rendered
  21370. * @param subMesh defines the submesh that will be rendered
  21371. */
  21372. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21373. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21374. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21375. protected _writeFloat(value: number): string;
  21376. /**
  21377. * Gets the current class name e.g. "NodeMaterialBlock"
  21378. * @returns the class name
  21379. */
  21380. getClassName(): string;
  21381. /**
  21382. * Register a new input. Must be called inside a block constructor
  21383. * @param name defines the connection point name
  21384. * @param type defines the connection point type
  21385. * @param isOptional defines a boolean indicating that this input can be omitted
  21386. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21387. * @param point an already created connection point. If not provided, create a new one
  21388. * @returns the current block
  21389. */
  21390. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21391. /**
  21392. * Register a new output. Must be called inside a block constructor
  21393. * @param name defines the connection point name
  21394. * @param type defines the connection point type
  21395. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21396. * @param point an already created connection point. If not provided, create a new one
  21397. * @returns the current block
  21398. */
  21399. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21400. /**
  21401. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21402. * @param forOutput defines an optional connection point to check compatibility with
  21403. * @returns the first available input or null
  21404. */
  21405. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21406. /**
  21407. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21408. * @param forBlock defines an optional block to check compatibility with
  21409. * @returns the first available input or null
  21410. */
  21411. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21412. /**
  21413. * Gets the sibling of the given output
  21414. * @param current defines the current output
  21415. * @returns the next output in the list or null
  21416. */
  21417. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21418. /**
  21419. * Connect current block with another block
  21420. * @param other defines the block to connect with
  21421. * @param options define the various options to help pick the right connections
  21422. * @returns the current block
  21423. */
  21424. connectTo(other: NodeMaterialBlock, options?: {
  21425. input?: string;
  21426. output?: string;
  21427. outputSwizzle?: string;
  21428. }): this | undefined;
  21429. protected _buildBlock(state: NodeMaterialBuildState): void;
  21430. /**
  21431. * Add uniforms, samplers and uniform buffers at compilation time
  21432. * @param state defines the state to update
  21433. * @param nodeMaterial defines the node material requesting the update
  21434. * @param defines defines the material defines to update
  21435. * @param uniformBuffers defines the list of uniform buffer names
  21436. */
  21437. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21438. /**
  21439. * Add potential fallbacks if shader compilation fails
  21440. * @param mesh defines the mesh to be rendered
  21441. * @param fallbacks defines the current prioritized list of fallbacks
  21442. */
  21443. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21444. /**
  21445. * Initialize defines for shader compilation
  21446. * @param mesh defines the mesh to be rendered
  21447. * @param nodeMaterial defines the node material requesting the update
  21448. * @param defines defines the material defines to update
  21449. * @param useInstances specifies that instances should be used
  21450. */
  21451. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21452. /**
  21453. * Update defines for shader compilation
  21454. * @param mesh defines the mesh to be rendered
  21455. * @param nodeMaterial defines the node material requesting the update
  21456. * @param defines defines the material defines to update
  21457. * @param useInstances specifies that instances should be used
  21458. */
  21459. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21460. /**
  21461. * Lets the block try to connect some inputs automatically
  21462. * @param material defines the hosting NodeMaterial
  21463. */
  21464. autoConfigure(material: NodeMaterial): void;
  21465. /**
  21466. * Function called when a block is declared as repeatable content generator
  21467. * @param vertexShaderState defines the current compilation state for the vertex shader
  21468. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21469. * @param mesh defines the mesh to be rendered
  21470. * @param defines defines the material defines to update
  21471. */
  21472. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21473. /**
  21474. * Checks if the block is ready
  21475. * @param mesh defines the mesh to be rendered
  21476. * @param nodeMaterial defines the node material requesting the update
  21477. * @param defines defines the material defines to update
  21478. * @param useInstances specifies that instances should be used
  21479. * @returns true if the block is ready
  21480. */
  21481. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21482. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21483. private _processBuild;
  21484. /**
  21485. * Compile the current node and generate the shader code
  21486. * @param state defines the current compilation state (uniforms, samplers, current string)
  21487. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21488. * @returns true if already built
  21489. */
  21490. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21491. protected _inputRename(name: string): string;
  21492. protected _outputRename(name: string): string;
  21493. protected _dumpPropertiesCode(): string;
  21494. /** @hidden */
  21495. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21496. /** @hidden */
  21497. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21498. /**
  21499. * Clone the current block to a new identical block
  21500. * @param scene defines the hosting scene
  21501. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21502. * @returns a copy of the current block
  21503. */
  21504. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21505. /**
  21506. * Serializes this block in a JSON representation
  21507. * @returns the serialized block object
  21508. */
  21509. serialize(): any;
  21510. /** @hidden */
  21511. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21512. private _deserializePortDisplayNames;
  21513. /**
  21514. * Release resources
  21515. */
  21516. dispose(): void;
  21517. }
  21518. }
  21519. declare module BABYLON {
  21520. /**
  21521. * Base class of materials working in push mode in babylon JS
  21522. * @hidden
  21523. */
  21524. export class PushMaterial extends Material {
  21525. protected _activeEffect: Effect;
  21526. protected _normalMatrix: Matrix;
  21527. /**
  21528. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  21529. * This means that the material can keep using a previous shader while a new one is being compiled.
  21530. * This is mostly used when shader parallel compilation is supported (true by default)
  21531. */
  21532. allowShaderHotSwapping: boolean;
  21533. constructor(name: string, scene: Scene);
  21534. getEffect(): Effect;
  21535. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21536. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21537. /**
  21538. * Binds the given world matrix to the active effect
  21539. *
  21540. * @param world the matrix to bind
  21541. */
  21542. bindOnlyWorldMatrix(world: Matrix): void;
  21543. /**
  21544. * Binds the given normal matrix to the active effect
  21545. *
  21546. * @param normalMatrix the matrix to bind
  21547. */
  21548. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21549. bind(world: Matrix, mesh?: Mesh): void;
  21550. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21551. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21552. }
  21553. }
  21554. declare module BABYLON {
  21555. /**
  21556. * Root class for all node material optimizers
  21557. */
  21558. export class NodeMaterialOptimizer {
  21559. /**
  21560. * Function used to optimize a NodeMaterial graph
  21561. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21562. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21563. */
  21564. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21565. }
  21566. }
  21567. declare module BABYLON {
  21568. /**
  21569. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21570. */
  21571. export class TransformBlock extends NodeMaterialBlock {
  21572. /**
  21573. * Defines the value to use to complement W value to transform it to a Vector4
  21574. */
  21575. complementW: number;
  21576. /**
  21577. * Defines the value to use to complement z value to transform it to a Vector4
  21578. */
  21579. complementZ: number;
  21580. /**
  21581. * Creates a new TransformBlock
  21582. * @param name defines the block name
  21583. */
  21584. constructor(name: string);
  21585. /**
  21586. * Gets the current class name
  21587. * @returns the class name
  21588. */
  21589. getClassName(): string;
  21590. /**
  21591. * Gets the vector input
  21592. */
  21593. get vector(): NodeMaterialConnectionPoint;
  21594. /**
  21595. * Gets the output component
  21596. */
  21597. get output(): NodeMaterialConnectionPoint;
  21598. /**
  21599. * Gets the xyz output component
  21600. */
  21601. get xyz(): NodeMaterialConnectionPoint;
  21602. /**
  21603. * Gets the matrix transform input
  21604. */
  21605. get transform(): NodeMaterialConnectionPoint;
  21606. protected _buildBlock(state: NodeMaterialBuildState): this;
  21607. serialize(): any;
  21608. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21609. protected _dumpPropertiesCode(): string;
  21610. }
  21611. }
  21612. declare module BABYLON {
  21613. /**
  21614. * Block used to output the vertex position
  21615. */
  21616. export class VertexOutputBlock extends NodeMaterialBlock {
  21617. /**
  21618. * Creates a new VertexOutputBlock
  21619. * @param name defines the block name
  21620. */
  21621. constructor(name: string);
  21622. /**
  21623. * Gets the current class name
  21624. * @returns the class name
  21625. */
  21626. getClassName(): string;
  21627. /**
  21628. * Gets the vector input component
  21629. */
  21630. get vector(): NodeMaterialConnectionPoint;
  21631. protected _buildBlock(state: NodeMaterialBuildState): this;
  21632. }
  21633. }
  21634. declare module BABYLON {
  21635. /**
  21636. * Block used to output the final color
  21637. */
  21638. export class FragmentOutputBlock extends NodeMaterialBlock {
  21639. /**
  21640. * Create a new FragmentOutputBlock
  21641. * @param name defines the block name
  21642. */
  21643. constructor(name: string);
  21644. /**
  21645. * Gets the current class name
  21646. * @returns the class name
  21647. */
  21648. getClassName(): string;
  21649. /**
  21650. * Gets the rgba input component
  21651. */
  21652. get rgba(): NodeMaterialConnectionPoint;
  21653. /**
  21654. * Gets the rgb input component
  21655. */
  21656. get rgb(): NodeMaterialConnectionPoint;
  21657. /**
  21658. * Gets the a input component
  21659. */
  21660. get a(): NodeMaterialConnectionPoint;
  21661. protected _buildBlock(state: NodeMaterialBuildState): this;
  21662. }
  21663. }
  21664. declare module BABYLON {
  21665. /**
  21666. * Block used for the particle ramp gradient section
  21667. */
  21668. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21669. /**
  21670. * Create a new ParticleRampGradientBlock
  21671. * @param name defines the block name
  21672. */
  21673. constructor(name: string);
  21674. /**
  21675. * Gets the current class name
  21676. * @returns the class name
  21677. */
  21678. getClassName(): string;
  21679. /**
  21680. * Gets the color input component
  21681. */
  21682. get color(): NodeMaterialConnectionPoint;
  21683. /**
  21684. * Gets the rampColor output component
  21685. */
  21686. get rampColor(): 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 for the particle blend multiply section
  21698. */
  21699. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21700. /**
  21701. * Create a new ParticleBlendMultiplyBlock
  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 color input component
  21712. */
  21713. get color(): NodeMaterialConnectionPoint;
  21714. /**
  21715. * Gets the alphaTexture input component
  21716. */
  21717. get alphaTexture(): NodeMaterialConnectionPoint;
  21718. /**
  21719. * Gets the alphaColor input component
  21720. */
  21721. get alphaColor(): NodeMaterialConnectionPoint;
  21722. /**
  21723. * Gets the blendColor output component
  21724. */
  21725. get blendColor(): NodeMaterialConnectionPoint;
  21726. /**
  21727. * Initialize the block and prepare the context for build
  21728. * @param state defines the state that will be used for the build
  21729. */
  21730. initialize(state: NodeMaterialBuildState): void;
  21731. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21732. }
  21733. }
  21734. declare module BABYLON {
  21735. /**
  21736. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21737. */
  21738. export class VectorMergerBlock extends NodeMaterialBlock {
  21739. /**
  21740. * Create a new VectorMergerBlock
  21741. * @param name defines the block name
  21742. */
  21743. constructor(name: string);
  21744. /**
  21745. * Gets the current class name
  21746. * @returns the class name
  21747. */
  21748. getClassName(): string;
  21749. /**
  21750. * Gets the xyz component (input)
  21751. */
  21752. get xyzIn(): NodeMaterialConnectionPoint;
  21753. /**
  21754. * Gets the xy component (input)
  21755. */
  21756. get xyIn(): NodeMaterialConnectionPoint;
  21757. /**
  21758. * Gets the x component (input)
  21759. */
  21760. get x(): NodeMaterialConnectionPoint;
  21761. /**
  21762. * Gets the y component (input)
  21763. */
  21764. get y(): NodeMaterialConnectionPoint;
  21765. /**
  21766. * Gets the z component (input)
  21767. */
  21768. get z(): NodeMaterialConnectionPoint;
  21769. /**
  21770. * Gets the w component (input)
  21771. */
  21772. get w(): NodeMaterialConnectionPoint;
  21773. /**
  21774. * Gets the xyzw component (output)
  21775. */
  21776. get xyzw(): NodeMaterialConnectionPoint;
  21777. /**
  21778. * Gets the xyz component (output)
  21779. */
  21780. get xyzOut(): NodeMaterialConnectionPoint;
  21781. /**
  21782. * Gets the xy component (output)
  21783. */
  21784. get xyOut(): NodeMaterialConnectionPoint;
  21785. /**
  21786. * Gets the xy component (output)
  21787. * @deprecated Please use xyOut instead.
  21788. */
  21789. get xy(): NodeMaterialConnectionPoint;
  21790. /**
  21791. * Gets the xyz component (output)
  21792. * @deprecated Please use xyzOut instead.
  21793. */
  21794. get xyz(): NodeMaterialConnectionPoint;
  21795. protected _buildBlock(state: NodeMaterialBuildState): this;
  21796. }
  21797. }
  21798. declare module BABYLON {
  21799. /**
  21800. * Block used to remap a float from a range to a new one
  21801. */
  21802. export class RemapBlock extends NodeMaterialBlock {
  21803. /**
  21804. * Gets or sets the source range
  21805. */
  21806. sourceRange: Vector2;
  21807. /**
  21808. * Gets or sets the target range
  21809. */
  21810. targetRange: Vector2;
  21811. /**
  21812. * Creates a new RemapBlock
  21813. * @param name defines the block name
  21814. */
  21815. constructor(name: string);
  21816. /**
  21817. * Gets the current class name
  21818. * @returns the class name
  21819. */
  21820. getClassName(): string;
  21821. /**
  21822. * Gets the input component
  21823. */
  21824. get input(): NodeMaterialConnectionPoint;
  21825. /**
  21826. * Gets the source min input component
  21827. */
  21828. get sourceMin(): NodeMaterialConnectionPoint;
  21829. /**
  21830. * Gets the source max input component
  21831. */
  21832. get sourceMax(): NodeMaterialConnectionPoint;
  21833. /**
  21834. * Gets the target min input component
  21835. */
  21836. get targetMin(): NodeMaterialConnectionPoint;
  21837. /**
  21838. * Gets the target max input component
  21839. */
  21840. get targetMax(): NodeMaterialConnectionPoint;
  21841. /**
  21842. * Gets the output component
  21843. */
  21844. get output(): NodeMaterialConnectionPoint;
  21845. protected _buildBlock(state: NodeMaterialBuildState): this;
  21846. protected _dumpPropertiesCode(): string;
  21847. serialize(): any;
  21848. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21849. }
  21850. }
  21851. declare module BABYLON {
  21852. /**
  21853. * Block used to multiply 2 values
  21854. */
  21855. export class MultiplyBlock extends NodeMaterialBlock {
  21856. /**
  21857. * Creates a new MultiplyBlock
  21858. * @param name defines the block name
  21859. */
  21860. constructor(name: string);
  21861. /**
  21862. * Gets the current class name
  21863. * @returns the class name
  21864. */
  21865. getClassName(): string;
  21866. /**
  21867. * Gets the left operand input component
  21868. */
  21869. get left(): NodeMaterialConnectionPoint;
  21870. /**
  21871. * Gets the right operand input component
  21872. */
  21873. get right(): NodeMaterialConnectionPoint;
  21874. /**
  21875. * Gets the output component
  21876. */
  21877. get output(): NodeMaterialConnectionPoint;
  21878. protected _buildBlock(state: NodeMaterialBuildState): this;
  21879. }
  21880. }
  21881. declare module BABYLON {
  21882. /**
  21883. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21884. */
  21885. export class ColorSplitterBlock extends NodeMaterialBlock {
  21886. /**
  21887. * Create a new ColorSplitterBlock
  21888. * @param name defines the block name
  21889. */
  21890. constructor(name: string);
  21891. /**
  21892. * Gets the current class name
  21893. * @returns the class name
  21894. */
  21895. getClassName(): string;
  21896. /**
  21897. * Gets the rgba component (input)
  21898. */
  21899. get rgba(): NodeMaterialConnectionPoint;
  21900. /**
  21901. * Gets the rgb component (input)
  21902. */
  21903. get rgbIn(): NodeMaterialConnectionPoint;
  21904. /**
  21905. * Gets the rgb component (output)
  21906. */
  21907. get rgbOut(): NodeMaterialConnectionPoint;
  21908. /**
  21909. * Gets the r component (output)
  21910. */
  21911. get r(): NodeMaterialConnectionPoint;
  21912. /**
  21913. * Gets the g component (output)
  21914. */
  21915. get g(): NodeMaterialConnectionPoint;
  21916. /**
  21917. * Gets the b component (output)
  21918. */
  21919. get b(): NodeMaterialConnectionPoint;
  21920. /**
  21921. * Gets the a component (output)
  21922. */
  21923. get a(): NodeMaterialConnectionPoint;
  21924. protected _inputRename(name: string): string;
  21925. protected _outputRename(name: string): string;
  21926. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21927. }
  21928. }
  21929. declare module BABYLON {
  21930. /**
  21931. * Interface used to configure the node material editor
  21932. */
  21933. export interface INodeMaterialEditorOptions {
  21934. /** Define the URl to load node editor script */
  21935. editorURL?: string;
  21936. }
  21937. /** @hidden */
  21938. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21939. NORMAL: boolean;
  21940. TANGENT: boolean;
  21941. UV1: boolean;
  21942. /** BONES */
  21943. NUM_BONE_INFLUENCERS: number;
  21944. BonesPerMesh: number;
  21945. BONETEXTURE: boolean;
  21946. /** MORPH TARGETS */
  21947. MORPHTARGETS: boolean;
  21948. MORPHTARGETS_NORMAL: boolean;
  21949. MORPHTARGETS_TANGENT: boolean;
  21950. MORPHTARGETS_UV: boolean;
  21951. NUM_MORPH_INFLUENCERS: number;
  21952. /** IMAGE PROCESSING */
  21953. IMAGEPROCESSING: boolean;
  21954. VIGNETTE: boolean;
  21955. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21956. VIGNETTEBLENDMODEOPAQUE: boolean;
  21957. TONEMAPPING: boolean;
  21958. TONEMAPPING_ACES: boolean;
  21959. CONTRAST: boolean;
  21960. EXPOSURE: boolean;
  21961. COLORCURVES: boolean;
  21962. COLORGRADING: boolean;
  21963. COLORGRADING3D: boolean;
  21964. SAMPLER3DGREENDEPTH: boolean;
  21965. SAMPLER3DBGRMAP: boolean;
  21966. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21967. /** MISC. */
  21968. BUMPDIRECTUV: number;
  21969. constructor();
  21970. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  21971. }
  21972. /**
  21973. * Class used to configure NodeMaterial
  21974. */
  21975. export interface INodeMaterialOptions {
  21976. /**
  21977. * Defines if blocks should emit comments
  21978. */
  21979. emitComments: boolean;
  21980. }
  21981. /**
  21982. * Class used to create a node based material built by assembling shader blocks
  21983. */
  21984. export class NodeMaterial extends PushMaterial {
  21985. private static _BuildIdGenerator;
  21986. private _options;
  21987. private _vertexCompilationState;
  21988. private _fragmentCompilationState;
  21989. private _sharedData;
  21990. private _buildId;
  21991. private _buildWasSuccessful;
  21992. private _cachedWorldViewMatrix;
  21993. private _cachedWorldViewProjectionMatrix;
  21994. private _optimizers;
  21995. private _animationFrame;
  21996. /** Define the Url to load node editor script */
  21997. static EditorURL: string;
  21998. /** Define the Url to load snippets */
  21999. static SnippetUrl: string;
  22000. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22001. static IgnoreTexturesAtLoadTime: boolean;
  22002. private BJSNODEMATERIALEDITOR;
  22003. /** Get the inspector from bundle or global */
  22004. private _getGlobalNodeMaterialEditor;
  22005. /**
  22006. * Snippet ID if the material was created from the snippet server
  22007. */
  22008. snippetId: string;
  22009. /**
  22010. * Gets or sets data used by visual editor
  22011. * @see https://nme.babylonjs.com
  22012. */
  22013. editorData: any;
  22014. /**
  22015. * 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)
  22016. */
  22017. ignoreAlpha: boolean;
  22018. /**
  22019. * Defines the maximum number of lights that can be used in the material
  22020. */
  22021. maxSimultaneousLights: number;
  22022. /**
  22023. * Observable raised when the material is built
  22024. */
  22025. onBuildObservable: Observable<NodeMaterial>;
  22026. /**
  22027. * Gets or sets the root nodes of the material vertex shader
  22028. */
  22029. _vertexOutputNodes: NodeMaterialBlock[];
  22030. /**
  22031. * Gets or sets the root nodes of the material fragment (pixel) shader
  22032. */
  22033. _fragmentOutputNodes: NodeMaterialBlock[];
  22034. /** Gets or sets options to control the node material overall behavior */
  22035. get options(): INodeMaterialOptions;
  22036. set options(options: INodeMaterialOptions);
  22037. /**
  22038. * Default configuration related to image processing available in the standard Material.
  22039. */
  22040. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22041. /**
  22042. * Gets the image processing configuration used either in this material.
  22043. */
  22044. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22045. /**
  22046. * Sets the Default image processing configuration used either in the this material.
  22047. *
  22048. * If sets to null, the scene one is in use.
  22049. */
  22050. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22051. /**
  22052. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22053. */
  22054. attachedBlocks: NodeMaterialBlock[];
  22055. /**
  22056. * Specifies the mode of the node material
  22057. * @hidden
  22058. */
  22059. _mode: NodeMaterialModes;
  22060. /**
  22061. * Gets the mode property
  22062. */
  22063. get mode(): NodeMaterialModes;
  22064. /**
  22065. * Create a new node based material
  22066. * @param name defines the material name
  22067. * @param scene defines the hosting scene
  22068. * @param options defines creation option
  22069. */
  22070. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22071. /**
  22072. * Gets the current class name of the material e.g. "NodeMaterial"
  22073. * @returns the class name
  22074. */
  22075. getClassName(): string;
  22076. /**
  22077. * Keep track of the image processing observer to allow dispose and replace.
  22078. */
  22079. private _imageProcessingObserver;
  22080. /**
  22081. * Attaches a new image processing configuration to the Standard Material.
  22082. * @param configuration
  22083. */
  22084. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22085. /**
  22086. * Get a block by its name
  22087. * @param name defines the name of the block to retrieve
  22088. * @returns the required block or null if not found
  22089. */
  22090. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22091. /**
  22092. * Get a block by its name
  22093. * @param predicate defines the predicate used to find the good candidate
  22094. * @returns the required block or null if not found
  22095. */
  22096. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22097. /**
  22098. * Get an input block by its name
  22099. * @param predicate defines the predicate used to find the good candidate
  22100. * @returns the required input block or null if not found
  22101. */
  22102. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22103. /**
  22104. * Gets the list of input blocks attached to this material
  22105. * @returns an array of InputBlocks
  22106. */
  22107. getInputBlocks(): InputBlock[];
  22108. /**
  22109. * Adds a new optimizer to the list of optimizers
  22110. * @param optimizer defines the optimizers to add
  22111. * @returns the current material
  22112. */
  22113. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22114. /**
  22115. * Remove an optimizer from the list of optimizers
  22116. * @param optimizer defines the optimizers to remove
  22117. * @returns the current material
  22118. */
  22119. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22120. /**
  22121. * Add a new block to the list of output nodes
  22122. * @param node defines the node to add
  22123. * @returns the current material
  22124. */
  22125. addOutputNode(node: NodeMaterialBlock): this;
  22126. /**
  22127. * Remove a block from the list of root nodes
  22128. * @param node defines the node to remove
  22129. * @returns the current material
  22130. */
  22131. removeOutputNode(node: NodeMaterialBlock): this;
  22132. private _addVertexOutputNode;
  22133. private _removeVertexOutputNode;
  22134. private _addFragmentOutputNode;
  22135. private _removeFragmentOutputNode;
  22136. /**
  22137. * Specifies if the material will require alpha blending
  22138. * @returns a boolean specifying if alpha blending is needed
  22139. */
  22140. needAlphaBlending(): boolean;
  22141. /**
  22142. * Specifies if this material should be rendered in alpha test mode
  22143. * @returns a boolean specifying if an alpha test is needed.
  22144. */
  22145. needAlphaTesting(): boolean;
  22146. private _initializeBlock;
  22147. private _resetDualBlocks;
  22148. /**
  22149. * Remove a block from the current node material
  22150. * @param block defines the block to remove
  22151. */
  22152. removeBlock(block: NodeMaterialBlock): void;
  22153. /**
  22154. * Build the material and generates the inner effect
  22155. * @param verbose defines if the build should log activity
  22156. */
  22157. build(verbose?: boolean): void;
  22158. /**
  22159. * Runs an otpimization phase to try to improve the shader code
  22160. */
  22161. optimize(): void;
  22162. private _prepareDefinesForAttributes;
  22163. /**
  22164. * Create a post process from the material
  22165. * @param camera The camera to apply the render pass to.
  22166. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22167. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22168. * @param engine The engine which the post process will be applied. (default: current engine)
  22169. * @param reusable If the post process can be reused on the same frame. (default: false)
  22170. * @param textureType Type of textures used when performing the post process. (default: 0)
  22171. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22172. * @returns the post process created
  22173. */
  22174. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22175. /**
  22176. * Create the post process effect from the material
  22177. * @param postProcess The post process to create the effect for
  22178. */
  22179. createEffectForPostProcess(postProcess: PostProcess): void;
  22180. private _createEffectOrPostProcess;
  22181. private _createEffectForParticles;
  22182. /**
  22183. * Create the effect to be used as the custom effect for a particle system
  22184. * @param particleSystem Particle system to create the effect for
  22185. * @param onCompiled defines a function to call when the effect creation is successful
  22186. * @param onError defines a function to call when the effect creation has failed
  22187. */
  22188. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22189. private _processDefines;
  22190. /**
  22191. * Get if the submesh is ready to be used and all its information available.
  22192. * Child classes can use it to update shaders
  22193. * @param mesh defines the mesh to check
  22194. * @param subMesh defines which submesh to check
  22195. * @param useInstances specifies that instances should be used
  22196. * @returns a boolean indicating that the submesh is ready or not
  22197. */
  22198. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22199. /**
  22200. * Get a string representing the shaders built by the current node graph
  22201. */
  22202. get compiledShaders(): string;
  22203. /**
  22204. * Binds the world matrix to the material
  22205. * @param world defines the world transformation matrix
  22206. */
  22207. bindOnlyWorldMatrix(world: Matrix): void;
  22208. /**
  22209. * Binds the submesh to this material by preparing the effect and shader to draw
  22210. * @param world defines the world transformation matrix
  22211. * @param mesh defines the mesh containing the submesh
  22212. * @param subMesh defines the submesh to bind the material to
  22213. */
  22214. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22215. /**
  22216. * Gets the active textures from the material
  22217. * @returns an array of textures
  22218. */
  22219. getActiveTextures(): BaseTexture[];
  22220. /**
  22221. * Gets the list of texture blocks
  22222. * @returns an array of texture blocks
  22223. */
  22224. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22225. /**
  22226. * Specifies if the material uses a texture
  22227. * @param texture defines the texture to check against the material
  22228. * @returns a boolean specifying if the material uses the texture
  22229. */
  22230. hasTexture(texture: BaseTexture): boolean;
  22231. /**
  22232. * Disposes the material
  22233. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22234. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22235. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22236. */
  22237. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22238. /** Creates the node editor window. */
  22239. private _createNodeEditor;
  22240. /**
  22241. * Launch the node material editor
  22242. * @param config Define the configuration of the editor
  22243. * @return a promise fulfilled when the node editor is visible
  22244. */
  22245. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22246. /**
  22247. * Clear the current material
  22248. */
  22249. clear(): void;
  22250. /**
  22251. * Clear the current material and set it to a default state
  22252. */
  22253. setToDefault(): void;
  22254. /**
  22255. * Clear the current material and set it to a default state for post process
  22256. */
  22257. setToDefaultPostProcess(): void;
  22258. /**
  22259. * Clear the current material and set it to a default state for particle
  22260. */
  22261. setToDefaultParticle(): void;
  22262. /**
  22263. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22264. * @param url defines the url to load from
  22265. * @returns a promise that will fullfil when the material is fully loaded
  22266. */
  22267. loadAsync(url: string): Promise<void>;
  22268. private _gatherBlocks;
  22269. /**
  22270. * Generate a string containing the code declaration required to create an equivalent of this material
  22271. * @returns a string
  22272. */
  22273. generateCode(): string;
  22274. /**
  22275. * Serializes this material in a JSON representation
  22276. * @returns the serialized material object
  22277. */
  22278. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22279. private _restoreConnections;
  22280. /**
  22281. * Clear the current graph and load a new one from a serialization object
  22282. * @param source defines the JSON representation of the material
  22283. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22284. */
  22285. loadFromSerialization(source: any, rootUrl?: string): void;
  22286. /**
  22287. * Makes a duplicate of the current material.
  22288. * @param name - name to use for the new material.
  22289. */
  22290. clone(name: string): NodeMaterial;
  22291. /**
  22292. * Creates a node material from parsed material data
  22293. * @param source defines the JSON representation of the material
  22294. * @param scene defines the hosting scene
  22295. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22296. * @returns a new node material
  22297. */
  22298. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22299. /**
  22300. * Creates a node material from a snippet saved in a remote file
  22301. * @param name defines the name of the material to create
  22302. * @param url defines the url to load from
  22303. * @param scene defines the hosting scene
  22304. * @returns a promise that will resolve to the new node material
  22305. */
  22306. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22307. /**
  22308. * Creates a node material from a snippet saved by the node material editor
  22309. * @param snippetId defines the snippet to load
  22310. * @param scene defines the hosting scene
  22311. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22312. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22313. * @returns a promise that will resolve to the new node material
  22314. */
  22315. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22316. /**
  22317. * Creates a new node material set to default basic configuration
  22318. * @param name defines the name of the material
  22319. * @param scene defines the hosting scene
  22320. * @returns a new NodeMaterial
  22321. */
  22322. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22323. }
  22324. }
  22325. declare module BABYLON {
  22326. /**
  22327. * Size options for a post process
  22328. */
  22329. export type PostProcessOptions = {
  22330. width: number;
  22331. height: number;
  22332. };
  22333. /**
  22334. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22335. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22336. */
  22337. export class PostProcess {
  22338. /** Name of the PostProcess. */
  22339. name: string;
  22340. /**
  22341. * Gets or sets the unique id of the post process
  22342. */
  22343. uniqueId: number;
  22344. /**
  22345. * Width of the texture to apply the post process on
  22346. */
  22347. width: number;
  22348. /**
  22349. * Height of the texture to apply the post process on
  22350. */
  22351. height: number;
  22352. /**
  22353. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22354. */
  22355. nodeMaterialSource: Nullable<NodeMaterial>;
  22356. /**
  22357. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22358. * @hidden
  22359. */
  22360. _outputTexture: Nullable<InternalTexture>;
  22361. /**
  22362. * Sampling mode used by the shader
  22363. * See https://doc.babylonjs.com/classes/3.1/texture
  22364. */
  22365. renderTargetSamplingMode: number;
  22366. /**
  22367. * Clear color to use when screen clearing
  22368. */
  22369. clearColor: Color4;
  22370. /**
  22371. * If the buffer needs to be cleared before applying the post process. (default: true)
  22372. * Should be set to false if shader will overwrite all previous pixels.
  22373. */
  22374. autoClear: boolean;
  22375. /**
  22376. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22377. */
  22378. alphaMode: number;
  22379. /**
  22380. * Sets the setAlphaBlendConstants of the babylon engine
  22381. */
  22382. alphaConstants: Color4;
  22383. /**
  22384. * Animations to be used for the post processing
  22385. */
  22386. animations: Animation[];
  22387. /**
  22388. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22389. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22390. */
  22391. enablePixelPerfectMode: boolean;
  22392. /**
  22393. * Force the postprocess to be applied without taking in account viewport
  22394. */
  22395. forceFullscreenViewport: boolean;
  22396. /**
  22397. * List of inspectable custom properties (used by the Inspector)
  22398. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22399. */
  22400. inspectableCustomProperties: IInspectable[];
  22401. /**
  22402. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22403. *
  22404. * | Value | Type | Description |
  22405. * | ----- | ----------------------------------- | ----------- |
  22406. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22407. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22408. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22409. *
  22410. */
  22411. scaleMode: number;
  22412. /**
  22413. * Force textures to be a power of two (default: false)
  22414. */
  22415. alwaysForcePOT: boolean;
  22416. private _samples;
  22417. /**
  22418. * Number of sample textures (default: 1)
  22419. */
  22420. get samples(): number;
  22421. set samples(n: number);
  22422. /**
  22423. * Modify the scale of the post process to be the same as the viewport (default: false)
  22424. */
  22425. adaptScaleToCurrentViewport: boolean;
  22426. private _camera;
  22427. private _scene;
  22428. private _engine;
  22429. private _options;
  22430. private _reusable;
  22431. private _textureType;
  22432. private _textureFormat;
  22433. /**
  22434. * Smart array of input and output textures for the post process.
  22435. * @hidden
  22436. */
  22437. _textures: SmartArray<InternalTexture>;
  22438. /**
  22439. * The index in _textures that corresponds to the output texture.
  22440. * @hidden
  22441. */
  22442. _currentRenderTextureInd: number;
  22443. private _effect;
  22444. private _samplers;
  22445. private _fragmentUrl;
  22446. private _vertexUrl;
  22447. private _parameters;
  22448. private _scaleRatio;
  22449. protected _indexParameters: any;
  22450. private _shareOutputWithPostProcess;
  22451. private _texelSize;
  22452. private _forcedOutputTexture;
  22453. /**
  22454. * Returns the fragment url or shader name used in the post process.
  22455. * @returns the fragment url or name in the shader store.
  22456. */
  22457. getEffectName(): string;
  22458. /**
  22459. * An event triggered when the postprocess is activated.
  22460. */
  22461. onActivateObservable: Observable<Camera>;
  22462. private _onActivateObserver;
  22463. /**
  22464. * A function that is added to the onActivateObservable
  22465. */
  22466. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22467. /**
  22468. * An event triggered when the postprocess changes its size.
  22469. */
  22470. onSizeChangedObservable: Observable<PostProcess>;
  22471. private _onSizeChangedObserver;
  22472. /**
  22473. * A function that is added to the onSizeChangedObservable
  22474. */
  22475. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22476. /**
  22477. * An event triggered when the postprocess applies its effect.
  22478. */
  22479. onApplyObservable: Observable<Effect>;
  22480. private _onApplyObserver;
  22481. /**
  22482. * A function that is added to the onApplyObservable
  22483. */
  22484. set onApply(callback: (effect: Effect) => void);
  22485. /**
  22486. * An event triggered before rendering the postprocess
  22487. */
  22488. onBeforeRenderObservable: Observable<Effect>;
  22489. private _onBeforeRenderObserver;
  22490. /**
  22491. * A function that is added to the onBeforeRenderObservable
  22492. */
  22493. set onBeforeRender(callback: (effect: Effect) => void);
  22494. /**
  22495. * An event triggered after rendering the postprocess
  22496. */
  22497. onAfterRenderObservable: Observable<Effect>;
  22498. private _onAfterRenderObserver;
  22499. /**
  22500. * A function that is added to the onAfterRenderObservable
  22501. */
  22502. set onAfterRender(callback: (efect: Effect) => void);
  22503. /**
  22504. * 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
  22505. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22506. */
  22507. get inputTexture(): InternalTexture;
  22508. set inputTexture(value: InternalTexture);
  22509. /**
  22510. * Gets the camera which post process is applied to.
  22511. * @returns The camera the post process is applied to.
  22512. */
  22513. getCamera(): Camera;
  22514. /**
  22515. * Gets the texel size of the postprocess.
  22516. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22517. */
  22518. get texelSize(): Vector2;
  22519. /**
  22520. * Creates a new instance PostProcess
  22521. * @param name The name of the PostProcess.
  22522. * @param fragmentUrl The url of the fragment shader to be used.
  22523. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22524. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22525. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22526. * @param camera The camera to apply the render pass to.
  22527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22528. * @param engine The engine which the post process will be applied. (default: current engine)
  22529. * @param reusable If the post process can be reused on the same frame. (default: false)
  22530. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22531. * @param textureType Type of textures used when performing the post process. (default: 0)
  22532. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22533. * @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
  22534. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22535. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22536. */
  22537. constructor(
  22538. /** Name of the PostProcess. */
  22539. 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);
  22540. /**
  22541. * Gets a string idenfifying the name of the class
  22542. * @returns "PostProcess" string
  22543. */
  22544. getClassName(): string;
  22545. /**
  22546. * Gets the engine which this post process belongs to.
  22547. * @returns The engine the post process was enabled with.
  22548. */
  22549. getEngine(): Engine;
  22550. /**
  22551. * The effect that is created when initializing the post process.
  22552. * @returns The created effect corresponding the the postprocess.
  22553. */
  22554. getEffect(): Effect;
  22555. /**
  22556. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22557. * @param postProcess The post process to share the output with.
  22558. * @returns This post process.
  22559. */
  22560. shareOutputWith(postProcess: PostProcess): PostProcess;
  22561. /**
  22562. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22563. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22564. */
  22565. useOwnOutput(): void;
  22566. /**
  22567. * Updates the effect with the current post process compile time values and recompiles the shader.
  22568. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22569. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22570. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22571. * @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
  22572. * @param onCompiled Called when the shader has been compiled.
  22573. * @param onError Called if there is an error when compiling a shader.
  22574. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22575. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22576. */
  22577. 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;
  22578. /**
  22579. * The post process is reusable if it can be used multiple times within one frame.
  22580. * @returns If the post process is reusable
  22581. */
  22582. isReusable(): boolean;
  22583. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22584. markTextureDirty(): void;
  22585. /**
  22586. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22587. * 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.
  22588. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22589. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22590. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22591. * @returns The target texture that was bound to be written to.
  22592. */
  22593. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22594. /**
  22595. * If the post process is supported.
  22596. */
  22597. get isSupported(): boolean;
  22598. /**
  22599. * The aspect ratio of the output texture.
  22600. */
  22601. get aspectRatio(): number;
  22602. /**
  22603. * Get a value indicating if the post-process is ready to be used
  22604. * @returns true if the post-process is ready (shader is compiled)
  22605. */
  22606. isReady(): boolean;
  22607. /**
  22608. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22609. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22610. */
  22611. apply(): Nullable<Effect>;
  22612. private _disposeTextures;
  22613. /**
  22614. * Disposes the post process.
  22615. * @param camera The camera to dispose the post process on.
  22616. */
  22617. dispose(camera?: Camera): void;
  22618. }
  22619. }
  22620. declare module BABYLON {
  22621. /** @hidden */
  22622. export var kernelBlurVaryingDeclaration: {
  22623. name: string;
  22624. shader: string;
  22625. };
  22626. }
  22627. declare module BABYLON {
  22628. /** @hidden */
  22629. export var kernelBlurFragment: {
  22630. name: string;
  22631. shader: string;
  22632. };
  22633. }
  22634. declare module BABYLON {
  22635. /** @hidden */
  22636. export var kernelBlurFragment2: {
  22637. name: string;
  22638. shader: string;
  22639. };
  22640. }
  22641. declare module BABYLON {
  22642. /** @hidden */
  22643. export var kernelBlurPixelShader: {
  22644. name: string;
  22645. shader: string;
  22646. };
  22647. }
  22648. declare module BABYLON {
  22649. /** @hidden */
  22650. export var kernelBlurVertex: {
  22651. name: string;
  22652. shader: string;
  22653. };
  22654. }
  22655. declare module BABYLON {
  22656. /** @hidden */
  22657. export var kernelBlurVertexShader: {
  22658. name: string;
  22659. shader: string;
  22660. };
  22661. }
  22662. declare module BABYLON {
  22663. /**
  22664. * The Blur Post Process which blurs an image based on a kernel and direction.
  22665. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22666. */
  22667. export class BlurPostProcess extends PostProcess {
  22668. /** The direction in which to blur the image. */
  22669. direction: Vector2;
  22670. private blockCompilation;
  22671. protected _kernel: number;
  22672. protected _idealKernel: number;
  22673. protected _packedFloat: boolean;
  22674. private _staticDefines;
  22675. /**
  22676. * Sets the length in pixels of the blur sample region
  22677. */
  22678. set kernel(v: number);
  22679. /**
  22680. * Gets the length in pixels of the blur sample region
  22681. */
  22682. get kernel(): number;
  22683. /**
  22684. * Sets wether or not the blur needs to unpack/repack floats
  22685. */
  22686. set packedFloat(v: boolean);
  22687. /**
  22688. * Gets wether or not the blur is unpacking/repacking floats
  22689. */
  22690. get packedFloat(): boolean;
  22691. /**
  22692. * Creates a new instance BlurPostProcess
  22693. * @param name The name of the effect.
  22694. * @param direction The direction in which to blur the image.
  22695. * @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.
  22696. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22697. * @param camera The camera to apply the render pass to.
  22698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22699. * @param engine The engine which the post process will be applied. (default: current engine)
  22700. * @param reusable If the post process can be reused on the same frame. (default: false)
  22701. * @param textureType Type of textures used when performing the post process. (default: 0)
  22702. * @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)
  22703. */
  22704. constructor(name: string,
  22705. /** The direction in which to blur the image. */
  22706. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22707. /**
  22708. * Updates the effect with the current post process compile time values and recompiles the shader.
  22709. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22710. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22711. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22712. * @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
  22713. * @param onCompiled Called when the shader has been compiled.
  22714. * @param onError Called if there is an error when compiling a shader.
  22715. */
  22716. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22717. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22718. /**
  22719. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22720. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22721. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22722. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22723. * The gaps between physical kernels are compensated for in the weighting of the samples
  22724. * @param idealKernel Ideal blur kernel.
  22725. * @return Nearest best kernel.
  22726. */
  22727. protected _nearestBestKernel(idealKernel: number): number;
  22728. /**
  22729. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22730. * @param x The point on the Gaussian distribution to sample.
  22731. * @return the value of the Gaussian function at x.
  22732. */
  22733. protected _gaussianWeight(x: number): number;
  22734. /**
  22735. * Generates a string that can be used as a floating point number in GLSL.
  22736. * @param x Value to print.
  22737. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22738. * @return GLSL float string.
  22739. */
  22740. protected _glslFloat(x: number, decimalFigures?: number): string;
  22741. }
  22742. }
  22743. declare module BABYLON {
  22744. /**
  22745. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22746. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22747. * You can then easily use it as a reflectionTexture on a flat surface.
  22748. * In case the surface is not a plane, please consider relying on reflection probes.
  22749. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22750. */
  22751. export class MirrorTexture extends RenderTargetTexture {
  22752. private scene;
  22753. /**
  22754. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22755. * 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.
  22756. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22757. */
  22758. mirrorPlane: Plane;
  22759. /**
  22760. * Define the blur ratio used to blur the reflection if needed.
  22761. */
  22762. set blurRatio(value: number);
  22763. get blurRatio(): number;
  22764. /**
  22765. * Define the adaptive blur kernel used to blur the reflection if needed.
  22766. * This will autocompute the closest best match for the `blurKernel`
  22767. */
  22768. set adaptiveBlurKernel(value: number);
  22769. /**
  22770. * Define the blur kernel used to blur the reflection if needed.
  22771. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22772. */
  22773. set blurKernel(value: number);
  22774. /**
  22775. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22776. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22777. */
  22778. set blurKernelX(value: number);
  22779. get blurKernelX(): number;
  22780. /**
  22781. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22782. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22783. */
  22784. set blurKernelY(value: number);
  22785. get blurKernelY(): number;
  22786. private _autoComputeBlurKernel;
  22787. protected _onRatioRescale(): void;
  22788. private _updateGammaSpace;
  22789. private _imageProcessingConfigChangeObserver;
  22790. private _transformMatrix;
  22791. private _mirrorMatrix;
  22792. private _savedViewMatrix;
  22793. private _blurX;
  22794. private _blurY;
  22795. private _adaptiveBlurKernel;
  22796. private _blurKernelX;
  22797. private _blurKernelY;
  22798. private _blurRatio;
  22799. /**
  22800. * Instantiates a Mirror Texture.
  22801. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22802. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22803. * You can then easily use it as a reflectionTexture on a flat surface.
  22804. * In case the surface is not a plane, please consider relying on reflection probes.
  22805. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22806. * @param name
  22807. * @param size
  22808. * @param scene
  22809. * @param generateMipMaps
  22810. * @param type
  22811. * @param samplingMode
  22812. * @param generateDepthBuffer
  22813. */
  22814. constructor(name: string, size: number | {
  22815. width: number;
  22816. height: number;
  22817. } | {
  22818. ratio: number;
  22819. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22820. private _preparePostProcesses;
  22821. /**
  22822. * Clone the mirror texture.
  22823. * @returns the cloned texture
  22824. */
  22825. clone(): MirrorTexture;
  22826. /**
  22827. * Serialize the texture to a JSON representation you could use in Parse later on
  22828. * @returns the serialized JSON representation
  22829. */
  22830. serialize(): any;
  22831. /**
  22832. * Dispose the texture and release its associated resources.
  22833. */
  22834. dispose(): void;
  22835. }
  22836. }
  22837. declare module BABYLON {
  22838. /**
  22839. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22840. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22841. */
  22842. export class Texture extends BaseTexture {
  22843. /**
  22844. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22845. */
  22846. static SerializeBuffers: boolean;
  22847. /** @hidden */
  22848. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22849. /** @hidden */
  22850. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22851. /** @hidden */
  22852. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22853. /** nearest is mag = nearest and min = nearest and mip = linear */
  22854. static readonly NEAREST_SAMPLINGMODE: number;
  22855. /** nearest is mag = nearest and min = nearest and mip = linear */
  22856. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22857. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22858. static readonly BILINEAR_SAMPLINGMODE: number;
  22859. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22860. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22861. /** Trilinear is mag = linear and min = linear and mip = linear */
  22862. static readonly TRILINEAR_SAMPLINGMODE: number;
  22863. /** Trilinear is mag = linear and min = linear and mip = linear */
  22864. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22865. /** mag = nearest and min = nearest and mip = nearest */
  22866. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22867. /** mag = nearest and min = linear and mip = nearest */
  22868. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22869. /** mag = nearest and min = linear and mip = linear */
  22870. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22871. /** mag = nearest and min = linear and mip = none */
  22872. static readonly NEAREST_LINEAR: number;
  22873. /** mag = nearest and min = nearest and mip = none */
  22874. static readonly NEAREST_NEAREST: number;
  22875. /** mag = linear and min = nearest and mip = nearest */
  22876. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22877. /** mag = linear and min = nearest and mip = linear */
  22878. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22879. /** mag = linear and min = linear and mip = none */
  22880. static readonly LINEAR_LINEAR: number;
  22881. /** mag = linear and min = nearest and mip = none */
  22882. static readonly LINEAR_NEAREST: number;
  22883. /** Explicit coordinates mode */
  22884. static readonly EXPLICIT_MODE: number;
  22885. /** Spherical coordinates mode */
  22886. static readonly SPHERICAL_MODE: number;
  22887. /** Planar coordinates mode */
  22888. static readonly PLANAR_MODE: number;
  22889. /** Cubic coordinates mode */
  22890. static readonly CUBIC_MODE: number;
  22891. /** Projection coordinates mode */
  22892. static readonly PROJECTION_MODE: number;
  22893. /** Inverse Cubic coordinates mode */
  22894. static readonly SKYBOX_MODE: number;
  22895. /** Inverse Cubic coordinates mode */
  22896. static readonly INVCUBIC_MODE: number;
  22897. /** Equirectangular coordinates mode */
  22898. static readonly EQUIRECTANGULAR_MODE: number;
  22899. /** Equirectangular Fixed coordinates mode */
  22900. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22901. /** Equirectangular Fixed Mirrored coordinates mode */
  22902. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22903. /** Texture is not repeating outside of 0..1 UVs */
  22904. static readonly CLAMP_ADDRESSMODE: number;
  22905. /** Texture is repeating outside of 0..1 UVs */
  22906. static readonly WRAP_ADDRESSMODE: number;
  22907. /** Texture is repeating and mirrored */
  22908. static readonly MIRROR_ADDRESSMODE: number;
  22909. /**
  22910. * 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
  22911. */
  22912. static UseSerializedUrlIfAny: boolean;
  22913. /**
  22914. * Define the url of the texture.
  22915. */
  22916. url: Nullable<string>;
  22917. /**
  22918. * Define an offset on the texture to offset the u coordinates of the UVs
  22919. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22920. */
  22921. uOffset: number;
  22922. /**
  22923. * Define an offset on the texture to offset the v coordinates of the UVs
  22924. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22925. */
  22926. vOffset: number;
  22927. /**
  22928. * Define an offset on the texture to scale the u coordinates of the UVs
  22929. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22930. */
  22931. uScale: number;
  22932. /**
  22933. * Define an offset on the texture to scale the v coordinates of the UVs
  22934. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22935. */
  22936. vScale: number;
  22937. /**
  22938. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22939. * @see http://doc.babylonjs.com/how_to/more_materials
  22940. */
  22941. uAng: number;
  22942. /**
  22943. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22944. * @see http://doc.babylonjs.com/how_to/more_materials
  22945. */
  22946. vAng: number;
  22947. /**
  22948. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22949. * @see http://doc.babylonjs.com/how_to/more_materials
  22950. */
  22951. wAng: number;
  22952. /**
  22953. * Defines the center of rotation (U)
  22954. */
  22955. uRotationCenter: number;
  22956. /**
  22957. * Defines the center of rotation (V)
  22958. */
  22959. vRotationCenter: number;
  22960. /**
  22961. * Defines the center of rotation (W)
  22962. */
  22963. wRotationCenter: number;
  22964. /**
  22965. * Are mip maps generated for this texture or not.
  22966. */
  22967. get noMipmap(): boolean;
  22968. /**
  22969. * List of inspectable custom properties (used by the Inspector)
  22970. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22971. */
  22972. inspectableCustomProperties: Nullable<IInspectable[]>;
  22973. private _noMipmap;
  22974. /** @hidden */
  22975. _invertY: boolean;
  22976. private _rowGenerationMatrix;
  22977. private _cachedTextureMatrix;
  22978. private _projectionModeMatrix;
  22979. private _t0;
  22980. private _t1;
  22981. private _t2;
  22982. private _cachedUOffset;
  22983. private _cachedVOffset;
  22984. private _cachedUScale;
  22985. private _cachedVScale;
  22986. private _cachedUAng;
  22987. private _cachedVAng;
  22988. private _cachedWAng;
  22989. private _cachedProjectionMatrixId;
  22990. private _cachedCoordinatesMode;
  22991. /** @hidden */
  22992. protected _initialSamplingMode: number;
  22993. /** @hidden */
  22994. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  22995. private _deleteBuffer;
  22996. protected _format: Nullable<number>;
  22997. private _delayedOnLoad;
  22998. private _delayedOnError;
  22999. private _mimeType?;
  23000. /**
  23001. * Observable triggered once the texture has been loaded.
  23002. */
  23003. onLoadObservable: Observable<Texture>;
  23004. protected _isBlocking: boolean;
  23005. /**
  23006. * Is the texture preventing material to render while loading.
  23007. * If false, a default texture will be used instead of the loading one during the preparation step.
  23008. */
  23009. set isBlocking(value: boolean);
  23010. get isBlocking(): boolean;
  23011. /**
  23012. * Get the current sampling mode associated with the texture.
  23013. */
  23014. get samplingMode(): number;
  23015. /**
  23016. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23017. */
  23018. get invertY(): boolean;
  23019. /**
  23020. * Instantiates a new texture.
  23021. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23022. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23023. * @param url defines the url of the picture to load as a texture
  23024. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23025. * @param noMipmap defines if the texture will require mip maps or not
  23026. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23027. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23028. * @param onLoad defines a callback triggered when the texture has been loaded
  23029. * @param onError defines a callback triggered when an error occurred during the loading session
  23030. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23031. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23032. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23033. * @param mimeType defines an optional mime type information
  23034. */
  23035. 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);
  23036. /**
  23037. * Update the url (and optional buffer) of this texture if url was null during construction.
  23038. * @param url the url of the texture
  23039. * @param buffer the buffer of the texture (defaults to null)
  23040. * @param onLoad callback called when the texture is loaded (defaults to null)
  23041. */
  23042. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23043. /**
  23044. * Finish the loading sequence of a texture flagged as delayed load.
  23045. * @hidden
  23046. */
  23047. delayLoad(): void;
  23048. private _prepareRowForTextureGeneration;
  23049. /**
  23050. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23051. * @returns the transform matrix of the texture.
  23052. */
  23053. getTextureMatrix(uBase?: number): Matrix;
  23054. /**
  23055. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23056. * @returns The reflection texture transform
  23057. */
  23058. getReflectionTextureMatrix(): Matrix;
  23059. /**
  23060. * Clones the texture.
  23061. * @returns the cloned texture
  23062. */
  23063. clone(): Texture;
  23064. /**
  23065. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23066. * @returns The JSON representation of the texture
  23067. */
  23068. serialize(): any;
  23069. /**
  23070. * Get the current class name of the texture useful for serialization or dynamic coding.
  23071. * @returns "Texture"
  23072. */
  23073. getClassName(): string;
  23074. /**
  23075. * Dispose the texture and release its associated resources.
  23076. */
  23077. dispose(): void;
  23078. /**
  23079. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23080. * @param parsedTexture Define the JSON representation of the texture
  23081. * @param scene Define the scene the parsed texture should be instantiated in
  23082. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23083. * @returns The parsed texture if successful
  23084. */
  23085. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23086. /**
  23087. * Creates a texture from its base 64 representation.
  23088. * @param data Define the base64 payload without the data: prefix
  23089. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23090. * @param scene Define the scene the texture should belong to
  23091. * @param noMipmap Forces the texture to not create mip map information if true
  23092. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23093. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23094. * @param onLoad define a callback triggered when the texture has been loaded
  23095. * @param onError define a callback triggered when an error occurred during the loading session
  23096. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23097. * @returns the created texture
  23098. */
  23099. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23100. /**
  23101. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23102. * @param data Define the base64 payload without the data: prefix
  23103. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23104. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23105. * @param scene Define the scene the texture should belong to
  23106. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23107. * @param noMipmap Forces the texture to not create mip map information if true
  23108. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23109. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23110. * @param onLoad define a callback triggered when the texture has been loaded
  23111. * @param onError define a callback triggered when an error occurred during the loading session
  23112. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23113. * @returns the created texture
  23114. */
  23115. 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;
  23116. }
  23117. }
  23118. declare module BABYLON {
  23119. /**
  23120. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23121. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23122. */
  23123. export class PostProcessManager {
  23124. private _scene;
  23125. private _indexBuffer;
  23126. private _vertexBuffers;
  23127. /**
  23128. * Creates a new instance PostProcess
  23129. * @param scene The scene that the post process is associated with.
  23130. */
  23131. constructor(scene: Scene);
  23132. private _prepareBuffers;
  23133. private _buildIndexBuffer;
  23134. /**
  23135. * Rebuilds the vertex buffers of the manager.
  23136. * @hidden
  23137. */
  23138. _rebuild(): void;
  23139. /**
  23140. * Prepares a frame to be run through a post process.
  23141. * @param sourceTexture The input texture to the post procesess. (default: null)
  23142. * @param postProcesses An array of post processes to be run. (default: null)
  23143. * @returns True if the post processes were able to be run.
  23144. * @hidden
  23145. */
  23146. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23147. /**
  23148. * Manually render a set of post processes to a texture.
  23149. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23150. * @param postProcesses An array of post processes to be run.
  23151. * @param targetTexture The target texture to render to.
  23152. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23153. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23154. * @param lodLevel defines which lod of the texture to render to
  23155. */
  23156. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23157. /**
  23158. * Finalize the result of the output of the postprocesses.
  23159. * @param doNotPresent If true the result will not be displayed to the screen.
  23160. * @param targetTexture The target texture to render to.
  23161. * @param faceIndex The index of the face to bind the target texture to.
  23162. * @param postProcesses The array of post processes to render.
  23163. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23164. * @hidden
  23165. */
  23166. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23167. /**
  23168. * Disposes of the post process manager.
  23169. */
  23170. dispose(): void;
  23171. }
  23172. }
  23173. declare module BABYLON {
  23174. /**
  23175. * This Helps creating a texture that will be created from a camera in your scene.
  23176. * It is basically a dynamic texture that could be used to create special effects for instance.
  23177. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23178. */
  23179. export class RenderTargetTexture extends Texture {
  23180. isCube: boolean;
  23181. /**
  23182. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23183. */
  23184. static readonly REFRESHRATE_RENDER_ONCE: number;
  23185. /**
  23186. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23187. */
  23188. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23189. /**
  23190. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23191. * the central point of your effect and can save a lot of performances.
  23192. */
  23193. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23194. /**
  23195. * Use this predicate to dynamically define the list of mesh you want to render.
  23196. * If set, the renderList property will be overwritten.
  23197. */
  23198. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23199. private _renderList;
  23200. /**
  23201. * Use this list to define the list of mesh you want to render.
  23202. */
  23203. get renderList(): Nullable<Array<AbstractMesh>>;
  23204. set renderList(value: Nullable<Array<AbstractMesh>>);
  23205. /**
  23206. * Use this function to overload the renderList array at rendering time.
  23207. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23208. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23209. * the cube (if the RTT is a cube, else layerOrFace=0).
  23210. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23211. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23212. * hold dummy elements!
  23213. */
  23214. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23215. private _hookArray;
  23216. /**
  23217. * Define if particles should be rendered in your texture.
  23218. */
  23219. renderParticles: boolean;
  23220. /**
  23221. * Define if sprites should be rendered in your texture.
  23222. */
  23223. renderSprites: boolean;
  23224. /**
  23225. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23226. */
  23227. coordinatesMode: number;
  23228. /**
  23229. * Define the camera used to render the texture.
  23230. */
  23231. activeCamera: Nullable<Camera>;
  23232. /**
  23233. * Override the mesh isReady function with your own one.
  23234. */
  23235. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23236. /**
  23237. * Override the render function of the texture with your own one.
  23238. */
  23239. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23240. /**
  23241. * Define if camera post processes should be use while rendering the texture.
  23242. */
  23243. useCameraPostProcesses: boolean;
  23244. /**
  23245. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23246. */
  23247. ignoreCameraViewport: boolean;
  23248. private _postProcessManager;
  23249. private _postProcesses;
  23250. private _resizeObserver;
  23251. /**
  23252. * An event triggered when the texture is unbind.
  23253. */
  23254. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23255. /**
  23256. * An event triggered when the texture is unbind.
  23257. */
  23258. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23259. private _onAfterUnbindObserver;
  23260. /**
  23261. * Set a after unbind callback in the texture.
  23262. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23263. */
  23264. set onAfterUnbind(callback: () => void);
  23265. /**
  23266. * An event triggered before rendering the texture
  23267. */
  23268. onBeforeRenderObservable: Observable<number>;
  23269. private _onBeforeRenderObserver;
  23270. /**
  23271. * Set a before render callback in the texture.
  23272. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23273. */
  23274. set onBeforeRender(callback: (faceIndex: number) => void);
  23275. /**
  23276. * An event triggered after rendering the texture
  23277. */
  23278. onAfterRenderObservable: Observable<number>;
  23279. private _onAfterRenderObserver;
  23280. /**
  23281. * Set a after render callback in the texture.
  23282. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23283. */
  23284. set onAfterRender(callback: (faceIndex: number) => void);
  23285. /**
  23286. * An event triggered after the texture clear
  23287. */
  23288. onClearObservable: Observable<Engine>;
  23289. private _onClearObserver;
  23290. /**
  23291. * Set a clear callback in the texture.
  23292. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23293. */
  23294. set onClear(callback: (Engine: Engine) => void);
  23295. /**
  23296. * An event triggered when the texture is resized.
  23297. */
  23298. onResizeObservable: Observable<RenderTargetTexture>;
  23299. /**
  23300. * Define the clear color of the Render Target if it should be different from the scene.
  23301. */
  23302. clearColor: Color4;
  23303. protected _size: number | {
  23304. width: number;
  23305. height: number;
  23306. layers?: number;
  23307. };
  23308. protected _initialSizeParameter: number | {
  23309. width: number;
  23310. height: number;
  23311. } | {
  23312. ratio: number;
  23313. };
  23314. protected _sizeRatio: Nullable<number>;
  23315. /** @hidden */
  23316. _generateMipMaps: boolean;
  23317. protected _renderingManager: RenderingManager;
  23318. /** @hidden */
  23319. _waitingRenderList: string[];
  23320. protected _doNotChangeAspectRatio: boolean;
  23321. protected _currentRefreshId: number;
  23322. protected _refreshRate: number;
  23323. protected _textureMatrix: Matrix;
  23324. protected _samples: number;
  23325. protected _renderTargetOptions: RenderTargetCreationOptions;
  23326. /**
  23327. * Gets render target creation options that were used.
  23328. */
  23329. get renderTargetOptions(): RenderTargetCreationOptions;
  23330. protected _onRatioRescale(): void;
  23331. /**
  23332. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23333. * It must define where the camera used to render the texture is set
  23334. */
  23335. boundingBoxPosition: Vector3;
  23336. private _boundingBoxSize;
  23337. /**
  23338. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23339. * When defined, the cubemap will switch to local mode
  23340. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23341. * @example https://www.babylonjs-playground.com/#RNASML
  23342. */
  23343. set boundingBoxSize(value: Vector3);
  23344. get boundingBoxSize(): Vector3;
  23345. /**
  23346. * In case the RTT has been created with a depth texture, get the associated
  23347. * depth texture.
  23348. * Otherwise, return null.
  23349. */
  23350. get depthStencilTexture(): Nullable<InternalTexture>;
  23351. /**
  23352. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23353. * or used a shadow, depth texture...
  23354. * @param name The friendly name of the texture
  23355. * @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)
  23356. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23357. * @param generateMipMaps True if mip maps need to be generated after render.
  23358. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23359. * @param type The type of the buffer in the RTT (int, half float, float...)
  23360. * @param isCube True if a cube texture needs to be created
  23361. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23362. * @param generateDepthBuffer True to generate a depth buffer
  23363. * @param generateStencilBuffer True to generate a stencil buffer
  23364. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23365. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23366. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23367. */
  23368. constructor(name: string, size: number | {
  23369. width: number;
  23370. height: number;
  23371. layers?: number;
  23372. } | {
  23373. ratio: number;
  23374. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23375. /**
  23376. * Creates a depth stencil texture.
  23377. * This is only available in WebGL 2 or with the depth texture extension available.
  23378. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23379. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23380. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23381. */
  23382. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23383. private _processSizeParameter;
  23384. /**
  23385. * Define the number of samples to use in case of MSAA.
  23386. * It defaults to one meaning no MSAA has been enabled.
  23387. */
  23388. get samples(): number;
  23389. set samples(value: number);
  23390. /**
  23391. * Resets the refresh counter of the texture and start bak from scratch.
  23392. * Could be useful to regenerate the texture if it is setup to render only once.
  23393. */
  23394. resetRefreshCounter(): void;
  23395. /**
  23396. * Define the refresh rate of the texture or the rendering frequency.
  23397. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23398. */
  23399. get refreshRate(): number;
  23400. set refreshRate(value: number);
  23401. /**
  23402. * Adds a post process to the render target rendering passes.
  23403. * @param postProcess define the post process to add
  23404. */
  23405. addPostProcess(postProcess: PostProcess): void;
  23406. /**
  23407. * Clear all the post processes attached to the render target
  23408. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23409. */
  23410. clearPostProcesses(dispose?: boolean): void;
  23411. /**
  23412. * Remove one of the post process from the list of attached post processes to the texture
  23413. * @param postProcess define the post process to remove from the list
  23414. */
  23415. removePostProcess(postProcess: PostProcess): void;
  23416. /** @hidden */
  23417. _shouldRender(): boolean;
  23418. /**
  23419. * Gets the actual render size of the texture.
  23420. * @returns the width of the render size
  23421. */
  23422. getRenderSize(): number;
  23423. /**
  23424. * Gets the actual render width of the texture.
  23425. * @returns the width of the render size
  23426. */
  23427. getRenderWidth(): number;
  23428. /**
  23429. * Gets the actual render height of the texture.
  23430. * @returns the height of the render size
  23431. */
  23432. getRenderHeight(): number;
  23433. /**
  23434. * Gets the actual number of layers of the texture.
  23435. * @returns the number of layers
  23436. */
  23437. getRenderLayers(): number;
  23438. /**
  23439. * Get if the texture can be rescaled or not.
  23440. */
  23441. get canRescale(): boolean;
  23442. /**
  23443. * Resize the texture using a ratio.
  23444. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23445. */
  23446. scale(ratio: number): void;
  23447. /**
  23448. * Get the texture reflection matrix used to rotate/transform the reflection.
  23449. * @returns the reflection matrix
  23450. */
  23451. getReflectionTextureMatrix(): Matrix;
  23452. /**
  23453. * Resize the texture to a new desired size.
  23454. * Be carrefull as it will recreate all the data in the new texture.
  23455. * @param size Define the new size. It can be:
  23456. * - a number for squared texture,
  23457. * - an object containing { width: number, height: number }
  23458. * - or an object containing a ratio { ratio: number }
  23459. */
  23460. resize(size: number | {
  23461. width: number;
  23462. height: number;
  23463. } | {
  23464. ratio: number;
  23465. }): void;
  23466. private _defaultRenderListPrepared;
  23467. /**
  23468. * Renders all the objects from the render list into the texture.
  23469. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23470. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23471. */
  23472. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23473. private _bestReflectionRenderTargetDimension;
  23474. private _prepareRenderingManager;
  23475. /**
  23476. * @hidden
  23477. * @param faceIndex face index to bind to if this is a cubetexture
  23478. * @param layer defines the index of the texture to bind in the array
  23479. */
  23480. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23481. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23482. private renderToTarget;
  23483. /**
  23484. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23485. * This allowed control for front to back rendering or reversly depending of the special needs.
  23486. *
  23487. * @param renderingGroupId The rendering group id corresponding to its index
  23488. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23489. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23490. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23491. */
  23492. 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;
  23493. /**
  23494. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23495. *
  23496. * @param renderingGroupId The rendering group id corresponding to its index
  23497. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23498. */
  23499. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23500. /**
  23501. * Clones the texture.
  23502. * @returns the cloned texture
  23503. */
  23504. clone(): RenderTargetTexture;
  23505. /**
  23506. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23507. * @returns The JSON representation of the texture
  23508. */
  23509. serialize(): any;
  23510. /**
  23511. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23512. */
  23513. disposeFramebufferObjects(): void;
  23514. /**
  23515. * Dispose the texture and release its associated resources.
  23516. */
  23517. dispose(): void;
  23518. /** @hidden */
  23519. _rebuild(): void;
  23520. /**
  23521. * Clear the info related to rendering groups preventing retention point in material dispose.
  23522. */
  23523. freeRenderingGroups(): void;
  23524. /**
  23525. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23526. * @returns the view count
  23527. */
  23528. getViewCount(): number;
  23529. }
  23530. }
  23531. declare module BABYLON {
  23532. /**
  23533. * Class used to manipulate GUIDs
  23534. */
  23535. export class GUID {
  23536. /**
  23537. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23538. * Be aware Math.random() could cause collisions, but:
  23539. * "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"
  23540. * @returns a pseudo random id
  23541. */
  23542. static RandomId(): string;
  23543. }
  23544. }
  23545. declare module BABYLON {
  23546. /**
  23547. * Options to be used when creating a shadow depth material
  23548. */
  23549. export interface IIOptionShadowDepthMaterial {
  23550. /** Variables in the vertex shader code that need to have their names remapped.
  23551. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23552. * "var_name" should be either: worldPos or vNormalW
  23553. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23554. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23555. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23556. */
  23557. remappedVariables?: string[];
  23558. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23559. standalone?: boolean;
  23560. }
  23561. /**
  23562. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23563. */
  23564. export class ShadowDepthWrapper {
  23565. private _scene;
  23566. private _options?;
  23567. private _baseMaterial;
  23568. private _onEffectCreatedObserver;
  23569. private _subMeshToEffect;
  23570. private _subMeshToDepthEffect;
  23571. private _meshes;
  23572. /** @hidden */
  23573. _matriceNames: any;
  23574. /** Gets the standalone status of the wrapper */
  23575. get standalone(): boolean;
  23576. /** Gets the base material the wrapper is built upon */
  23577. get baseMaterial(): Material;
  23578. /**
  23579. * Instantiate a new shadow depth wrapper.
  23580. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23581. * generate the shadow depth map. For more information, please refer to the documentation:
  23582. * https://doc.babylonjs.com/babylon101/shadows
  23583. * @param baseMaterial Material to wrap
  23584. * @param scene Define the scene the material belongs to
  23585. * @param options Options used to create the wrapper
  23586. */
  23587. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23588. /**
  23589. * Gets the effect to use to generate the depth map
  23590. * @param subMesh subMesh to get the effect for
  23591. * @param shadowGenerator shadow generator to get the effect for
  23592. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23593. */
  23594. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23595. /**
  23596. * Specifies that the submesh is ready to be used for depth rendering
  23597. * @param subMesh submesh to check
  23598. * @param defines the list of defines to take into account when checking the effect
  23599. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23600. * @param useInstances specifies that instances should be used
  23601. * @returns a boolean indicating that the submesh is ready or not
  23602. */
  23603. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23604. /**
  23605. * Disposes the resources
  23606. */
  23607. dispose(): void;
  23608. private _makeEffect;
  23609. }
  23610. }
  23611. declare module BABYLON {
  23612. /**
  23613. * Options for compiling materials.
  23614. */
  23615. export interface IMaterialCompilationOptions {
  23616. /**
  23617. * Defines whether clip planes are enabled.
  23618. */
  23619. clipPlane: boolean;
  23620. /**
  23621. * Defines whether instances are enabled.
  23622. */
  23623. useInstances: boolean;
  23624. }
  23625. /**
  23626. * Base class for the main features of a material in Babylon.js
  23627. */
  23628. export class Material implements IAnimatable {
  23629. /**
  23630. * Returns the triangle fill mode
  23631. */
  23632. static readonly TriangleFillMode: number;
  23633. /**
  23634. * Returns the wireframe mode
  23635. */
  23636. static readonly WireFrameFillMode: number;
  23637. /**
  23638. * Returns the point fill mode
  23639. */
  23640. static readonly PointFillMode: number;
  23641. /**
  23642. * Returns the point list draw mode
  23643. */
  23644. static readonly PointListDrawMode: number;
  23645. /**
  23646. * Returns the line list draw mode
  23647. */
  23648. static readonly LineListDrawMode: number;
  23649. /**
  23650. * Returns the line loop draw mode
  23651. */
  23652. static readonly LineLoopDrawMode: number;
  23653. /**
  23654. * Returns the line strip draw mode
  23655. */
  23656. static readonly LineStripDrawMode: number;
  23657. /**
  23658. * Returns the triangle strip draw mode
  23659. */
  23660. static readonly TriangleStripDrawMode: number;
  23661. /**
  23662. * Returns the triangle fan draw mode
  23663. */
  23664. static readonly TriangleFanDrawMode: number;
  23665. /**
  23666. * Stores the clock-wise side orientation
  23667. */
  23668. static readonly ClockWiseSideOrientation: number;
  23669. /**
  23670. * Stores the counter clock-wise side orientation
  23671. */
  23672. static readonly CounterClockWiseSideOrientation: number;
  23673. /**
  23674. * The dirty texture flag value
  23675. */
  23676. static readonly TextureDirtyFlag: number;
  23677. /**
  23678. * The dirty light flag value
  23679. */
  23680. static readonly LightDirtyFlag: number;
  23681. /**
  23682. * The dirty fresnel flag value
  23683. */
  23684. static readonly FresnelDirtyFlag: number;
  23685. /**
  23686. * The dirty attribute flag value
  23687. */
  23688. static readonly AttributesDirtyFlag: number;
  23689. /**
  23690. * The dirty misc flag value
  23691. */
  23692. static readonly MiscDirtyFlag: number;
  23693. /**
  23694. * The all dirty flag value
  23695. */
  23696. static readonly AllDirtyFlag: number;
  23697. /**
  23698. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23699. */
  23700. static readonly MATERIAL_OPAQUE: number;
  23701. /**
  23702. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23703. */
  23704. static readonly MATERIAL_ALPHATEST: number;
  23705. /**
  23706. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23707. */
  23708. static readonly MATERIAL_ALPHABLEND: number;
  23709. /**
  23710. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23711. * They are also discarded below the alpha cutoff threshold to improve performances.
  23712. */
  23713. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23714. /**
  23715. * Custom callback helping to override the default shader used in the material.
  23716. */
  23717. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  23718. /**
  23719. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23720. */
  23721. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23722. /**
  23723. * The ID of the material
  23724. */
  23725. id: string;
  23726. /**
  23727. * Gets or sets the unique id of the material
  23728. */
  23729. uniqueId: number;
  23730. /**
  23731. * The name of the material
  23732. */
  23733. name: string;
  23734. /**
  23735. * Gets or sets user defined metadata
  23736. */
  23737. metadata: any;
  23738. /**
  23739. * For internal use only. Please do not use.
  23740. */
  23741. reservedDataStore: any;
  23742. /**
  23743. * Specifies if the ready state should be checked on each call
  23744. */
  23745. checkReadyOnEveryCall: boolean;
  23746. /**
  23747. * Specifies if the ready state should be checked once
  23748. */
  23749. checkReadyOnlyOnce: boolean;
  23750. /**
  23751. * The state of the material
  23752. */
  23753. state: string;
  23754. /**
  23755. * The alpha value of the material
  23756. */
  23757. protected _alpha: number;
  23758. /**
  23759. * List of inspectable custom properties (used by the Inspector)
  23760. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23761. */
  23762. inspectableCustomProperties: IInspectable[];
  23763. /**
  23764. * Sets the alpha value of the material
  23765. */
  23766. set alpha(value: number);
  23767. /**
  23768. * Gets the alpha value of the material
  23769. */
  23770. get alpha(): number;
  23771. /**
  23772. * Specifies if back face culling is enabled
  23773. */
  23774. protected _backFaceCulling: boolean;
  23775. /**
  23776. * Sets the back-face culling state
  23777. */
  23778. set backFaceCulling(value: boolean);
  23779. /**
  23780. * Gets the back-face culling state
  23781. */
  23782. get backFaceCulling(): boolean;
  23783. /**
  23784. * Stores the value for side orientation
  23785. */
  23786. sideOrientation: number;
  23787. /**
  23788. * Callback triggered when the material is compiled
  23789. */
  23790. onCompiled: Nullable<(effect: Effect) => void>;
  23791. /**
  23792. * Callback triggered when an error occurs
  23793. */
  23794. onError: Nullable<(effect: Effect, errors: string) => void>;
  23795. /**
  23796. * Callback triggered to get the render target textures
  23797. */
  23798. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23799. /**
  23800. * Gets a boolean indicating that current material needs to register RTT
  23801. */
  23802. get hasRenderTargetTextures(): boolean;
  23803. /**
  23804. * Specifies if the material should be serialized
  23805. */
  23806. doNotSerialize: boolean;
  23807. /**
  23808. * @hidden
  23809. */
  23810. _storeEffectOnSubMeshes: boolean;
  23811. /**
  23812. * Stores the animations for the material
  23813. */
  23814. animations: Nullable<Array<Animation>>;
  23815. /**
  23816. * An event triggered when the material is disposed
  23817. */
  23818. onDisposeObservable: Observable<Material>;
  23819. /**
  23820. * An observer which watches for dispose events
  23821. */
  23822. private _onDisposeObserver;
  23823. private _onUnBindObservable;
  23824. /**
  23825. * Called during a dispose event
  23826. */
  23827. set onDispose(callback: () => void);
  23828. private _onBindObservable;
  23829. /**
  23830. * An event triggered when the material is bound
  23831. */
  23832. get onBindObservable(): Observable<AbstractMesh>;
  23833. /**
  23834. * An observer which watches for bind events
  23835. */
  23836. private _onBindObserver;
  23837. /**
  23838. * Called during a bind event
  23839. */
  23840. set onBind(callback: (Mesh: AbstractMesh) => void);
  23841. /**
  23842. * An event triggered when the material is unbound
  23843. */
  23844. get onUnBindObservable(): Observable<Material>;
  23845. protected _onEffectCreatedObservable: Nullable<Observable<{
  23846. effect: Effect;
  23847. subMesh: Nullable<SubMesh>;
  23848. }>>;
  23849. /**
  23850. * An event triggered when the effect is (re)created
  23851. */
  23852. get onEffectCreatedObservable(): Observable<{
  23853. effect: Effect;
  23854. subMesh: Nullable<SubMesh>;
  23855. }>;
  23856. /**
  23857. * Stores the value of the alpha mode
  23858. */
  23859. private _alphaMode;
  23860. /**
  23861. * Sets the value of the alpha mode.
  23862. *
  23863. * | Value | Type | Description |
  23864. * | --- | --- | --- |
  23865. * | 0 | ALPHA_DISABLE | |
  23866. * | 1 | ALPHA_ADD | |
  23867. * | 2 | ALPHA_COMBINE | |
  23868. * | 3 | ALPHA_SUBTRACT | |
  23869. * | 4 | ALPHA_MULTIPLY | |
  23870. * | 5 | ALPHA_MAXIMIZED | |
  23871. * | 6 | ALPHA_ONEONE | |
  23872. * | 7 | ALPHA_PREMULTIPLIED | |
  23873. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23874. * | 9 | ALPHA_INTERPOLATE | |
  23875. * | 10 | ALPHA_SCREENMODE | |
  23876. *
  23877. */
  23878. set alphaMode(value: number);
  23879. /**
  23880. * Gets the value of the alpha mode
  23881. */
  23882. get alphaMode(): number;
  23883. /**
  23884. * Stores the state of the need depth pre-pass value
  23885. */
  23886. private _needDepthPrePass;
  23887. /**
  23888. * Sets the need depth pre-pass value
  23889. */
  23890. set needDepthPrePass(value: boolean);
  23891. /**
  23892. * Gets the depth pre-pass value
  23893. */
  23894. get needDepthPrePass(): boolean;
  23895. /**
  23896. * Specifies if depth writing should be disabled
  23897. */
  23898. disableDepthWrite: boolean;
  23899. /**
  23900. * Specifies if color writing should be disabled
  23901. */
  23902. disableColorWrite: boolean;
  23903. /**
  23904. * Specifies if depth writing should be forced
  23905. */
  23906. forceDepthWrite: boolean;
  23907. /**
  23908. * Specifies the depth function that should be used. 0 means the default engine function
  23909. */
  23910. depthFunction: number;
  23911. /**
  23912. * Specifies if there should be a separate pass for culling
  23913. */
  23914. separateCullingPass: boolean;
  23915. /**
  23916. * Stores the state specifing if fog should be enabled
  23917. */
  23918. private _fogEnabled;
  23919. /**
  23920. * Sets the state for enabling fog
  23921. */
  23922. set fogEnabled(value: boolean);
  23923. /**
  23924. * Gets the value of the fog enabled state
  23925. */
  23926. get fogEnabled(): boolean;
  23927. /**
  23928. * Stores the size of points
  23929. */
  23930. pointSize: number;
  23931. /**
  23932. * Stores the z offset value
  23933. */
  23934. zOffset: number;
  23935. get wireframe(): boolean;
  23936. /**
  23937. * Sets the state of wireframe mode
  23938. */
  23939. set wireframe(value: boolean);
  23940. /**
  23941. * Gets the value specifying if point clouds are enabled
  23942. */
  23943. get pointsCloud(): boolean;
  23944. /**
  23945. * Sets the state of point cloud mode
  23946. */
  23947. set pointsCloud(value: boolean);
  23948. /**
  23949. * Gets the material fill mode
  23950. */
  23951. get fillMode(): number;
  23952. /**
  23953. * Sets the material fill mode
  23954. */
  23955. set fillMode(value: number);
  23956. /**
  23957. * @hidden
  23958. * Stores the effects for the material
  23959. */
  23960. _effect: Nullable<Effect>;
  23961. /**
  23962. * Specifies if uniform buffers should be used
  23963. */
  23964. private _useUBO;
  23965. /**
  23966. * Stores a reference to the scene
  23967. */
  23968. private _scene;
  23969. /**
  23970. * Stores the fill mode state
  23971. */
  23972. private _fillMode;
  23973. /**
  23974. * Specifies if the depth write state should be cached
  23975. */
  23976. private _cachedDepthWriteState;
  23977. /**
  23978. * Specifies if the color write state should be cached
  23979. */
  23980. private _cachedColorWriteState;
  23981. /**
  23982. * Specifies if the depth function state should be cached
  23983. */
  23984. private _cachedDepthFunctionState;
  23985. /**
  23986. * Stores the uniform buffer
  23987. */
  23988. protected _uniformBuffer: UniformBuffer;
  23989. /** @hidden */
  23990. _indexInSceneMaterialArray: number;
  23991. /** @hidden */
  23992. meshMap: Nullable<{
  23993. [id: string]: AbstractMesh | undefined;
  23994. }>;
  23995. /**
  23996. * Creates a material instance
  23997. * @param name defines the name of the material
  23998. * @param scene defines the scene to reference
  23999. * @param doNotAdd specifies if the material should be added to the scene
  24000. */
  24001. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24002. /**
  24003. * Returns a string representation of the current material
  24004. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24005. * @returns a string with material information
  24006. */
  24007. toString(fullDetails?: boolean): string;
  24008. /**
  24009. * Gets the class name of the material
  24010. * @returns a string with the class name of the material
  24011. */
  24012. getClassName(): string;
  24013. /**
  24014. * Specifies if updates for the material been locked
  24015. */
  24016. get isFrozen(): boolean;
  24017. /**
  24018. * Locks updates for the material
  24019. */
  24020. freeze(): void;
  24021. /**
  24022. * Unlocks updates for the material
  24023. */
  24024. unfreeze(): void;
  24025. /**
  24026. * Specifies if the material is ready to be used
  24027. * @param mesh defines the mesh to check
  24028. * @param useInstances specifies if instances should be used
  24029. * @returns a boolean indicating if the material is ready to be used
  24030. */
  24031. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24032. /**
  24033. * Specifies that the submesh is ready to be used
  24034. * @param mesh defines the mesh to check
  24035. * @param subMesh defines which submesh to check
  24036. * @param useInstances specifies that instances should be used
  24037. * @returns a boolean indicating that the submesh is ready or not
  24038. */
  24039. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  24040. /**
  24041. * Returns the material effect
  24042. * @returns the effect associated with the material
  24043. */
  24044. getEffect(): Nullable<Effect>;
  24045. /**
  24046. * Returns the current scene
  24047. * @returns a Scene
  24048. */
  24049. getScene(): Scene;
  24050. /**
  24051. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24052. */
  24053. protected _forceAlphaTest: boolean;
  24054. /**
  24055. * The transparency mode of the material.
  24056. */
  24057. protected _transparencyMode: Nullable<number>;
  24058. /**
  24059. * Gets the current transparency mode.
  24060. */
  24061. get transparencyMode(): Nullable<number>;
  24062. /**
  24063. * Sets the transparency mode of the material.
  24064. *
  24065. * | Value | Type | Description |
  24066. * | ----- | ----------------------------------- | ----------- |
  24067. * | 0 | OPAQUE | |
  24068. * | 1 | ALPHATEST | |
  24069. * | 2 | ALPHABLEND | |
  24070. * | 3 | ALPHATESTANDBLEND | |
  24071. *
  24072. */
  24073. set transparencyMode(value: Nullable<number>);
  24074. /**
  24075. * Returns true if alpha blending should be disabled.
  24076. */
  24077. protected get _disableAlphaBlending(): boolean;
  24078. /**
  24079. * Specifies whether or not this material should be rendered in alpha blend mode.
  24080. * @returns a boolean specifying if alpha blending is needed
  24081. */
  24082. needAlphaBlending(): boolean;
  24083. /**
  24084. * Specifies if the mesh will require alpha blending
  24085. * @param mesh defines the mesh to check
  24086. * @returns a boolean specifying if alpha blending is needed for the mesh
  24087. */
  24088. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24089. /**
  24090. * Specifies whether or not this material should be rendered in alpha test mode.
  24091. * @returns a boolean specifying if an alpha test is needed.
  24092. */
  24093. needAlphaTesting(): boolean;
  24094. /**
  24095. * Specifies if material alpha testing should be turned on for the mesh
  24096. * @param mesh defines the mesh to check
  24097. */
  24098. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24099. /**
  24100. * Gets the texture used for the alpha test
  24101. * @returns the texture to use for alpha testing
  24102. */
  24103. getAlphaTestTexture(): Nullable<BaseTexture>;
  24104. /**
  24105. * Marks the material to indicate that it needs to be re-calculated
  24106. */
  24107. markDirty(): void;
  24108. /** @hidden */
  24109. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24110. /**
  24111. * Binds the material to the mesh
  24112. * @param world defines the world transformation matrix
  24113. * @param mesh defines the mesh to bind the material to
  24114. */
  24115. bind(world: Matrix, mesh?: Mesh): void;
  24116. /**
  24117. * Binds the submesh to the material
  24118. * @param world defines the world transformation matrix
  24119. * @param mesh defines the mesh containing the submesh
  24120. * @param subMesh defines the submesh to bind the material to
  24121. */
  24122. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24123. /**
  24124. * Binds the world matrix to the material
  24125. * @param world defines the world transformation matrix
  24126. */
  24127. bindOnlyWorldMatrix(world: Matrix): void;
  24128. /**
  24129. * Binds the scene's uniform buffer to the effect.
  24130. * @param effect defines the effect to bind to the scene uniform buffer
  24131. * @param sceneUbo defines the uniform buffer storing scene data
  24132. */
  24133. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24134. /**
  24135. * Binds the view matrix to the effect
  24136. * @param effect defines the effect to bind the view matrix to
  24137. */
  24138. bindView(effect: Effect): void;
  24139. /**
  24140. * Binds the view projection matrix to the effect
  24141. * @param effect defines the effect to bind the view projection matrix to
  24142. */
  24143. bindViewProjection(effect: Effect): void;
  24144. /**
  24145. * Processes to execute after binding the material to a mesh
  24146. * @param mesh defines the rendered mesh
  24147. */
  24148. protected _afterBind(mesh?: Mesh): void;
  24149. /**
  24150. * Unbinds the material from the mesh
  24151. */
  24152. unbind(): void;
  24153. /**
  24154. * Gets the active textures from the material
  24155. * @returns an array of textures
  24156. */
  24157. getActiveTextures(): BaseTexture[];
  24158. /**
  24159. * Specifies if the material uses a texture
  24160. * @param texture defines the texture to check against the material
  24161. * @returns a boolean specifying if the material uses the texture
  24162. */
  24163. hasTexture(texture: BaseTexture): boolean;
  24164. /**
  24165. * Makes a duplicate of the material, and gives it a new name
  24166. * @param name defines the new name for the duplicated material
  24167. * @returns the cloned material
  24168. */
  24169. clone(name: string): Nullable<Material>;
  24170. /**
  24171. * Gets the meshes bound to the material
  24172. * @returns an array of meshes bound to the material
  24173. */
  24174. getBindedMeshes(): AbstractMesh[];
  24175. /**
  24176. * Force shader compilation
  24177. * @param mesh defines the mesh associated with this material
  24178. * @param onCompiled defines a function to execute once the material is compiled
  24179. * @param options defines the options to configure the compilation
  24180. * @param onError defines a function to execute if the material fails compiling
  24181. */
  24182. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24183. /**
  24184. * Force shader compilation
  24185. * @param mesh defines the mesh that will use this material
  24186. * @param options defines additional options for compiling the shaders
  24187. * @returns a promise that resolves when the compilation completes
  24188. */
  24189. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24190. private static readonly _AllDirtyCallBack;
  24191. private static readonly _ImageProcessingDirtyCallBack;
  24192. private static readonly _TextureDirtyCallBack;
  24193. private static readonly _FresnelDirtyCallBack;
  24194. private static readonly _MiscDirtyCallBack;
  24195. private static readonly _LightsDirtyCallBack;
  24196. private static readonly _AttributeDirtyCallBack;
  24197. private static _FresnelAndMiscDirtyCallBack;
  24198. private static _TextureAndMiscDirtyCallBack;
  24199. private static readonly _DirtyCallbackArray;
  24200. private static readonly _RunDirtyCallBacks;
  24201. /**
  24202. * Marks a define in the material to indicate that it needs to be re-computed
  24203. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24204. */
  24205. markAsDirty(flag: number): void;
  24206. /**
  24207. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24208. * @param func defines a function which checks material defines against the submeshes
  24209. */
  24210. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24211. /**
  24212. * Indicates that we need to re-calculated for all submeshes
  24213. */
  24214. protected _markAllSubMeshesAsAllDirty(): void;
  24215. /**
  24216. * Indicates that image processing needs to be re-calculated for all submeshes
  24217. */
  24218. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24219. /**
  24220. * Indicates that textures need to be re-calculated for all submeshes
  24221. */
  24222. protected _markAllSubMeshesAsTexturesDirty(): void;
  24223. /**
  24224. * Indicates that fresnel needs to be re-calculated for all submeshes
  24225. */
  24226. protected _markAllSubMeshesAsFresnelDirty(): void;
  24227. /**
  24228. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24229. */
  24230. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24231. /**
  24232. * Indicates that lights need to be re-calculated for all submeshes
  24233. */
  24234. protected _markAllSubMeshesAsLightsDirty(): void;
  24235. /**
  24236. * Indicates that attributes need to be re-calculated for all submeshes
  24237. */
  24238. protected _markAllSubMeshesAsAttributesDirty(): void;
  24239. /**
  24240. * Indicates that misc needs to be re-calculated for all submeshes
  24241. */
  24242. protected _markAllSubMeshesAsMiscDirty(): void;
  24243. /**
  24244. * Indicates that textures and misc need to be re-calculated for all submeshes
  24245. */
  24246. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24247. /**
  24248. * Disposes the material
  24249. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24250. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24251. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24252. */
  24253. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24254. /** @hidden */
  24255. private releaseVertexArrayObject;
  24256. /**
  24257. * Serializes this material
  24258. * @returns the serialized material object
  24259. */
  24260. serialize(): any;
  24261. /**
  24262. * Creates a material from parsed material data
  24263. * @param parsedMaterial defines parsed material data
  24264. * @param scene defines the hosting scene
  24265. * @param rootUrl defines the root URL to use to load textures
  24266. * @returns a new material
  24267. */
  24268. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24269. }
  24270. }
  24271. declare module BABYLON {
  24272. /**
  24273. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24274. * separate meshes. This can be use to improve performances.
  24275. * @see http://doc.babylonjs.com/how_to/multi_materials
  24276. */
  24277. export class MultiMaterial extends Material {
  24278. private _subMaterials;
  24279. /**
  24280. * Gets or Sets the list of Materials used within the multi material.
  24281. * They need to be ordered according to the submeshes order in the associated mesh
  24282. */
  24283. get subMaterials(): Nullable<Material>[];
  24284. set subMaterials(value: Nullable<Material>[]);
  24285. /**
  24286. * Function used to align with Node.getChildren()
  24287. * @returns the list of Materials used within the multi material
  24288. */
  24289. getChildren(): Nullable<Material>[];
  24290. /**
  24291. * Instantiates a new Multi Material
  24292. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24293. * separate meshes. This can be use to improve performances.
  24294. * @see http://doc.babylonjs.com/how_to/multi_materials
  24295. * @param name Define the name in the scene
  24296. * @param scene Define the scene the material belongs to
  24297. */
  24298. constructor(name: string, scene: Scene);
  24299. private _hookArray;
  24300. /**
  24301. * Get one of the submaterial by its index in the submaterials array
  24302. * @param index The index to look the sub material at
  24303. * @returns The Material if the index has been defined
  24304. */
  24305. getSubMaterial(index: number): Nullable<Material>;
  24306. /**
  24307. * Get the list of active textures for the whole sub materials list.
  24308. * @returns All the textures that will be used during the rendering
  24309. */
  24310. getActiveTextures(): BaseTexture[];
  24311. /**
  24312. * Gets the current class name of the material e.g. "MultiMaterial"
  24313. * Mainly use in serialization.
  24314. * @returns the class name
  24315. */
  24316. getClassName(): string;
  24317. /**
  24318. * Checks if the material is ready to render the requested sub mesh
  24319. * @param mesh Define the mesh the submesh belongs to
  24320. * @param subMesh Define the sub mesh to look readyness for
  24321. * @param useInstances Define whether or not the material is used with instances
  24322. * @returns true if ready, otherwise false
  24323. */
  24324. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  24325. /**
  24326. * Clones the current material and its related sub materials
  24327. * @param name Define the name of the newly cloned material
  24328. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24329. * @returns the cloned material
  24330. */
  24331. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24332. /**
  24333. * Serializes the materials into a JSON representation.
  24334. * @returns the JSON representation
  24335. */
  24336. serialize(): any;
  24337. /**
  24338. * Dispose the material and release its associated resources
  24339. * @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)
  24340. * @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)
  24341. * @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)
  24342. */
  24343. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24344. /**
  24345. * Creates a MultiMaterial from parsed MultiMaterial data.
  24346. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24347. * @param scene defines the hosting scene
  24348. * @returns a new MultiMaterial
  24349. */
  24350. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24351. }
  24352. }
  24353. declare module BABYLON {
  24354. /**
  24355. * Base class for submeshes
  24356. */
  24357. export class BaseSubMesh {
  24358. /** @hidden */
  24359. _materialDefines: Nullable<MaterialDefines>;
  24360. /** @hidden */
  24361. _materialEffect: Nullable<Effect>;
  24362. /** @hidden */
  24363. _effectOverride: Nullable<Effect>;
  24364. /**
  24365. * Gets material defines used by the effect associated to the sub mesh
  24366. */
  24367. get materialDefines(): Nullable<MaterialDefines>;
  24368. /**
  24369. * Sets material defines used by the effect associated to the sub mesh
  24370. */
  24371. set materialDefines(defines: Nullable<MaterialDefines>);
  24372. /**
  24373. * Gets associated effect
  24374. */
  24375. get effect(): Nullable<Effect>;
  24376. /**
  24377. * Sets associated effect (effect used to render this submesh)
  24378. * @param effect defines the effect to associate with
  24379. * @param defines defines the set of defines used to compile this effect
  24380. */
  24381. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24382. }
  24383. /**
  24384. * Defines a subdivision inside a mesh
  24385. */
  24386. export class SubMesh extends BaseSubMesh implements ICullable {
  24387. /** the material index to use */
  24388. materialIndex: number;
  24389. /** vertex index start */
  24390. verticesStart: number;
  24391. /** vertices count */
  24392. verticesCount: number;
  24393. /** index start */
  24394. indexStart: number;
  24395. /** indices count */
  24396. indexCount: number;
  24397. /** @hidden */
  24398. _linesIndexCount: number;
  24399. private _mesh;
  24400. private _renderingMesh;
  24401. private _boundingInfo;
  24402. private _linesIndexBuffer;
  24403. /** @hidden */
  24404. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24405. /** @hidden */
  24406. _trianglePlanes: Plane[];
  24407. /** @hidden */
  24408. _lastColliderTransformMatrix: Nullable<Matrix>;
  24409. /** @hidden */
  24410. _renderId: number;
  24411. /** @hidden */
  24412. _alphaIndex: number;
  24413. /** @hidden */
  24414. _distanceToCamera: number;
  24415. /** @hidden */
  24416. _id: number;
  24417. private _currentMaterial;
  24418. /**
  24419. * Add a new submesh to a mesh
  24420. * @param materialIndex defines the material index to use
  24421. * @param verticesStart defines vertex index start
  24422. * @param verticesCount defines vertices count
  24423. * @param indexStart defines index start
  24424. * @param indexCount defines indices count
  24425. * @param mesh defines the parent mesh
  24426. * @param renderingMesh defines an optional rendering mesh
  24427. * @param createBoundingBox defines if bounding box should be created for this submesh
  24428. * @returns the new submesh
  24429. */
  24430. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24431. /**
  24432. * Creates a new submesh
  24433. * @param materialIndex defines the material index to use
  24434. * @param verticesStart defines vertex index start
  24435. * @param verticesCount defines vertices count
  24436. * @param indexStart defines index start
  24437. * @param indexCount defines indices count
  24438. * @param mesh defines the parent mesh
  24439. * @param renderingMesh defines an optional rendering mesh
  24440. * @param createBoundingBox defines if bounding box should be created for this submesh
  24441. */
  24442. constructor(
  24443. /** the material index to use */
  24444. materialIndex: number,
  24445. /** vertex index start */
  24446. verticesStart: number,
  24447. /** vertices count */
  24448. verticesCount: number,
  24449. /** index start */
  24450. indexStart: number,
  24451. /** indices count */
  24452. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  24453. /**
  24454. * Returns true if this submesh covers the entire parent mesh
  24455. * @ignorenaming
  24456. */
  24457. get IsGlobal(): boolean;
  24458. /**
  24459. * Returns the submesh BoudingInfo object
  24460. * @returns current bounding info (or mesh's one if the submesh is global)
  24461. */
  24462. getBoundingInfo(): BoundingInfo;
  24463. /**
  24464. * Sets the submesh BoundingInfo
  24465. * @param boundingInfo defines the new bounding info to use
  24466. * @returns the SubMesh
  24467. */
  24468. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24469. /**
  24470. * Returns the mesh of the current submesh
  24471. * @return the parent mesh
  24472. */
  24473. getMesh(): AbstractMesh;
  24474. /**
  24475. * Returns the rendering mesh of the submesh
  24476. * @returns the rendering mesh (could be different from parent mesh)
  24477. */
  24478. getRenderingMesh(): Mesh;
  24479. /**
  24480. * Returns the submesh material
  24481. * @returns null or the current material
  24482. */
  24483. getMaterial(): Nullable<Material>;
  24484. /**
  24485. * Sets a new updated BoundingInfo object to the submesh
  24486. * @param data defines an optional position array to use to determine the bounding info
  24487. * @returns the SubMesh
  24488. */
  24489. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24490. /** @hidden */
  24491. _checkCollision(collider: Collider): boolean;
  24492. /**
  24493. * Updates the submesh BoundingInfo
  24494. * @param world defines the world matrix to use to update the bounding info
  24495. * @returns the submesh
  24496. */
  24497. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24498. /**
  24499. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24500. * @param frustumPlanes defines the frustum planes
  24501. * @returns true if the submesh is intersecting with the frustum
  24502. */
  24503. isInFrustum(frustumPlanes: Plane[]): boolean;
  24504. /**
  24505. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24506. * @param frustumPlanes defines the frustum planes
  24507. * @returns true if the submesh is inside the frustum
  24508. */
  24509. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24510. /**
  24511. * Renders the submesh
  24512. * @param enableAlphaMode defines if alpha needs to be used
  24513. * @returns the submesh
  24514. */
  24515. render(enableAlphaMode: boolean): SubMesh;
  24516. /**
  24517. * @hidden
  24518. */
  24519. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24520. /**
  24521. * Checks if the submesh intersects with a ray
  24522. * @param ray defines the ray to test
  24523. * @returns true is the passed ray intersects the submesh bounding box
  24524. */
  24525. canIntersects(ray: Ray): boolean;
  24526. /**
  24527. * Intersects current submesh with a ray
  24528. * @param ray defines the ray to test
  24529. * @param positions defines mesh's positions array
  24530. * @param indices defines mesh's indices array
  24531. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24532. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24533. * @returns intersection info or null if no intersection
  24534. */
  24535. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24536. /** @hidden */
  24537. private _intersectLines;
  24538. /** @hidden */
  24539. private _intersectUnIndexedLines;
  24540. /** @hidden */
  24541. private _intersectTriangles;
  24542. /** @hidden */
  24543. private _intersectUnIndexedTriangles;
  24544. /** @hidden */
  24545. _rebuild(): void;
  24546. /**
  24547. * Creates a new submesh from the passed mesh
  24548. * @param newMesh defines the new hosting mesh
  24549. * @param newRenderingMesh defines an optional rendering mesh
  24550. * @returns the new submesh
  24551. */
  24552. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24553. /**
  24554. * Release associated resources
  24555. */
  24556. dispose(): void;
  24557. /**
  24558. * Gets the class name
  24559. * @returns the string "SubMesh".
  24560. */
  24561. getClassName(): string;
  24562. /**
  24563. * Creates a new submesh from indices data
  24564. * @param materialIndex the index of the main mesh material
  24565. * @param startIndex the index where to start the copy in the mesh indices array
  24566. * @param indexCount the number of indices to copy then from the startIndex
  24567. * @param mesh the main mesh to create the submesh from
  24568. * @param renderingMesh the optional rendering mesh
  24569. * @returns a new submesh
  24570. */
  24571. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24572. }
  24573. }
  24574. declare module BABYLON {
  24575. /**
  24576. * Class used to represent data loading progression
  24577. */
  24578. export class SceneLoaderFlags {
  24579. private static _ForceFullSceneLoadingForIncremental;
  24580. private static _ShowLoadingScreen;
  24581. private static _CleanBoneMatrixWeights;
  24582. private static _loggingLevel;
  24583. /**
  24584. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24585. */
  24586. static get ForceFullSceneLoadingForIncremental(): boolean;
  24587. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24588. /**
  24589. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24590. */
  24591. static get ShowLoadingScreen(): boolean;
  24592. static set ShowLoadingScreen(value: boolean);
  24593. /**
  24594. * Defines the current logging level (while loading the scene)
  24595. * @ignorenaming
  24596. */
  24597. static get loggingLevel(): number;
  24598. static set loggingLevel(value: number);
  24599. /**
  24600. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24601. */
  24602. static get CleanBoneMatrixWeights(): boolean;
  24603. static set CleanBoneMatrixWeights(value: boolean);
  24604. }
  24605. }
  24606. declare module BABYLON {
  24607. /**
  24608. * Class used to store geometry data (vertex buffers + index buffer)
  24609. */
  24610. export class Geometry implements IGetSetVerticesData {
  24611. /**
  24612. * Gets or sets the ID of the geometry
  24613. */
  24614. id: string;
  24615. /**
  24616. * Gets or sets the unique ID of the geometry
  24617. */
  24618. uniqueId: number;
  24619. /**
  24620. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24621. */
  24622. delayLoadState: number;
  24623. /**
  24624. * Gets the file containing the data to load when running in delay load state
  24625. */
  24626. delayLoadingFile: Nullable<string>;
  24627. /**
  24628. * Callback called when the geometry is updated
  24629. */
  24630. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24631. private _scene;
  24632. private _engine;
  24633. private _meshes;
  24634. private _totalVertices;
  24635. /** @hidden */
  24636. _indices: IndicesArray;
  24637. /** @hidden */
  24638. _vertexBuffers: {
  24639. [key: string]: VertexBuffer;
  24640. };
  24641. private _isDisposed;
  24642. private _extend;
  24643. private _boundingBias;
  24644. /** @hidden */
  24645. _delayInfo: Array<string>;
  24646. private _indexBuffer;
  24647. private _indexBufferIsUpdatable;
  24648. /** @hidden */
  24649. _boundingInfo: Nullable<BoundingInfo>;
  24650. /** @hidden */
  24651. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24652. /** @hidden */
  24653. _softwareSkinningFrameId: number;
  24654. private _vertexArrayObjects;
  24655. private _updatable;
  24656. /** @hidden */
  24657. _positions: Nullable<Vector3[]>;
  24658. /**
  24659. * 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
  24660. */
  24661. get boundingBias(): Vector2;
  24662. /**
  24663. * 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
  24664. */
  24665. set boundingBias(value: Vector2);
  24666. /**
  24667. * Static function used to attach a new empty geometry to a mesh
  24668. * @param mesh defines the mesh to attach the geometry to
  24669. * @returns the new Geometry
  24670. */
  24671. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24672. /** Get the list of meshes using this geometry */
  24673. get meshes(): Mesh[];
  24674. /**
  24675. * Creates a new geometry
  24676. * @param id defines the unique ID
  24677. * @param scene defines the hosting scene
  24678. * @param vertexData defines the VertexData used to get geometry data
  24679. * @param updatable defines if geometry must be updatable (false by default)
  24680. * @param mesh defines the mesh that will be associated with the geometry
  24681. */
  24682. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24683. /**
  24684. * Gets the current extend of the geometry
  24685. */
  24686. get extend(): {
  24687. minimum: Vector3;
  24688. maximum: Vector3;
  24689. };
  24690. /**
  24691. * Gets the hosting scene
  24692. * @returns the hosting Scene
  24693. */
  24694. getScene(): Scene;
  24695. /**
  24696. * Gets the hosting engine
  24697. * @returns the hosting Engine
  24698. */
  24699. getEngine(): Engine;
  24700. /**
  24701. * Defines if the geometry is ready to use
  24702. * @returns true if the geometry is ready to be used
  24703. */
  24704. isReady(): boolean;
  24705. /**
  24706. * Gets a value indicating that the geometry should not be serialized
  24707. */
  24708. get doNotSerialize(): boolean;
  24709. /** @hidden */
  24710. _rebuild(): void;
  24711. /**
  24712. * Affects all geometry data in one call
  24713. * @param vertexData defines the geometry data
  24714. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24715. */
  24716. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24717. /**
  24718. * Set specific vertex data
  24719. * @param kind defines the data kind (Position, normal, etc...)
  24720. * @param data defines the vertex data to use
  24721. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24722. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24723. */
  24724. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24725. /**
  24726. * Removes a specific vertex data
  24727. * @param kind defines the data kind (Position, normal, etc...)
  24728. */
  24729. removeVerticesData(kind: string): void;
  24730. /**
  24731. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24732. * @param buffer defines the vertex buffer to use
  24733. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24734. */
  24735. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24736. /**
  24737. * Update a specific vertex buffer
  24738. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24739. * It will do nothing if the buffer is not updatable
  24740. * @param kind defines the data kind (Position, normal, etc...)
  24741. * @param data defines the data to use
  24742. * @param offset defines the offset in the target buffer where to store the data
  24743. * @param useBytes set to true if the offset is in bytes
  24744. */
  24745. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24746. /**
  24747. * Update a specific vertex buffer
  24748. * This function will create a new buffer if the current one is not updatable
  24749. * @param kind defines the data kind (Position, normal, etc...)
  24750. * @param data defines the data to use
  24751. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24752. */
  24753. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24754. private _updateBoundingInfo;
  24755. /** @hidden */
  24756. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24757. /**
  24758. * Gets total number of vertices
  24759. * @returns the total number of vertices
  24760. */
  24761. getTotalVertices(): number;
  24762. /**
  24763. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24764. * @param kind defines the data kind (Position, normal, etc...)
  24765. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24766. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24767. * @returns a float array containing vertex data
  24768. */
  24769. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24770. /**
  24771. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24772. * @param kind defines the data kind (Position, normal, etc...)
  24773. * @returns true if the vertex buffer with the specified kind is updatable
  24774. */
  24775. isVertexBufferUpdatable(kind: string): boolean;
  24776. /**
  24777. * Gets a specific vertex buffer
  24778. * @param kind defines the data kind (Position, normal, etc...)
  24779. * @returns a VertexBuffer
  24780. */
  24781. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24782. /**
  24783. * Returns all vertex buffers
  24784. * @return an object holding all vertex buffers indexed by kind
  24785. */
  24786. getVertexBuffers(): Nullable<{
  24787. [key: string]: VertexBuffer;
  24788. }>;
  24789. /**
  24790. * Gets a boolean indicating if specific vertex buffer is present
  24791. * @param kind defines the data kind (Position, normal, etc...)
  24792. * @returns true if data is present
  24793. */
  24794. isVerticesDataPresent(kind: string): boolean;
  24795. /**
  24796. * Gets a list of all attached data kinds (Position, normal, etc...)
  24797. * @returns a list of string containing all kinds
  24798. */
  24799. getVerticesDataKinds(): string[];
  24800. /**
  24801. * Update index buffer
  24802. * @param indices defines the indices to store in the index buffer
  24803. * @param offset defines the offset in the target buffer where to store the data
  24804. * @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)
  24805. */
  24806. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24807. /**
  24808. * Creates a new index buffer
  24809. * @param indices defines the indices to store in the index buffer
  24810. * @param totalVertices defines the total number of vertices (could be null)
  24811. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24812. */
  24813. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24814. /**
  24815. * Return the total number of indices
  24816. * @returns the total number of indices
  24817. */
  24818. getTotalIndices(): number;
  24819. /**
  24820. * Gets the index buffer array
  24821. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24822. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24823. * @returns the index buffer array
  24824. */
  24825. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24826. /**
  24827. * Gets the index buffer
  24828. * @return the index buffer
  24829. */
  24830. getIndexBuffer(): Nullable<DataBuffer>;
  24831. /** @hidden */
  24832. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24833. /**
  24834. * Release the associated resources for a specific mesh
  24835. * @param mesh defines the source mesh
  24836. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24837. */
  24838. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24839. /**
  24840. * Apply current geometry to a given mesh
  24841. * @param mesh defines the mesh to apply geometry to
  24842. */
  24843. applyToMesh(mesh: Mesh): void;
  24844. private _updateExtend;
  24845. private _applyToMesh;
  24846. private notifyUpdate;
  24847. /**
  24848. * Load the geometry if it was flagged as delay loaded
  24849. * @param scene defines the hosting scene
  24850. * @param onLoaded defines a callback called when the geometry is loaded
  24851. */
  24852. load(scene: Scene, onLoaded?: () => void): void;
  24853. private _queueLoad;
  24854. /**
  24855. * Invert the geometry to move from a right handed system to a left handed one.
  24856. */
  24857. toLeftHanded(): void;
  24858. /** @hidden */
  24859. _resetPointsArrayCache(): void;
  24860. /** @hidden */
  24861. _generatePointsArray(): boolean;
  24862. /**
  24863. * Gets a value indicating if the geometry is disposed
  24864. * @returns true if the geometry was disposed
  24865. */
  24866. isDisposed(): boolean;
  24867. private _disposeVertexArrayObjects;
  24868. /**
  24869. * Free all associated resources
  24870. */
  24871. dispose(): void;
  24872. /**
  24873. * Clone the current geometry into a new geometry
  24874. * @param id defines the unique ID of the new geometry
  24875. * @returns a new geometry object
  24876. */
  24877. copy(id: string): Geometry;
  24878. /**
  24879. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24880. * @return a JSON representation of the current geometry data (without the vertices data)
  24881. */
  24882. serialize(): any;
  24883. private toNumberArray;
  24884. /**
  24885. * Serialize all vertices data into a JSON oject
  24886. * @returns a JSON representation of the current geometry data
  24887. */
  24888. serializeVerticeData(): any;
  24889. /**
  24890. * Extracts a clone of a mesh geometry
  24891. * @param mesh defines the source mesh
  24892. * @param id defines the unique ID of the new geometry object
  24893. * @returns the new geometry object
  24894. */
  24895. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24896. /**
  24897. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24898. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24899. * Be aware Math.random() could cause collisions, but:
  24900. * "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"
  24901. * @returns a string containing a new GUID
  24902. */
  24903. static RandomId(): string;
  24904. /** @hidden */
  24905. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24906. private static _CleanMatricesWeights;
  24907. /**
  24908. * Create a new geometry from persisted data (Using .babylon file format)
  24909. * @param parsedVertexData defines the persisted data
  24910. * @param scene defines the hosting scene
  24911. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24912. * @returns the new geometry object
  24913. */
  24914. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24915. }
  24916. }
  24917. declare module BABYLON {
  24918. /**
  24919. * Define an interface for all classes that will get and set the data on vertices
  24920. */
  24921. export interface IGetSetVerticesData {
  24922. /**
  24923. * Gets a boolean indicating if specific vertex data is present
  24924. * @param kind defines the vertex data kind to use
  24925. * @returns true is data kind is present
  24926. */
  24927. isVerticesDataPresent(kind: string): boolean;
  24928. /**
  24929. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24930. * @param kind defines the data kind (Position, normal, etc...)
  24931. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24932. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24933. * @returns a float array containing vertex data
  24934. */
  24935. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24936. /**
  24937. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24938. * @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.
  24939. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24940. * @returns the indices array or an empty array if the mesh has no geometry
  24941. */
  24942. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24943. /**
  24944. * Set specific vertex data
  24945. * @param kind defines the data kind (Position, normal, etc...)
  24946. * @param data defines the vertex data to use
  24947. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24948. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24949. */
  24950. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24951. /**
  24952. * Update a specific associated vertex buffer
  24953. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24954. * - VertexBuffer.PositionKind
  24955. * - VertexBuffer.UVKind
  24956. * - VertexBuffer.UV2Kind
  24957. * - VertexBuffer.UV3Kind
  24958. * - VertexBuffer.UV4Kind
  24959. * - VertexBuffer.UV5Kind
  24960. * - VertexBuffer.UV6Kind
  24961. * - VertexBuffer.ColorKind
  24962. * - VertexBuffer.MatricesIndicesKind
  24963. * - VertexBuffer.MatricesIndicesExtraKind
  24964. * - VertexBuffer.MatricesWeightsKind
  24965. * - VertexBuffer.MatricesWeightsExtraKind
  24966. * @param data defines the data source
  24967. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24968. * @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)
  24969. */
  24970. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  24971. /**
  24972. * Creates a new index buffer
  24973. * @param indices defines the indices to store in the index buffer
  24974. * @param totalVertices defines the total number of vertices (could be null)
  24975. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24976. */
  24977. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  24978. }
  24979. /**
  24980. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  24981. */
  24982. export class VertexData {
  24983. /**
  24984. * Mesh side orientation : usually the external or front surface
  24985. */
  24986. static readonly FRONTSIDE: number;
  24987. /**
  24988. * Mesh side orientation : usually the internal or back surface
  24989. */
  24990. static readonly BACKSIDE: number;
  24991. /**
  24992. * Mesh side orientation : both internal and external or front and back surfaces
  24993. */
  24994. static readonly DOUBLESIDE: number;
  24995. /**
  24996. * Mesh side orientation : by default, `FRONTSIDE`
  24997. */
  24998. static readonly DEFAULTSIDE: number;
  24999. /**
  25000. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25001. */
  25002. positions: Nullable<FloatArray>;
  25003. /**
  25004. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25005. */
  25006. normals: Nullable<FloatArray>;
  25007. /**
  25008. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25009. */
  25010. tangents: Nullable<FloatArray>;
  25011. /**
  25012. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25013. */
  25014. uvs: Nullable<FloatArray>;
  25015. /**
  25016. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25017. */
  25018. uvs2: Nullable<FloatArray>;
  25019. /**
  25020. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25021. */
  25022. uvs3: Nullable<FloatArray>;
  25023. /**
  25024. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25025. */
  25026. uvs4: Nullable<FloatArray>;
  25027. /**
  25028. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25029. */
  25030. uvs5: Nullable<FloatArray>;
  25031. /**
  25032. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25033. */
  25034. uvs6: Nullable<FloatArray>;
  25035. /**
  25036. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25037. */
  25038. colors: Nullable<FloatArray>;
  25039. /**
  25040. * 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).
  25041. */
  25042. matricesIndices: Nullable<FloatArray>;
  25043. /**
  25044. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25045. */
  25046. matricesWeights: Nullable<FloatArray>;
  25047. /**
  25048. * An array extending the number of possible indices
  25049. */
  25050. matricesIndicesExtra: Nullable<FloatArray>;
  25051. /**
  25052. * An array extending the number of possible weights when the number of indices is extended
  25053. */
  25054. matricesWeightsExtra: Nullable<FloatArray>;
  25055. /**
  25056. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25057. */
  25058. indices: Nullable<IndicesArray>;
  25059. /**
  25060. * Uses the passed data array to set the set the values for the specified kind of data
  25061. * @param data a linear array of floating numbers
  25062. * @param kind the type of data that is being set, eg positions, colors etc
  25063. */
  25064. set(data: FloatArray, kind: string): void;
  25065. /**
  25066. * Associates the vertexData to the passed Mesh.
  25067. * Sets it as updatable or not (default `false`)
  25068. * @param mesh the mesh the vertexData is applied to
  25069. * @param updatable when used and having the value true allows new data to update the vertexData
  25070. * @returns the VertexData
  25071. */
  25072. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25073. /**
  25074. * Associates the vertexData to the passed Geometry.
  25075. * Sets it as updatable or not (default `false`)
  25076. * @param geometry the geometry the vertexData is applied to
  25077. * @param updatable when used and having the value true allows new data to update the vertexData
  25078. * @returns VertexData
  25079. */
  25080. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25081. /**
  25082. * Updates the associated mesh
  25083. * @param mesh the mesh to be updated
  25084. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25085. * @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
  25086. * @returns VertexData
  25087. */
  25088. updateMesh(mesh: Mesh): VertexData;
  25089. /**
  25090. * Updates the associated geometry
  25091. * @param geometry the geometry to be updated
  25092. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25093. * @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
  25094. * @returns VertexData.
  25095. */
  25096. updateGeometry(geometry: Geometry): VertexData;
  25097. private _applyTo;
  25098. private _update;
  25099. /**
  25100. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25101. * @param matrix the transforming matrix
  25102. * @returns the VertexData
  25103. */
  25104. transform(matrix: Matrix): VertexData;
  25105. /**
  25106. * Merges the passed VertexData into the current one
  25107. * @param other the VertexData to be merged into the current one
  25108. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25109. * @returns the modified VertexData
  25110. */
  25111. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25112. private _mergeElement;
  25113. private _validate;
  25114. /**
  25115. * Serializes the VertexData
  25116. * @returns a serialized object
  25117. */
  25118. serialize(): any;
  25119. /**
  25120. * Extracts the vertexData from a mesh
  25121. * @param mesh the mesh from which to extract the VertexData
  25122. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25123. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25124. * @returns the object VertexData associated to the passed mesh
  25125. */
  25126. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25127. /**
  25128. * Extracts the vertexData from the geometry
  25129. * @param geometry the geometry from which to extract the VertexData
  25130. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25131. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25132. * @returns the object VertexData associated to the passed mesh
  25133. */
  25134. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25135. private static _ExtractFrom;
  25136. /**
  25137. * Creates the VertexData for a Ribbon
  25138. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25139. * * pathArray array of paths, each of which an array of successive Vector3
  25140. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25141. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25142. * * 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
  25143. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25144. * * 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)
  25145. * * 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)
  25146. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25147. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25148. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25149. * @returns the VertexData of the ribbon
  25150. */
  25151. static CreateRibbon(options: {
  25152. pathArray: Vector3[][];
  25153. closeArray?: boolean;
  25154. closePath?: boolean;
  25155. offset?: number;
  25156. sideOrientation?: number;
  25157. frontUVs?: Vector4;
  25158. backUVs?: Vector4;
  25159. invertUV?: boolean;
  25160. uvs?: Vector2[];
  25161. colors?: Color4[];
  25162. }): VertexData;
  25163. /**
  25164. * Creates the VertexData for a box
  25165. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25166. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25167. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25168. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25169. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25170. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25171. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25172. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25173. * * 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)
  25174. * * 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)
  25175. * @returns the VertexData of the box
  25176. */
  25177. static CreateBox(options: {
  25178. size?: number;
  25179. width?: number;
  25180. height?: number;
  25181. depth?: number;
  25182. faceUV?: Vector4[];
  25183. faceColors?: Color4[];
  25184. sideOrientation?: number;
  25185. frontUVs?: Vector4;
  25186. backUVs?: Vector4;
  25187. }): VertexData;
  25188. /**
  25189. * Creates the VertexData for a tiled box
  25190. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25191. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25192. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25193. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25194. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25195. * @returns the VertexData of the box
  25196. */
  25197. static CreateTiledBox(options: {
  25198. pattern?: number;
  25199. width?: number;
  25200. height?: number;
  25201. depth?: number;
  25202. tileSize?: number;
  25203. tileWidth?: number;
  25204. tileHeight?: number;
  25205. alignHorizontal?: number;
  25206. alignVertical?: number;
  25207. faceUV?: Vector4[];
  25208. faceColors?: Color4[];
  25209. sideOrientation?: number;
  25210. }): VertexData;
  25211. /**
  25212. * Creates the VertexData for a tiled plane
  25213. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25214. * * pattern a limited pattern arrangement depending on the number
  25215. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25216. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25217. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25218. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25219. * * 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)
  25220. * * 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)
  25221. * @returns the VertexData of the tiled plane
  25222. */
  25223. static CreateTiledPlane(options: {
  25224. pattern?: number;
  25225. tileSize?: number;
  25226. tileWidth?: number;
  25227. tileHeight?: number;
  25228. size?: number;
  25229. width?: number;
  25230. height?: number;
  25231. alignHorizontal?: number;
  25232. alignVertical?: number;
  25233. sideOrientation?: number;
  25234. frontUVs?: Vector4;
  25235. backUVs?: Vector4;
  25236. }): VertexData;
  25237. /**
  25238. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25239. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25240. * * segments sets the number of horizontal strips optional, default 32
  25241. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25242. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25243. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25244. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25245. * * 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
  25246. * * 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
  25247. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25248. * * 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)
  25249. * * 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)
  25250. * @returns the VertexData of the ellipsoid
  25251. */
  25252. static CreateSphere(options: {
  25253. segments?: number;
  25254. diameter?: number;
  25255. diameterX?: number;
  25256. diameterY?: number;
  25257. diameterZ?: number;
  25258. arc?: number;
  25259. slice?: number;
  25260. sideOrientation?: number;
  25261. frontUVs?: Vector4;
  25262. backUVs?: Vector4;
  25263. }): VertexData;
  25264. /**
  25265. * Creates the VertexData for a cylinder, cone or prism
  25266. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25267. * * height sets the height (y direction) of the cylinder, optional, default 2
  25268. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25269. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25270. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25271. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25272. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25273. * * 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
  25274. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25275. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25276. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25277. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25279. * * 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)
  25280. * * 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)
  25281. * @returns the VertexData of the cylinder, cone or prism
  25282. */
  25283. static CreateCylinder(options: {
  25284. height?: number;
  25285. diameterTop?: number;
  25286. diameterBottom?: number;
  25287. diameter?: number;
  25288. tessellation?: number;
  25289. subdivisions?: number;
  25290. arc?: number;
  25291. faceColors?: Color4[];
  25292. faceUV?: Vector4[];
  25293. hasRings?: boolean;
  25294. enclose?: boolean;
  25295. sideOrientation?: number;
  25296. frontUVs?: Vector4;
  25297. backUVs?: Vector4;
  25298. }): VertexData;
  25299. /**
  25300. * Creates the VertexData for a torus
  25301. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25302. * * diameter the diameter of the torus, optional default 1
  25303. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25304. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25305. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25306. * * 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)
  25307. * * 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)
  25308. * @returns the VertexData of the torus
  25309. */
  25310. static CreateTorus(options: {
  25311. diameter?: number;
  25312. thickness?: number;
  25313. tessellation?: number;
  25314. sideOrientation?: number;
  25315. frontUVs?: Vector4;
  25316. backUVs?: Vector4;
  25317. }): VertexData;
  25318. /**
  25319. * Creates the VertexData of the LineSystem
  25320. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25321. * - lines an array of lines, each line being an array of successive Vector3
  25322. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25323. * @returns the VertexData of the LineSystem
  25324. */
  25325. static CreateLineSystem(options: {
  25326. lines: Vector3[][];
  25327. colors?: Nullable<Color4[][]>;
  25328. }): VertexData;
  25329. /**
  25330. * Create the VertexData for a DashedLines
  25331. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25332. * - points an array successive Vector3
  25333. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25334. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25335. * - dashNb the intended total number of dashes, optional, default 200
  25336. * @returns the VertexData for the DashedLines
  25337. */
  25338. static CreateDashedLines(options: {
  25339. points: Vector3[];
  25340. dashSize?: number;
  25341. gapSize?: number;
  25342. dashNb?: number;
  25343. }): VertexData;
  25344. /**
  25345. * Creates the VertexData for a Ground
  25346. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25347. * - width the width (x direction) of the ground, optional, default 1
  25348. * - height the height (z direction) of the ground, optional, default 1
  25349. * - subdivisions the number of subdivisions per side, optional, default 1
  25350. * @returns the VertexData of the Ground
  25351. */
  25352. static CreateGround(options: {
  25353. width?: number;
  25354. height?: number;
  25355. subdivisions?: number;
  25356. subdivisionsX?: number;
  25357. subdivisionsY?: number;
  25358. }): VertexData;
  25359. /**
  25360. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25361. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25362. * * xmin the ground minimum X coordinate, optional, default -1
  25363. * * zmin the ground minimum Z coordinate, optional, default -1
  25364. * * xmax the ground maximum X coordinate, optional, default 1
  25365. * * zmax the ground maximum Z coordinate, optional, default 1
  25366. * * 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}
  25367. * * 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}
  25368. * @returns the VertexData of the TiledGround
  25369. */
  25370. static CreateTiledGround(options: {
  25371. xmin: number;
  25372. zmin: number;
  25373. xmax: number;
  25374. zmax: number;
  25375. subdivisions?: {
  25376. w: number;
  25377. h: number;
  25378. };
  25379. precision?: {
  25380. w: number;
  25381. h: number;
  25382. };
  25383. }): VertexData;
  25384. /**
  25385. * Creates the VertexData of the Ground designed from a heightmap
  25386. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25387. * * width the width (x direction) of the ground
  25388. * * height the height (z direction) of the ground
  25389. * * subdivisions the number of subdivisions per side
  25390. * * minHeight the minimum altitude on the ground, optional, default 0
  25391. * * maxHeight the maximum altitude on the ground, optional default 1
  25392. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25393. * * buffer the array holding the image color data
  25394. * * bufferWidth the width of image
  25395. * * bufferHeight the height of image
  25396. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25397. * @returns the VertexData of the Ground designed from a heightmap
  25398. */
  25399. static CreateGroundFromHeightMap(options: {
  25400. width: number;
  25401. height: number;
  25402. subdivisions: number;
  25403. minHeight: number;
  25404. maxHeight: number;
  25405. colorFilter: Color3;
  25406. buffer: Uint8Array;
  25407. bufferWidth: number;
  25408. bufferHeight: number;
  25409. alphaFilter: number;
  25410. }): VertexData;
  25411. /**
  25412. * Creates the VertexData for a Plane
  25413. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25414. * * size sets the width and height of the plane to the value of size, optional default 1
  25415. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25416. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25417. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25418. * * 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)
  25419. * * 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)
  25420. * @returns the VertexData of the box
  25421. */
  25422. static CreatePlane(options: {
  25423. size?: number;
  25424. width?: number;
  25425. height?: number;
  25426. sideOrientation?: number;
  25427. frontUVs?: Vector4;
  25428. backUVs?: Vector4;
  25429. }): VertexData;
  25430. /**
  25431. * Creates the VertexData of the Disc or regular Polygon
  25432. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25433. * * radius the radius of the disc, optional default 0.5
  25434. * * tessellation the number of polygon sides, optional, default 64
  25435. * * 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
  25436. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25437. * * 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)
  25438. * * 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)
  25439. * @returns the VertexData of the box
  25440. */
  25441. static CreateDisc(options: {
  25442. radius?: number;
  25443. tessellation?: number;
  25444. arc?: number;
  25445. sideOrientation?: number;
  25446. frontUVs?: Vector4;
  25447. backUVs?: Vector4;
  25448. }): VertexData;
  25449. /**
  25450. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25451. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25452. * @param polygon a mesh built from polygonTriangulation.build()
  25453. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25454. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25455. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25456. * @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)
  25457. * @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)
  25458. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25459. * @returns the VertexData of the Polygon
  25460. */
  25461. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25462. /**
  25463. * Creates the VertexData of the IcoSphere
  25464. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25465. * * radius the radius of the IcoSphere, optional default 1
  25466. * * radiusX allows stretching in the x direction, optional, default radius
  25467. * * radiusY allows stretching in the y direction, optional, default radius
  25468. * * radiusZ allows stretching in the z direction, optional, default radius
  25469. * * flat when true creates a flat shaded mesh, optional, default true
  25470. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25472. * * 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)
  25473. * * 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)
  25474. * @returns the VertexData of the IcoSphere
  25475. */
  25476. static CreateIcoSphere(options: {
  25477. radius?: number;
  25478. radiusX?: number;
  25479. radiusY?: number;
  25480. radiusZ?: number;
  25481. flat?: boolean;
  25482. subdivisions?: number;
  25483. sideOrientation?: number;
  25484. frontUVs?: Vector4;
  25485. backUVs?: Vector4;
  25486. }): VertexData;
  25487. /**
  25488. * Creates the VertexData for a Polyhedron
  25489. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25490. * * type provided types are:
  25491. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25492. * * 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)
  25493. * * size the size of the IcoSphere, optional default 1
  25494. * * sizeX allows stretching in the x direction, optional, default size
  25495. * * sizeY allows stretching in the y direction, optional, default size
  25496. * * sizeZ allows stretching in the z direction, optional, default size
  25497. * * 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
  25498. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25499. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25500. * * flat when true creates a flat shaded mesh, optional, default true
  25501. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25502. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25503. * * 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)
  25504. * * 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)
  25505. * @returns the VertexData of the Polyhedron
  25506. */
  25507. static CreatePolyhedron(options: {
  25508. type?: number;
  25509. size?: number;
  25510. sizeX?: number;
  25511. sizeY?: number;
  25512. sizeZ?: number;
  25513. custom?: any;
  25514. faceUV?: Vector4[];
  25515. faceColors?: Color4[];
  25516. flat?: boolean;
  25517. sideOrientation?: number;
  25518. frontUVs?: Vector4;
  25519. backUVs?: Vector4;
  25520. }): VertexData;
  25521. /**
  25522. * Creates the VertexData for a TorusKnot
  25523. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25524. * * radius the radius of the torus knot, optional, default 2
  25525. * * tube the thickness of the tube, optional, default 0.5
  25526. * * radialSegments the number of sides on each tube segments, optional, default 32
  25527. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25528. * * p the number of windings around the z axis, optional, default 2
  25529. * * q the number of windings around the x axis, optional, default 3
  25530. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25531. * * 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)
  25532. * * 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)
  25533. * @returns the VertexData of the Torus Knot
  25534. */
  25535. static CreateTorusKnot(options: {
  25536. radius?: number;
  25537. tube?: number;
  25538. radialSegments?: number;
  25539. tubularSegments?: number;
  25540. p?: number;
  25541. q?: number;
  25542. sideOrientation?: number;
  25543. frontUVs?: Vector4;
  25544. backUVs?: Vector4;
  25545. }): VertexData;
  25546. /**
  25547. * Compute normals for given positions and indices
  25548. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25549. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25550. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25551. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25552. * * facetNormals : optional array of facet normals (vector3)
  25553. * * facetPositions : optional array of facet positions (vector3)
  25554. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25555. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25556. * * bInfo : optional bounding info, required for facetPartitioning computation
  25557. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25558. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25559. * * useRightHandedSystem: optional boolean to for right handed system computation
  25560. * * depthSort : optional boolean to enable the facet depth sort computation
  25561. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25562. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25563. */
  25564. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25565. facetNormals?: any;
  25566. facetPositions?: any;
  25567. facetPartitioning?: any;
  25568. ratio?: number;
  25569. bInfo?: any;
  25570. bbSize?: Vector3;
  25571. subDiv?: any;
  25572. useRightHandedSystem?: boolean;
  25573. depthSort?: boolean;
  25574. distanceTo?: Vector3;
  25575. depthSortedFacets?: any;
  25576. }): void;
  25577. /** @hidden */
  25578. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25579. /**
  25580. * Applies VertexData created from the imported parameters to the geometry
  25581. * @param parsedVertexData the parsed data from an imported file
  25582. * @param geometry the geometry to apply the VertexData to
  25583. */
  25584. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25585. }
  25586. }
  25587. declare module BABYLON {
  25588. /**
  25589. * Defines a target to use with MorphTargetManager
  25590. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25591. */
  25592. export class MorphTarget implements IAnimatable {
  25593. /** defines the name of the target */
  25594. name: string;
  25595. /**
  25596. * Gets or sets the list of animations
  25597. */
  25598. animations: Animation[];
  25599. private _scene;
  25600. private _positions;
  25601. private _normals;
  25602. private _tangents;
  25603. private _uvs;
  25604. private _influence;
  25605. private _uniqueId;
  25606. /**
  25607. * Observable raised when the influence changes
  25608. */
  25609. onInfluenceChanged: Observable<boolean>;
  25610. /** @hidden */
  25611. _onDataLayoutChanged: Observable<void>;
  25612. /**
  25613. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25614. */
  25615. get influence(): number;
  25616. set influence(influence: number);
  25617. /**
  25618. * Gets or sets the id of the morph Target
  25619. */
  25620. id: string;
  25621. private _animationPropertiesOverride;
  25622. /**
  25623. * Gets or sets the animation properties override
  25624. */
  25625. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25626. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25627. /**
  25628. * Creates a new MorphTarget
  25629. * @param name defines the name of the target
  25630. * @param influence defines the influence to use
  25631. * @param scene defines the scene the morphtarget belongs to
  25632. */
  25633. constructor(
  25634. /** defines the name of the target */
  25635. name: string, influence?: number, scene?: Nullable<Scene>);
  25636. /**
  25637. * Gets the unique ID of this manager
  25638. */
  25639. get uniqueId(): number;
  25640. /**
  25641. * Gets a boolean defining if the target contains position data
  25642. */
  25643. get hasPositions(): boolean;
  25644. /**
  25645. * Gets a boolean defining if the target contains normal data
  25646. */
  25647. get hasNormals(): boolean;
  25648. /**
  25649. * Gets a boolean defining if the target contains tangent data
  25650. */
  25651. get hasTangents(): boolean;
  25652. /**
  25653. * Gets a boolean defining if the target contains texture coordinates data
  25654. */
  25655. get hasUVs(): boolean;
  25656. /**
  25657. * Affects position data to this target
  25658. * @param data defines the position data to use
  25659. */
  25660. setPositions(data: Nullable<FloatArray>): void;
  25661. /**
  25662. * Gets the position data stored in this target
  25663. * @returns a FloatArray containing the position data (or null if not present)
  25664. */
  25665. getPositions(): Nullable<FloatArray>;
  25666. /**
  25667. * Affects normal data to this target
  25668. * @param data defines the normal data to use
  25669. */
  25670. setNormals(data: Nullable<FloatArray>): void;
  25671. /**
  25672. * Gets the normal data stored in this target
  25673. * @returns a FloatArray containing the normal data (or null if not present)
  25674. */
  25675. getNormals(): Nullable<FloatArray>;
  25676. /**
  25677. * Affects tangent data to this target
  25678. * @param data defines the tangent data to use
  25679. */
  25680. setTangents(data: Nullable<FloatArray>): void;
  25681. /**
  25682. * Gets the tangent data stored in this target
  25683. * @returns a FloatArray containing the tangent data (or null if not present)
  25684. */
  25685. getTangents(): Nullable<FloatArray>;
  25686. /**
  25687. * Affects texture coordinates data to this target
  25688. * @param data defines the texture coordinates data to use
  25689. */
  25690. setUVs(data: Nullable<FloatArray>): void;
  25691. /**
  25692. * Gets the texture coordinates data stored in this target
  25693. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25694. */
  25695. getUVs(): Nullable<FloatArray>;
  25696. /**
  25697. * Clone the current target
  25698. * @returns a new MorphTarget
  25699. */
  25700. clone(): MorphTarget;
  25701. /**
  25702. * Serializes the current target into a Serialization object
  25703. * @returns the serialized object
  25704. */
  25705. serialize(): any;
  25706. /**
  25707. * Returns the string "MorphTarget"
  25708. * @returns "MorphTarget"
  25709. */
  25710. getClassName(): string;
  25711. /**
  25712. * Creates a new target from serialized data
  25713. * @param serializationObject defines the serialized data to use
  25714. * @returns a new MorphTarget
  25715. */
  25716. static Parse(serializationObject: any): MorphTarget;
  25717. /**
  25718. * Creates a MorphTarget from mesh data
  25719. * @param mesh defines the source mesh
  25720. * @param name defines the name to use for the new target
  25721. * @param influence defines the influence to attach to the target
  25722. * @returns a new MorphTarget
  25723. */
  25724. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25725. }
  25726. }
  25727. declare module BABYLON {
  25728. /**
  25729. * This class is used to deform meshes using morphing between different targets
  25730. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25731. */
  25732. export class MorphTargetManager {
  25733. private _targets;
  25734. private _targetInfluenceChangedObservers;
  25735. private _targetDataLayoutChangedObservers;
  25736. private _activeTargets;
  25737. private _scene;
  25738. private _influences;
  25739. private _supportsNormals;
  25740. private _supportsTangents;
  25741. private _supportsUVs;
  25742. private _vertexCount;
  25743. private _uniqueId;
  25744. private _tempInfluences;
  25745. /**
  25746. * Gets or sets a boolean indicating if normals must be morphed
  25747. */
  25748. enableNormalMorphing: boolean;
  25749. /**
  25750. * Gets or sets a boolean indicating if tangents must be morphed
  25751. */
  25752. enableTangentMorphing: boolean;
  25753. /**
  25754. * Gets or sets a boolean indicating if UV must be morphed
  25755. */
  25756. enableUVMorphing: boolean;
  25757. /**
  25758. * Creates a new MorphTargetManager
  25759. * @param scene defines the current scene
  25760. */
  25761. constructor(scene?: Nullable<Scene>);
  25762. /**
  25763. * Gets the unique ID of this manager
  25764. */
  25765. get uniqueId(): number;
  25766. /**
  25767. * Gets the number of vertices handled by this manager
  25768. */
  25769. get vertexCount(): number;
  25770. /**
  25771. * Gets a boolean indicating if this manager supports morphing of normals
  25772. */
  25773. get supportsNormals(): boolean;
  25774. /**
  25775. * Gets a boolean indicating if this manager supports morphing of tangents
  25776. */
  25777. get supportsTangents(): boolean;
  25778. /**
  25779. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25780. */
  25781. get supportsUVs(): boolean;
  25782. /**
  25783. * Gets the number of targets stored in this manager
  25784. */
  25785. get numTargets(): number;
  25786. /**
  25787. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25788. */
  25789. get numInfluencers(): number;
  25790. /**
  25791. * Gets the list of influences (one per target)
  25792. */
  25793. get influences(): Float32Array;
  25794. /**
  25795. * Gets the active target at specified index. An active target is a target with an influence > 0
  25796. * @param index defines the index to check
  25797. * @returns the requested target
  25798. */
  25799. getActiveTarget(index: number): MorphTarget;
  25800. /**
  25801. * Gets the target at specified index
  25802. * @param index defines the index to check
  25803. * @returns the requested target
  25804. */
  25805. getTarget(index: number): MorphTarget;
  25806. /**
  25807. * Add a new target to this manager
  25808. * @param target defines the target to add
  25809. */
  25810. addTarget(target: MorphTarget): void;
  25811. /**
  25812. * Removes a target from the manager
  25813. * @param target defines the target to remove
  25814. */
  25815. removeTarget(target: MorphTarget): void;
  25816. /**
  25817. * Clone the current manager
  25818. * @returns a new MorphTargetManager
  25819. */
  25820. clone(): MorphTargetManager;
  25821. /**
  25822. * Serializes the current manager into a Serialization object
  25823. * @returns the serialized object
  25824. */
  25825. serialize(): any;
  25826. private _syncActiveTargets;
  25827. /**
  25828. * Syncrhonize the targets with all the meshes using this morph target manager
  25829. */
  25830. synchronize(): void;
  25831. /**
  25832. * Creates a new MorphTargetManager from serialized data
  25833. * @param serializationObject defines the serialized data
  25834. * @param scene defines the hosting scene
  25835. * @returns the new MorphTargetManager
  25836. */
  25837. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25838. }
  25839. }
  25840. declare module BABYLON {
  25841. /**
  25842. * Class used to represent a specific level of detail of a mesh
  25843. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25844. */
  25845. export class MeshLODLevel {
  25846. /** Defines the distance where this level should start being displayed */
  25847. distance: number;
  25848. /** Defines the mesh to use to render this level */
  25849. mesh: Nullable<Mesh>;
  25850. /**
  25851. * Creates a new LOD level
  25852. * @param distance defines the distance where this level should star being displayed
  25853. * @param mesh defines the mesh to use to render this level
  25854. */
  25855. constructor(
  25856. /** Defines the distance where this level should start being displayed */
  25857. distance: number,
  25858. /** Defines the mesh to use to render this level */
  25859. mesh: Nullable<Mesh>);
  25860. }
  25861. }
  25862. declare module BABYLON {
  25863. /**
  25864. * Mesh representing the gorund
  25865. */
  25866. export class GroundMesh extends Mesh {
  25867. /** If octree should be generated */
  25868. generateOctree: boolean;
  25869. private _heightQuads;
  25870. /** @hidden */
  25871. _subdivisionsX: number;
  25872. /** @hidden */
  25873. _subdivisionsY: number;
  25874. /** @hidden */
  25875. _width: number;
  25876. /** @hidden */
  25877. _height: number;
  25878. /** @hidden */
  25879. _minX: number;
  25880. /** @hidden */
  25881. _maxX: number;
  25882. /** @hidden */
  25883. _minZ: number;
  25884. /** @hidden */
  25885. _maxZ: number;
  25886. constructor(name: string, scene: Scene);
  25887. /**
  25888. * "GroundMesh"
  25889. * @returns "GroundMesh"
  25890. */
  25891. getClassName(): string;
  25892. /**
  25893. * The minimum of x and y subdivisions
  25894. */
  25895. get subdivisions(): number;
  25896. /**
  25897. * X subdivisions
  25898. */
  25899. get subdivisionsX(): number;
  25900. /**
  25901. * Y subdivisions
  25902. */
  25903. get subdivisionsY(): number;
  25904. /**
  25905. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25906. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25907. * @param chunksCount the number of subdivisions for x and y
  25908. * @param octreeBlocksSize (Default: 32)
  25909. */
  25910. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25911. /**
  25912. * Returns a height (y) value in the Worl system :
  25913. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25914. * @param x x coordinate
  25915. * @param z z coordinate
  25916. * @returns the ground y position if (x, z) are outside the ground surface.
  25917. */
  25918. getHeightAtCoordinates(x: number, z: number): number;
  25919. /**
  25920. * Returns a normalized vector (Vector3) orthogonal to the ground
  25921. * at the ground coordinates (x, z) expressed in the World system.
  25922. * @param x x coordinate
  25923. * @param z z coordinate
  25924. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25925. */
  25926. getNormalAtCoordinates(x: number, z: number): Vector3;
  25927. /**
  25928. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25929. * at the ground coordinates (x, z) expressed in the World system.
  25930. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25931. * @param x x coordinate
  25932. * @param z z coordinate
  25933. * @param ref vector to store the result
  25934. * @returns the GroundMesh.
  25935. */
  25936. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25937. /**
  25938. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25939. * if the ground has been updated.
  25940. * This can be used in the render loop.
  25941. * @returns the GroundMesh.
  25942. */
  25943. updateCoordinateHeights(): GroundMesh;
  25944. private _getFacetAt;
  25945. private _initHeightQuads;
  25946. private _computeHeightQuads;
  25947. /**
  25948. * Serializes this ground mesh
  25949. * @param serializationObject object to write serialization to
  25950. */
  25951. serialize(serializationObject: any): void;
  25952. /**
  25953. * Parses a serialized ground mesh
  25954. * @param parsedMesh the serialized mesh
  25955. * @param scene the scene to create the ground mesh in
  25956. * @returns the created ground mesh
  25957. */
  25958. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25959. }
  25960. }
  25961. declare module BABYLON {
  25962. /**
  25963. * Interface for Physics-Joint data
  25964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25965. */
  25966. export interface PhysicsJointData {
  25967. /**
  25968. * The main pivot of the joint
  25969. */
  25970. mainPivot?: Vector3;
  25971. /**
  25972. * The connected pivot of the joint
  25973. */
  25974. connectedPivot?: Vector3;
  25975. /**
  25976. * The main axis of the joint
  25977. */
  25978. mainAxis?: Vector3;
  25979. /**
  25980. * The connected axis of the joint
  25981. */
  25982. connectedAxis?: Vector3;
  25983. /**
  25984. * The collision of the joint
  25985. */
  25986. collision?: boolean;
  25987. /**
  25988. * Native Oimo/Cannon/Energy data
  25989. */
  25990. nativeParams?: any;
  25991. }
  25992. /**
  25993. * This is a holder class for the physics joint created by the physics plugin
  25994. * It holds a set of functions to control the underlying joint
  25995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25996. */
  25997. export class PhysicsJoint {
  25998. /**
  25999. * The type of the physics joint
  26000. */
  26001. type: number;
  26002. /**
  26003. * The data for the physics joint
  26004. */
  26005. jointData: PhysicsJointData;
  26006. private _physicsJoint;
  26007. protected _physicsPlugin: IPhysicsEnginePlugin;
  26008. /**
  26009. * Initializes the physics joint
  26010. * @param type The type of the physics joint
  26011. * @param jointData The data for the physics joint
  26012. */
  26013. constructor(
  26014. /**
  26015. * The type of the physics joint
  26016. */
  26017. type: number,
  26018. /**
  26019. * The data for the physics joint
  26020. */
  26021. jointData: PhysicsJointData);
  26022. /**
  26023. * Gets the physics joint
  26024. */
  26025. get physicsJoint(): any;
  26026. /**
  26027. * Sets the physics joint
  26028. */
  26029. set physicsJoint(newJoint: any);
  26030. /**
  26031. * Sets the physics plugin
  26032. */
  26033. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26034. /**
  26035. * Execute a function that is physics-plugin specific.
  26036. * @param {Function} func the function that will be executed.
  26037. * It accepts two parameters: the physics world and the physics joint
  26038. */
  26039. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26040. /**
  26041. * Distance-Joint type
  26042. */
  26043. static DistanceJoint: number;
  26044. /**
  26045. * Hinge-Joint type
  26046. */
  26047. static HingeJoint: number;
  26048. /**
  26049. * Ball-and-Socket joint type
  26050. */
  26051. static BallAndSocketJoint: number;
  26052. /**
  26053. * Wheel-Joint type
  26054. */
  26055. static WheelJoint: number;
  26056. /**
  26057. * Slider-Joint type
  26058. */
  26059. static SliderJoint: number;
  26060. /**
  26061. * Prismatic-Joint type
  26062. */
  26063. static PrismaticJoint: number;
  26064. /**
  26065. * Universal-Joint type
  26066. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26067. */
  26068. static UniversalJoint: number;
  26069. /**
  26070. * Hinge-Joint 2 type
  26071. */
  26072. static Hinge2Joint: number;
  26073. /**
  26074. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26075. */
  26076. static PointToPointJoint: number;
  26077. /**
  26078. * Spring-Joint type
  26079. */
  26080. static SpringJoint: number;
  26081. /**
  26082. * Lock-Joint type
  26083. */
  26084. static LockJoint: number;
  26085. }
  26086. /**
  26087. * A class representing a physics distance joint
  26088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26089. */
  26090. export class DistanceJoint extends PhysicsJoint {
  26091. /**
  26092. *
  26093. * @param jointData The data for the Distance-Joint
  26094. */
  26095. constructor(jointData: DistanceJointData);
  26096. /**
  26097. * Update the predefined distance.
  26098. * @param maxDistance The maximum preferred distance
  26099. * @param minDistance The minimum preferred distance
  26100. */
  26101. updateDistance(maxDistance: number, minDistance?: number): void;
  26102. }
  26103. /**
  26104. * Represents a Motor-Enabled Joint
  26105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26106. */
  26107. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26108. /**
  26109. * Initializes the Motor-Enabled Joint
  26110. * @param type The type of the joint
  26111. * @param jointData The physica joint data for the joint
  26112. */
  26113. constructor(type: number, jointData: PhysicsJointData);
  26114. /**
  26115. * Set the motor values.
  26116. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26117. * @param force the force to apply
  26118. * @param maxForce max force for this motor.
  26119. */
  26120. setMotor(force?: number, maxForce?: number): void;
  26121. /**
  26122. * Set the motor's limits.
  26123. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26124. * @param upperLimit The upper limit of the motor
  26125. * @param lowerLimit The lower limit of the motor
  26126. */
  26127. setLimit(upperLimit: number, lowerLimit?: number): void;
  26128. }
  26129. /**
  26130. * This class represents a single physics Hinge-Joint
  26131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26132. */
  26133. export class HingeJoint extends MotorEnabledJoint {
  26134. /**
  26135. * Initializes the Hinge-Joint
  26136. * @param jointData The joint data for the Hinge-Joint
  26137. */
  26138. constructor(jointData: PhysicsJointData);
  26139. /**
  26140. * Set the motor values.
  26141. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26142. * @param {number} force the force to apply
  26143. * @param {number} maxForce max force for this motor.
  26144. */
  26145. setMotor(force?: number, maxForce?: number): void;
  26146. /**
  26147. * Set the motor's limits.
  26148. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26149. * @param upperLimit The upper limit of the motor
  26150. * @param lowerLimit The lower limit of the motor
  26151. */
  26152. setLimit(upperLimit: number, lowerLimit?: number): void;
  26153. }
  26154. /**
  26155. * This class represents a dual hinge physics joint (same as wheel joint)
  26156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26157. */
  26158. export class Hinge2Joint extends MotorEnabledJoint {
  26159. /**
  26160. * Initializes the Hinge2-Joint
  26161. * @param jointData The joint data for the Hinge2-Joint
  26162. */
  26163. constructor(jointData: PhysicsJointData);
  26164. /**
  26165. * Set the motor values.
  26166. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26167. * @param {number} targetSpeed the speed the motor is to reach
  26168. * @param {number} maxForce max force for this motor.
  26169. * @param {motorIndex} the motor's index, 0 or 1.
  26170. */
  26171. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26172. /**
  26173. * Set the motor limits.
  26174. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26175. * @param {number} upperLimit the upper limit
  26176. * @param {number} lowerLimit lower limit
  26177. * @param {motorIndex} the motor's index, 0 or 1.
  26178. */
  26179. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26180. }
  26181. /**
  26182. * Interface for a motor enabled joint
  26183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26184. */
  26185. export interface IMotorEnabledJoint {
  26186. /**
  26187. * Physics joint
  26188. */
  26189. physicsJoint: any;
  26190. /**
  26191. * Sets the motor of the motor-enabled joint
  26192. * @param force The force of the motor
  26193. * @param maxForce The maximum force of the motor
  26194. * @param motorIndex The index of the motor
  26195. */
  26196. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26197. /**
  26198. * Sets the limit of the motor
  26199. * @param upperLimit The upper limit of the motor
  26200. * @param lowerLimit The lower limit of the motor
  26201. * @param motorIndex The index of the motor
  26202. */
  26203. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26204. }
  26205. /**
  26206. * Joint data for a Distance-Joint
  26207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26208. */
  26209. export interface DistanceJointData extends PhysicsJointData {
  26210. /**
  26211. * Max distance the 2 joint objects can be apart
  26212. */
  26213. maxDistance: number;
  26214. }
  26215. /**
  26216. * Joint data from a spring joint
  26217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26218. */
  26219. export interface SpringJointData extends PhysicsJointData {
  26220. /**
  26221. * Length of the spring
  26222. */
  26223. length: number;
  26224. /**
  26225. * Stiffness of the spring
  26226. */
  26227. stiffness: number;
  26228. /**
  26229. * Damping of the spring
  26230. */
  26231. damping: number;
  26232. /** this callback will be called when applying the force to the impostors. */
  26233. forceApplicationCallback: () => void;
  26234. }
  26235. }
  26236. declare module BABYLON {
  26237. /**
  26238. * Holds the data for the raycast result
  26239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26240. */
  26241. export class PhysicsRaycastResult {
  26242. private _hasHit;
  26243. private _hitDistance;
  26244. private _hitNormalWorld;
  26245. private _hitPointWorld;
  26246. private _rayFromWorld;
  26247. private _rayToWorld;
  26248. /**
  26249. * Gets if there was a hit
  26250. */
  26251. get hasHit(): boolean;
  26252. /**
  26253. * Gets the distance from the hit
  26254. */
  26255. get hitDistance(): number;
  26256. /**
  26257. * Gets the hit normal/direction in the world
  26258. */
  26259. get hitNormalWorld(): Vector3;
  26260. /**
  26261. * Gets the hit point in the world
  26262. */
  26263. get hitPointWorld(): Vector3;
  26264. /**
  26265. * Gets the ray "start point" of the ray in the world
  26266. */
  26267. get rayFromWorld(): Vector3;
  26268. /**
  26269. * Gets the ray "end point" of the ray in the world
  26270. */
  26271. get rayToWorld(): Vector3;
  26272. /**
  26273. * Sets the hit data (normal & point in world space)
  26274. * @param hitNormalWorld defines the normal in world space
  26275. * @param hitPointWorld defines the point in world space
  26276. */
  26277. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26278. /**
  26279. * Sets the distance from the start point to the hit point
  26280. * @param distance
  26281. */
  26282. setHitDistance(distance: number): void;
  26283. /**
  26284. * Calculates the distance manually
  26285. */
  26286. calculateHitDistance(): void;
  26287. /**
  26288. * Resets all the values to default
  26289. * @param from The from point on world space
  26290. * @param to The to point on world space
  26291. */
  26292. reset(from?: Vector3, to?: Vector3): void;
  26293. }
  26294. /**
  26295. * Interface for the size containing width and height
  26296. */
  26297. interface IXYZ {
  26298. /**
  26299. * X
  26300. */
  26301. x: number;
  26302. /**
  26303. * Y
  26304. */
  26305. y: number;
  26306. /**
  26307. * Z
  26308. */
  26309. z: number;
  26310. }
  26311. }
  26312. declare module BABYLON {
  26313. /**
  26314. * Interface used to describe a physics joint
  26315. */
  26316. export interface PhysicsImpostorJoint {
  26317. /** Defines the main impostor to which the joint is linked */
  26318. mainImpostor: PhysicsImpostor;
  26319. /** Defines the impostor that is connected to the main impostor using this joint */
  26320. connectedImpostor: PhysicsImpostor;
  26321. /** Defines the joint itself */
  26322. joint: PhysicsJoint;
  26323. }
  26324. /** @hidden */
  26325. export interface IPhysicsEnginePlugin {
  26326. world: any;
  26327. name: string;
  26328. setGravity(gravity: Vector3): void;
  26329. setTimeStep(timeStep: number): void;
  26330. getTimeStep(): number;
  26331. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26332. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26333. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26334. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26335. removePhysicsBody(impostor: PhysicsImpostor): void;
  26336. generateJoint(joint: PhysicsImpostorJoint): void;
  26337. removeJoint(joint: PhysicsImpostorJoint): void;
  26338. isSupported(): boolean;
  26339. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26340. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26341. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26342. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26343. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26344. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26345. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26346. getBodyMass(impostor: PhysicsImpostor): number;
  26347. getBodyFriction(impostor: PhysicsImpostor): number;
  26348. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26349. getBodyRestitution(impostor: PhysicsImpostor): number;
  26350. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26351. getBodyPressure?(impostor: PhysicsImpostor): number;
  26352. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26353. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26354. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26355. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26356. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26357. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26358. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26359. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26360. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26361. sleepBody(impostor: PhysicsImpostor): void;
  26362. wakeUpBody(impostor: PhysicsImpostor): void;
  26363. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26364. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26365. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26366. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26367. getRadius(impostor: PhysicsImpostor): number;
  26368. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26369. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26370. dispose(): void;
  26371. }
  26372. /**
  26373. * Interface used to define a physics engine
  26374. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26375. */
  26376. export interface IPhysicsEngine {
  26377. /**
  26378. * Gets the gravity vector used by the simulation
  26379. */
  26380. gravity: Vector3;
  26381. /**
  26382. * Sets the gravity vector used by the simulation
  26383. * @param gravity defines the gravity vector to use
  26384. */
  26385. setGravity(gravity: Vector3): void;
  26386. /**
  26387. * Set the time step of the physics engine.
  26388. * Default is 1/60.
  26389. * To slow it down, enter 1/600 for example.
  26390. * To speed it up, 1/30
  26391. * @param newTimeStep the new timestep to apply to this world.
  26392. */
  26393. setTimeStep(newTimeStep: number): void;
  26394. /**
  26395. * Get the time step of the physics engine.
  26396. * @returns the current time step
  26397. */
  26398. getTimeStep(): number;
  26399. /**
  26400. * Set the sub time step of the physics engine.
  26401. * Default is 0 meaning there is no sub steps
  26402. * To increase physics resolution precision, set a small value (like 1 ms)
  26403. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26404. */
  26405. setSubTimeStep(subTimeStep: number): void;
  26406. /**
  26407. * Get the sub time step of the physics engine.
  26408. * @returns the current sub time step
  26409. */
  26410. getSubTimeStep(): number;
  26411. /**
  26412. * Release all resources
  26413. */
  26414. dispose(): void;
  26415. /**
  26416. * Gets the name of the current physics plugin
  26417. * @returns the name of the plugin
  26418. */
  26419. getPhysicsPluginName(): string;
  26420. /**
  26421. * Adding a new impostor for the impostor tracking.
  26422. * This will be done by the impostor itself.
  26423. * @param impostor the impostor to add
  26424. */
  26425. addImpostor(impostor: PhysicsImpostor): void;
  26426. /**
  26427. * Remove an impostor from the engine.
  26428. * This impostor and its mesh will not longer be updated by the physics engine.
  26429. * @param impostor the impostor to remove
  26430. */
  26431. removeImpostor(impostor: PhysicsImpostor): void;
  26432. /**
  26433. * Add a joint to the physics engine
  26434. * @param mainImpostor defines the main impostor to which the joint is added.
  26435. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26436. * @param joint defines the joint that will connect both impostors.
  26437. */
  26438. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26439. /**
  26440. * Removes a joint from the simulation
  26441. * @param mainImpostor defines the impostor used with the joint
  26442. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26443. * @param joint defines the joint to remove
  26444. */
  26445. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26446. /**
  26447. * Gets the current plugin used to run the simulation
  26448. * @returns current plugin
  26449. */
  26450. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26451. /**
  26452. * Gets the list of physic impostors
  26453. * @returns an array of PhysicsImpostor
  26454. */
  26455. getImpostors(): Array<PhysicsImpostor>;
  26456. /**
  26457. * Gets the impostor for a physics enabled object
  26458. * @param object defines the object impersonated by the impostor
  26459. * @returns the PhysicsImpostor or null if not found
  26460. */
  26461. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26462. /**
  26463. * Gets the impostor for a physics body object
  26464. * @param body defines physics body used by the impostor
  26465. * @returns the PhysicsImpostor or null if not found
  26466. */
  26467. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26468. /**
  26469. * Does a raycast in the physics world
  26470. * @param from when should the ray start?
  26471. * @param to when should the ray end?
  26472. * @returns PhysicsRaycastResult
  26473. */
  26474. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26475. /**
  26476. * Called by the scene. No need to call it.
  26477. * @param delta defines the timespam between frames
  26478. */
  26479. _step(delta: number): void;
  26480. }
  26481. }
  26482. declare module BABYLON {
  26483. /**
  26484. * The interface for the physics imposter parameters
  26485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26486. */
  26487. export interface PhysicsImpostorParameters {
  26488. /**
  26489. * The mass of the physics imposter
  26490. */
  26491. mass: number;
  26492. /**
  26493. * The friction of the physics imposter
  26494. */
  26495. friction?: number;
  26496. /**
  26497. * The coefficient of restitution of the physics imposter
  26498. */
  26499. restitution?: number;
  26500. /**
  26501. * The native options of the physics imposter
  26502. */
  26503. nativeOptions?: any;
  26504. /**
  26505. * Specifies if the parent should be ignored
  26506. */
  26507. ignoreParent?: boolean;
  26508. /**
  26509. * Specifies if bi-directional transformations should be disabled
  26510. */
  26511. disableBidirectionalTransformation?: boolean;
  26512. /**
  26513. * The pressure inside the physics imposter, soft object only
  26514. */
  26515. pressure?: number;
  26516. /**
  26517. * The stiffness the physics imposter, soft object only
  26518. */
  26519. stiffness?: number;
  26520. /**
  26521. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26522. */
  26523. velocityIterations?: number;
  26524. /**
  26525. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26526. */
  26527. positionIterations?: number;
  26528. /**
  26529. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26530. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26531. * Add to fix multiple points
  26532. */
  26533. fixedPoints?: number;
  26534. /**
  26535. * The collision margin around a soft object
  26536. */
  26537. margin?: number;
  26538. /**
  26539. * The collision margin around a soft object
  26540. */
  26541. damping?: number;
  26542. /**
  26543. * The path for a rope based on an extrusion
  26544. */
  26545. path?: any;
  26546. /**
  26547. * The shape of an extrusion used for a rope based on an extrusion
  26548. */
  26549. shape?: any;
  26550. }
  26551. /**
  26552. * Interface for a physics-enabled object
  26553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26554. */
  26555. export interface IPhysicsEnabledObject {
  26556. /**
  26557. * The position of the physics-enabled object
  26558. */
  26559. position: Vector3;
  26560. /**
  26561. * The rotation of the physics-enabled object
  26562. */
  26563. rotationQuaternion: Nullable<Quaternion>;
  26564. /**
  26565. * The scale of the physics-enabled object
  26566. */
  26567. scaling: Vector3;
  26568. /**
  26569. * The rotation of the physics-enabled object
  26570. */
  26571. rotation?: Vector3;
  26572. /**
  26573. * The parent of the physics-enabled object
  26574. */
  26575. parent?: any;
  26576. /**
  26577. * The bounding info of the physics-enabled object
  26578. * @returns The bounding info of the physics-enabled object
  26579. */
  26580. getBoundingInfo(): BoundingInfo;
  26581. /**
  26582. * Computes the world matrix
  26583. * @param force Specifies if the world matrix should be computed by force
  26584. * @returns A world matrix
  26585. */
  26586. computeWorldMatrix(force: boolean): Matrix;
  26587. /**
  26588. * Gets the world matrix
  26589. * @returns A world matrix
  26590. */
  26591. getWorldMatrix?(): Matrix;
  26592. /**
  26593. * Gets the child meshes
  26594. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26595. * @returns An array of abstract meshes
  26596. */
  26597. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26598. /**
  26599. * Gets the vertex data
  26600. * @param kind The type of vertex data
  26601. * @returns A nullable array of numbers, or a float32 array
  26602. */
  26603. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26604. /**
  26605. * Gets the indices from the mesh
  26606. * @returns A nullable array of index arrays
  26607. */
  26608. getIndices?(): Nullable<IndicesArray>;
  26609. /**
  26610. * Gets the scene from the mesh
  26611. * @returns the indices array or null
  26612. */
  26613. getScene?(): Scene;
  26614. /**
  26615. * Gets the absolute position from the mesh
  26616. * @returns the absolute position
  26617. */
  26618. getAbsolutePosition(): Vector3;
  26619. /**
  26620. * Gets the absolute pivot point from the mesh
  26621. * @returns the absolute pivot point
  26622. */
  26623. getAbsolutePivotPoint(): Vector3;
  26624. /**
  26625. * Rotates the mesh
  26626. * @param axis The axis of rotation
  26627. * @param amount The amount of rotation
  26628. * @param space The space of the rotation
  26629. * @returns The rotation transform node
  26630. */
  26631. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26632. /**
  26633. * Translates the mesh
  26634. * @param axis The axis of translation
  26635. * @param distance The distance of translation
  26636. * @param space The space of the translation
  26637. * @returns The transform node
  26638. */
  26639. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26640. /**
  26641. * Sets the absolute position of the mesh
  26642. * @param absolutePosition The absolute position of the mesh
  26643. * @returns The transform node
  26644. */
  26645. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26646. /**
  26647. * Gets the class name of the mesh
  26648. * @returns The class name
  26649. */
  26650. getClassName(): string;
  26651. }
  26652. /**
  26653. * Represents a physics imposter
  26654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26655. */
  26656. export class PhysicsImpostor {
  26657. /**
  26658. * The physics-enabled object used as the physics imposter
  26659. */
  26660. object: IPhysicsEnabledObject;
  26661. /**
  26662. * The type of the physics imposter
  26663. */
  26664. type: number;
  26665. private _options;
  26666. private _scene?;
  26667. /**
  26668. * The default object size of the imposter
  26669. */
  26670. static DEFAULT_OBJECT_SIZE: Vector3;
  26671. /**
  26672. * The identity quaternion of the imposter
  26673. */
  26674. static IDENTITY_QUATERNION: Quaternion;
  26675. /** @hidden */
  26676. _pluginData: any;
  26677. private _physicsEngine;
  26678. private _physicsBody;
  26679. private _bodyUpdateRequired;
  26680. private _onBeforePhysicsStepCallbacks;
  26681. private _onAfterPhysicsStepCallbacks;
  26682. /** @hidden */
  26683. _onPhysicsCollideCallbacks: Array<{
  26684. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26685. otherImpostors: Array<PhysicsImpostor>;
  26686. }>;
  26687. private _deltaPosition;
  26688. private _deltaRotation;
  26689. private _deltaRotationConjugated;
  26690. /** @hidden */
  26691. _isFromLine: boolean;
  26692. private _parent;
  26693. private _isDisposed;
  26694. private static _tmpVecs;
  26695. private static _tmpQuat;
  26696. /**
  26697. * Specifies if the physics imposter is disposed
  26698. */
  26699. get isDisposed(): boolean;
  26700. /**
  26701. * Gets the mass of the physics imposter
  26702. */
  26703. get mass(): number;
  26704. set mass(value: number);
  26705. /**
  26706. * Gets the coefficient of friction
  26707. */
  26708. get friction(): number;
  26709. /**
  26710. * Sets the coefficient of friction
  26711. */
  26712. set friction(value: number);
  26713. /**
  26714. * Gets the coefficient of restitution
  26715. */
  26716. get restitution(): number;
  26717. /**
  26718. * Sets the coefficient of restitution
  26719. */
  26720. set restitution(value: number);
  26721. /**
  26722. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26723. */
  26724. get pressure(): number;
  26725. /**
  26726. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26727. */
  26728. set pressure(value: number);
  26729. /**
  26730. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26731. */
  26732. get stiffness(): number;
  26733. /**
  26734. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26735. */
  26736. set stiffness(value: number);
  26737. /**
  26738. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26739. */
  26740. get velocityIterations(): number;
  26741. /**
  26742. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26743. */
  26744. set velocityIterations(value: number);
  26745. /**
  26746. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26747. */
  26748. get positionIterations(): number;
  26749. /**
  26750. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26751. */
  26752. set positionIterations(value: number);
  26753. /**
  26754. * The unique id of the physics imposter
  26755. * set by the physics engine when adding this impostor to the array
  26756. */
  26757. uniqueId: number;
  26758. /**
  26759. * @hidden
  26760. */
  26761. soft: boolean;
  26762. /**
  26763. * @hidden
  26764. */
  26765. segments: number;
  26766. private _joints;
  26767. /**
  26768. * Initializes the physics imposter
  26769. * @param object The physics-enabled object used as the physics imposter
  26770. * @param type The type of the physics imposter
  26771. * @param _options The options for the physics imposter
  26772. * @param _scene The Babylon scene
  26773. */
  26774. constructor(
  26775. /**
  26776. * The physics-enabled object used as the physics imposter
  26777. */
  26778. object: IPhysicsEnabledObject,
  26779. /**
  26780. * The type of the physics imposter
  26781. */
  26782. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26783. /**
  26784. * This function will completly initialize this impostor.
  26785. * It will create a new body - but only if this mesh has no parent.
  26786. * If it has, this impostor will not be used other than to define the impostor
  26787. * of the child mesh.
  26788. * @hidden
  26789. */
  26790. _init(): void;
  26791. private _getPhysicsParent;
  26792. /**
  26793. * Should a new body be generated.
  26794. * @returns boolean specifying if body initialization is required
  26795. */
  26796. isBodyInitRequired(): boolean;
  26797. /**
  26798. * Sets the updated scaling
  26799. * @param updated Specifies if the scaling is updated
  26800. */
  26801. setScalingUpdated(): void;
  26802. /**
  26803. * Force a regeneration of this or the parent's impostor's body.
  26804. * Use under cautious - This will remove all joints already implemented.
  26805. */
  26806. forceUpdate(): void;
  26807. /**
  26808. * Gets the body that holds this impostor. Either its own, or its parent.
  26809. */
  26810. get physicsBody(): any;
  26811. /**
  26812. * Get the parent of the physics imposter
  26813. * @returns Physics imposter or null
  26814. */
  26815. get parent(): Nullable<PhysicsImpostor>;
  26816. /**
  26817. * Sets the parent of the physics imposter
  26818. */
  26819. set parent(value: Nullable<PhysicsImpostor>);
  26820. /**
  26821. * Set the physics body. Used mainly by the physics engine/plugin
  26822. */
  26823. set physicsBody(physicsBody: any);
  26824. /**
  26825. * Resets the update flags
  26826. */
  26827. resetUpdateFlags(): void;
  26828. /**
  26829. * Gets the object extend size
  26830. * @returns the object extend size
  26831. */
  26832. getObjectExtendSize(): Vector3;
  26833. /**
  26834. * Gets the object center
  26835. * @returns The object center
  26836. */
  26837. getObjectCenter(): Vector3;
  26838. /**
  26839. * Get a specific parameter from the options parameters
  26840. * @param paramName The object parameter name
  26841. * @returns The object parameter
  26842. */
  26843. getParam(paramName: string): any;
  26844. /**
  26845. * Sets a specific parameter in the options given to the physics plugin
  26846. * @param paramName The parameter name
  26847. * @param value The value of the parameter
  26848. */
  26849. setParam(paramName: string, value: number): void;
  26850. /**
  26851. * Specifically change the body's mass option. Won't recreate the physics body object
  26852. * @param mass The mass of the physics imposter
  26853. */
  26854. setMass(mass: number): void;
  26855. /**
  26856. * Gets the linear velocity
  26857. * @returns linear velocity or null
  26858. */
  26859. getLinearVelocity(): Nullable<Vector3>;
  26860. /**
  26861. * Sets the linear velocity
  26862. * @param velocity linear velocity or null
  26863. */
  26864. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26865. /**
  26866. * Gets the angular velocity
  26867. * @returns angular velocity or null
  26868. */
  26869. getAngularVelocity(): Nullable<Vector3>;
  26870. /**
  26871. * Sets the angular velocity
  26872. * @param velocity The velocity or null
  26873. */
  26874. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26875. /**
  26876. * Execute a function with the physics plugin native code
  26877. * Provide a function the will have two variables - the world object and the physics body object
  26878. * @param func The function to execute with the physics plugin native code
  26879. */
  26880. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26881. /**
  26882. * Register a function that will be executed before the physics world is stepping forward
  26883. * @param func The function to execute before the physics world is stepped forward
  26884. */
  26885. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26886. /**
  26887. * Unregister a function that will be executed before the physics world is stepping forward
  26888. * @param func The function to execute before the physics world is stepped forward
  26889. */
  26890. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26891. /**
  26892. * Register a function that will be executed after the physics step
  26893. * @param func The function to execute after physics step
  26894. */
  26895. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26896. /**
  26897. * Unregisters a function that will be executed after the physics step
  26898. * @param func The function to execute after physics step
  26899. */
  26900. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26901. /**
  26902. * register a function that will be executed when this impostor collides against a different body
  26903. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26904. * @param func Callback that is executed on collision
  26905. */
  26906. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26907. /**
  26908. * Unregisters the physics imposter on contact
  26909. * @param collideAgainst The physics object to collide against
  26910. * @param func Callback to execute on collision
  26911. */
  26912. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26913. private _tmpQuat;
  26914. private _tmpQuat2;
  26915. /**
  26916. * Get the parent rotation
  26917. * @returns The parent rotation
  26918. */
  26919. getParentsRotation(): Quaternion;
  26920. /**
  26921. * this function is executed by the physics engine.
  26922. */
  26923. beforeStep: () => void;
  26924. /**
  26925. * this function is executed by the physics engine
  26926. */
  26927. afterStep: () => void;
  26928. /**
  26929. * Legacy collision detection event support
  26930. */
  26931. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26932. /**
  26933. * event and body object due to cannon's event-based architecture.
  26934. */
  26935. onCollide: (e: {
  26936. body: any;
  26937. }) => void;
  26938. /**
  26939. * Apply a force
  26940. * @param force The force to apply
  26941. * @param contactPoint The contact point for the force
  26942. * @returns The physics imposter
  26943. */
  26944. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26945. /**
  26946. * Apply an impulse
  26947. * @param force The impulse force
  26948. * @param contactPoint The contact point for the impulse force
  26949. * @returns The physics imposter
  26950. */
  26951. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26952. /**
  26953. * A help function to create a joint
  26954. * @param otherImpostor A physics imposter used to create a joint
  26955. * @param jointType The type of joint
  26956. * @param jointData The data for the joint
  26957. * @returns The physics imposter
  26958. */
  26959. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26960. /**
  26961. * Add a joint to this impostor with a different impostor
  26962. * @param otherImpostor A physics imposter used to add a joint
  26963. * @param joint The joint to add
  26964. * @returns The physics imposter
  26965. */
  26966. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26967. /**
  26968. * Add an anchor to a cloth impostor
  26969. * @param otherImpostor rigid impostor to anchor to
  26970. * @param width ratio across width from 0 to 1
  26971. * @param height ratio up height from 0 to 1
  26972. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  26973. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  26974. * @returns impostor the soft imposter
  26975. */
  26976. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26977. /**
  26978. * Add a hook to a rope impostor
  26979. * @param otherImpostor rigid impostor to anchor to
  26980. * @param length ratio across rope from 0 to 1
  26981. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  26982. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  26983. * @returns impostor the rope imposter
  26984. */
  26985. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26986. /**
  26987. * Will keep this body still, in a sleep mode.
  26988. * @returns the physics imposter
  26989. */
  26990. sleep(): PhysicsImpostor;
  26991. /**
  26992. * Wake the body up.
  26993. * @returns The physics imposter
  26994. */
  26995. wakeUp(): PhysicsImpostor;
  26996. /**
  26997. * Clones the physics imposter
  26998. * @param newObject The physics imposter clones to this physics-enabled object
  26999. * @returns A nullable physics imposter
  27000. */
  27001. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27002. /**
  27003. * Disposes the physics imposter
  27004. */
  27005. dispose(): void;
  27006. /**
  27007. * Sets the delta position
  27008. * @param position The delta position amount
  27009. */
  27010. setDeltaPosition(position: Vector3): void;
  27011. /**
  27012. * Sets the delta rotation
  27013. * @param rotation The delta rotation amount
  27014. */
  27015. setDeltaRotation(rotation: Quaternion): void;
  27016. /**
  27017. * Gets the box size of the physics imposter and stores the result in the input parameter
  27018. * @param result Stores the box size
  27019. * @returns The physics imposter
  27020. */
  27021. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27022. /**
  27023. * Gets the radius of the physics imposter
  27024. * @returns Radius of the physics imposter
  27025. */
  27026. getRadius(): number;
  27027. /**
  27028. * Sync a bone with this impostor
  27029. * @param bone The bone to sync to the impostor.
  27030. * @param boneMesh The mesh that the bone is influencing.
  27031. * @param jointPivot The pivot of the joint / bone in local space.
  27032. * @param distToJoint Optional distance from the impostor to the joint.
  27033. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27034. */
  27035. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27036. /**
  27037. * Sync impostor to a bone
  27038. * @param bone The bone that the impostor will be synced to.
  27039. * @param boneMesh The mesh that the bone is influencing.
  27040. * @param jointPivot The pivot of the joint / bone in local space.
  27041. * @param distToJoint Optional distance from the impostor to the joint.
  27042. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27043. * @param boneAxis Optional vector3 axis the bone is aligned with
  27044. */
  27045. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27046. /**
  27047. * No-Imposter type
  27048. */
  27049. static NoImpostor: number;
  27050. /**
  27051. * Sphere-Imposter type
  27052. */
  27053. static SphereImpostor: number;
  27054. /**
  27055. * Box-Imposter type
  27056. */
  27057. static BoxImpostor: number;
  27058. /**
  27059. * Plane-Imposter type
  27060. */
  27061. static PlaneImpostor: number;
  27062. /**
  27063. * Mesh-imposter type
  27064. */
  27065. static MeshImpostor: number;
  27066. /**
  27067. * Capsule-Impostor type (Ammo.js plugin only)
  27068. */
  27069. static CapsuleImpostor: number;
  27070. /**
  27071. * Cylinder-Imposter type
  27072. */
  27073. static CylinderImpostor: number;
  27074. /**
  27075. * Particle-Imposter type
  27076. */
  27077. static ParticleImpostor: number;
  27078. /**
  27079. * Heightmap-Imposter type
  27080. */
  27081. static HeightmapImpostor: number;
  27082. /**
  27083. * ConvexHull-Impostor type (Ammo.js plugin only)
  27084. */
  27085. static ConvexHullImpostor: number;
  27086. /**
  27087. * Custom-Imposter type (Ammo.js plugin only)
  27088. */
  27089. static CustomImpostor: number;
  27090. /**
  27091. * Rope-Imposter type
  27092. */
  27093. static RopeImpostor: number;
  27094. /**
  27095. * Cloth-Imposter type
  27096. */
  27097. static ClothImpostor: number;
  27098. /**
  27099. * Softbody-Imposter type
  27100. */
  27101. static SoftbodyImpostor: number;
  27102. }
  27103. }
  27104. declare module BABYLON {
  27105. /**
  27106. * @hidden
  27107. **/
  27108. export class _CreationDataStorage {
  27109. closePath?: boolean;
  27110. closeArray?: boolean;
  27111. idx: number[];
  27112. dashSize: number;
  27113. gapSize: number;
  27114. path3D: Path3D;
  27115. pathArray: Vector3[][];
  27116. arc: number;
  27117. radius: number;
  27118. cap: number;
  27119. tessellation: number;
  27120. }
  27121. /**
  27122. * @hidden
  27123. **/
  27124. class _InstanceDataStorage {
  27125. visibleInstances: any;
  27126. batchCache: _InstancesBatch;
  27127. instancesBufferSize: number;
  27128. instancesBuffer: Nullable<Buffer>;
  27129. instancesData: Float32Array;
  27130. overridenInstanceCount: number;
  27131. isFrozen: boolean;
  27132. previousBatch: Nullable<_InstancesBatch>;
  27133. hardwareInstancedRendering: boolean;
  27134. sideOrientation: number;
  27135. manualUpdate: boolean;
  27136. }
  27137. /**
  27138. * @hidden
  27139. **/
  27140. export class _InstancesBatch {
  27141. mustReturn: boolean;
  27142. visibleInstances: Nullable<InstancedMesh[]>[];
  27143. renderSelf: boolean[];
  27144. hardwareInstancedRendering: boolean[];
  27145. }
  27146. /**
  27147. * Class used to represent renderable models
  27148. */
  27149. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27150. /**
  27151. * Mesh side orientation : usually the external or front surface
  27152. */
  27153. static readonly FRONTSIDE: number;
  27154. /**
  27155. * Mesh side orientation : usually the internal or back surface
  27156. */
  27157. static readonly BACKSIDE: number;
  27158. /**
  27159. * Mesh side orientation : both internal and external or front and back surfaces
  27160. */
  27161. static readonly DOUBLESIDE: number;
  27162. /**
  27163. * Mesh side orientation : by default, `FRONTSIDE`
  27164. */
  27165. static readonly DEFAULTSIDE: number;
  27166. /**
  27167. * Mesh cap setting : no cap
  27168. */
  27169. static readonly NO_CAP: number;
  27170. /**
  27171. * Mesh cap setting : one cap at the beginning of the mesh
  27172. */
  27173. static readonly CAP_START: number;
  27174. /**
  27175. * Mesh cap setting : one cap at the end of the mesh
  27176. */
  27177. static readonly CAP_END: number;
  27178. /**
  27179. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27180. */
  27181. static readonly CAP_ALL: number;
  27182. /**
  27183. * Mesh pattern setting : no flip or rotate
  27184. */
  27185. static readonly NO_FLIP: number;
  27186. /**
  27187. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27188. */
  27189. static readonly FLIP_TILE: number;
  27190. /**
  27191. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27192. */
  27193. static readonly ROTATE_TILE: number;
  27194. /**
  27195. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27196. */
  27197. static readonly FLIP_ROW: number;
  27198. /**
  27199. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27200. */
  27201. static readonly ROTATE_ROW: number;
  27202. /**
  27203. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27204. */
  27205. static readonly FLIP_N_ROTATE_TILE: number;
  27206. /**
  27207. * Mesh pattern setting : rotate pattern and rotate
  27208. */
  27209. static readonly FLIP_N_ROTATE_ROW: number;
  27210. /**
  27211. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27212. */
  27213. static readonly CENTER: number;
  27214. /**
  27215. * Mesh tile positioning : part tiles on left
  27216. */
  27217. static readonly LEFT: number;
  27218. /**
  27219. * Mesh tile positioning : part tiles on right
  27220. */
  27221. static readonly RIGHT: number;
  27222. /**
  27223. * Mesh tile positioning : part tiles on top
  27224. */
  27225. static readonly TOP: number;
  27226. /**
  27227. * Mesh tile positioning : part tiles on bottom
  27228. */
  27229. static readonly BOTTOM: number;
  27230. /**
  27231. * Gets the default side orientation.
  27232. * @param orientation the orientation to value to attempt to get
  27233. * @returns the default orientation
  27234. * @hidden
  27235. */
  27236. static _GetDefaultSideOrientation(orientation?: number): number;
  27237. private _internalMeshDataInfo;
  27238. /**
  27239. * An event triggered before rendering the mesh
  27240. */
  27241. get onBeforeRenderObservable(): Observable<Mesh>;
  27242. /**
  27243. * An event triggered before binding the mesh
  27244. */
  27245. get onBeforeBindObservable(): Observable<Mesh>;
  27246. /**
  27247. * An event triggered after rendering the mesh
  27248. */
  27249. get onAfterRenderObservable(): Observable<Mesh>;
  27250. /**
  27251. * An event triggered before drawing the mesh
  27252. */
  27253. get onBeforeDrawObservable(): Observable<Mesh>;
  27254. private _onBeforeDrawObserver;
  27255. /**
  27256. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27257. */
  27258. set onBeforeDraw(callback: () => void);
  27259. get hasInstances(): boolean;
  27260. /**
  27261. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27262. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27263. */
  27264. delayLoadState: number;
  27265. /**
  27266. * Gets the list of instances created from this mesh
  27267. * it is not supposed to be modified manually.
  27268. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27269. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27270. */
  27271. instances: InstancedMesh[];
  27272. /**
  27273. * Gets the file containing delay loading data for this mesh
  27274. */
  27275. delayLoadingFile: string;
  27276. /** @hidden */
  27277. _binaryInfo: any;
  27278. /**
  27279. * User defined function used to change how LOD level selection is done
  27280. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27281. */
  27282. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27283. /**
  27284. * Gets or sets the morph target manager
  27285. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27286. */
  27287. get morphTargetManager(): Nullable<MorphTargetManager>;
  27288. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27289. /** @hidden */
  27290. _creationDataStorage: Nullable<_CreationDataStorage>;
  27291. /** @hidden */
  27292. _geometry: Nullable<Geometry>;
  27293. /** @hidden */
  27294. _delayInfo: Array<string>;
  27295. /** @hidden */
  27296. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27297. /** @hidden */
  27298. _instanceDataStorage: _InstanceDataStorage;
  27299. private _effectiveMaterial;
  27300. /** @hidden */
  27301. _shouldGenerateFlatShading: boolean;
  27302. /** @hidden */
  27303. _originalBuilderSideOrientation: number;
  27304. /**
  27305. * Use this property to change the original side orientation defined at construction time
  27306. */
  27307. overrideMaterialSideOrientation: Nullable<number>;
  27308. /**
  27309. * Gets the source mesh (the one used to clone this one from)
  27310. */
  27311. get source(): Nullable<Mesh>;
  27312. /**
  27313. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27314. */
  27315. get isUnIndexed(): boolean;
  27316. set isUnIndexed(value: boolean);
  27317. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27318. get worldMatrixInstancedBuffer(): Float32Array;
  27319. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27320. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27321. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27322. /**
  27323. * @constructor
  27324. * @param name The value used by scene.getMeshByName() to do a lookup.
  27325. * @param scene The scene to add this mesh to.
  27326. * @param parent The parent of this mesh, if it has one
  27327. * @param source An optional Mesh from which geometry is shared, cloned.
  27328. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27329. * When false, achieved by calling a clone(), also passing False.
  27330. * This will make creation of children, recursive.
  27331. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27332. */
  27333. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27334. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27335. doNotInstantiate: boolean;
  27336. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27337. /**
  27338. * Gets the class name
  27339. * @returns the string "Mesh".
  27340. */
  27341. getClassName(): string;
  27342. /** @hidden */
  27343. get _isMesh(): boolean;
  27344. /**
  27345. * Returns a description of this mesh
  27346. * @param fullDetails define if full details about this mesh must be used
  27347. * @returns a descriptive string representing this mesh
  27348. */
  27349. toString(fullDetails?: boolean): string;
  27350. /** @hidden */
  27351. _unBindEffect(): void;
  27352. /**
  27353. * Gets a boolean indicating if this mesh has LOD
  27354. */
  27355. get hasLODLevels(): boolean;
  27356. /**
  27357. * Gets the list of MeshLODLevel associated with the current mesh
  27358. * @returns an array of MeshLODLevel
  27359. */
  27360. getLODLevels(): MeshLODLevel[];
  27361. private _sortLODLevels;
  27362. /**
  27363. * Add a mesh as LOD level triggered at the given distance.
  27364. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27365. * @param distance The distance from the center of the object to show this level
  27366. * @param mesh The mesh to be added as LOD level (can be null)
  27367. * @return This mesh (for chaining)
  27368. */
  27369. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27370. /**
  27371. * Returns the LOD level mesh at the passed distance or null if not found.
  27372. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27373. * @param distance The distance from the center of the object to show this level
  27374. * @returns a Mesh or `null`
  27375. */
  27376. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27377. /**
  27378. * Remove a mesh from the LOD array
  27379. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27380. * @param mesh defines the mesh to be removed
  27381. * @return This mesh (for chaining)
  27382. */
  27383. removeLODLevel(mesh: Mesh): Mesh;
  27384. /**
  27385. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27386. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27387. * @param camera defines the camera to use to compute distance
  27388. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27389. * @return This mesh (for chaining)
  27390. */
  27391. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27392. /**
  27393. * Gets the mesh internal Geometry object
  27394. */
  27395. get geometry(): Nullable<Geometry>;
  27396. /**
  27397. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27398. * @returns the total number of vertices
  27399. */
  27400. getTotalVertices(): number;
  27401. /**
  27402. * Returns the content of an associated vertex buffer
  27403. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27404. * - VertexBuffer.PositionKind
  27405. * - VertexBuffer.UVKind
  27406. * - VertexBuffer.UV2Kind
  27407. * - VertexBuffer.UV3Kind
  27408. * - VertexBuffer.UV4Kind
  27409. * - VertexBuffer.UV5Kind
  27410. * - VertexBuffer.UV6Kind
  27411. * - VertexBuffer.ColorKind
  27412. * - VertexBuffer.MatricesIndicesKind
  27413. * - VertexBuffer.MatricesIndicesExtraKind
  27414. * - VertexBuffer.MatricesWeightsKind
  27415. * - VertexBuffer.MatricesWeightsExtraKind
  27416. * @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
  27417. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27418. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27419. */
  27420. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27421. /**
  27422. * Returns the mesh VertexBuffer object from the requested `kind`
  27423. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27424. * - VertexBuffer.PositionKind
  27425. * - VertexBuffer.NormalKind
  27426. * - VertexBuffer.UVKind
  27427. * - VertexBuffer.UV2Kind
  27428. * - VertexBuffer.UV3Kind
  27429. * - VertexBuffer.UV4Kind
  27430. * - VertexBuffer.UV5Kind
  27431. * - VertexBuffer.UV6Kind
  27432. * - VertexBuffer.ColorKind
  27433. * - VertexBuffer.MatricesIndicesKind
  27434. * - VertexBuffer.MatricesIndicesExtraKind
  27435. * - VertexBuffer.MatricesWeightsKind
  27436. * - VertexBuffer.MatricesWeightsExtraKind
  27437. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27438. */
  27439. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27440. /**
  27441. * Tests if a specific vertex buffer is associated with this mesh
  27442. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27443. * - VertexBuffer.PositionKind
  27444. * - VertexBuffer.NormalKind
  27445. * - VertexBuffer.UVKind
  27446. * - VertexBuffer.UV2Kind
  27447. * - VertexBuffer.UV3Kind
  27448. * - VertexBuffer.UV4Kind
  27449. * - VertexBuffer.UV5Kind
  27450. * - VertexBuffer.UV6Kind
  27451. * - VertexBuffer.ColorKind
  27452. * - VertexBuffer.MatricesIndicesKind
  27453. * - VertexBuffer.MatricesIndicesExtraKind
  27454. * - VertexBuffer.MatricesWeightsKind
  27455. * - VertexBuffer.MatricesWeightsExtraKind
  27456. * @returns a boolean
  27457. */
  27458. isVerticesDataPresent(kind: string): boolean;
  27459. /**
  27460. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27461. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27462. * - VertexBuffer.PositionKind
  27463. * - VertexBuffer.UVKind
  27464. * - VertexBuffer.UV2Kind
  27465. * - VertexBuffer.UV3Kind
  27466. * - VertexBuffer.UV4Kind
  27467. * - VertexBuffer.UV5Kind
  27468. * - VertexBuffer.UV6Kind
  27469. * - VertexBuffer.ColorKind
  27470. * - VertexBuffer.MatricesIndicesKind
  27471. * - VertexBuffer.MatricesIndicesExtraKind
  27472. * - VertexBuffer.MatricesWeightsKind
  27473. * - VertexBuffer.MatricesWeightsExtraKind
  27474. * @returns a boolean
  27475. */
  27476. isVertexBufferUpdatable(kind: string): boolean;
  27477. /**
  27478. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27479. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27480. * - VertexBuffer.PositionKind
  27481. * - VertexBuffer.NormalKind
  27482. * - VertexBuffer.UVKind
  27483. * - VertexBuffer.UV2Kind
  27484. * - VertexBuffer.UV3Kind
  27485. * - VertexBuffer.UV4Kind
  27486. * - VertexBuffer.UV5Kind
  27487. * - VertexBuffer.UV6Kind
  27488. * - VertexBuffer.ColorKind
  27489. * - VertexBuffer.MatricesIndicesKind
  27490. * - VertexBuffer.MatricesIndicesExtraKind
  27491. * - VertexBuffer.MatricesWeightsKind
  27492. * - VertexBuffer.MatricesWeightsExtraKind
  27493. * @returns an array of strings
  27494. */
  27495. getVerticesDataKinds(): string[];
  27496. /**
  27497. * Returns a positive integer : the total number of indices in this mesh geometry.
  27498. * @returns the numner of indices or zero if the mesh has no geometry.
  27499. */
  27500. getTotalIndices(): number;
  27501. /**
  27502. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27503. * @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.
  27504. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27505. * @returns the indices array or an empty array if the mesh has no geometry
  27506. */
  27507. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27508. get isBlocked(): boolean;
  27509. /**
  27510. * Determine if the current mesh is ready to be rendered
  27511. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27512. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27513. * @returns true if all associated assets are ready (material, textures, shaders)
  27514. */
  27515. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27516. /**
  27517. * 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.
  27518. */
  27519. get areNormalsFrozen(): boolean;
  27520. /**
  27521. * 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.
  27522. * @returns the current mesh
  27523. */
  27524. freezeNormals(): Mesh;
  27525. /**
  27526. * 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
  27527. * @returns the current mesh
  27528. */
  27529. unfreezeNormals(): Mesh;
  27530. /**
  27531. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27532. */
  27533. set overridenInstanceCount(count: number);
  27534. /** @hidden */
  27535. _preActivate(): Mesh;
  27536. /** @hidden */
  27537. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27538. /** @hidden */
  27539. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27540. /**
  27541. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27542. * This means the mesh underlying bounding box and sphere are recomputed.
  27543. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27544. * @returns the current mesh
  27545. */
  27546. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27547. /** @hidden */
  27548. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27549. /**
  27550. * This function will subdivide the mesh into multiple submeshes
  27551. * @param count defines the expected number of submeshes
  27552. */
  27553. subdivide(count: number): void;
  27554. /**
  27555. * Copy a FloatArray into a specific associated vertex buffer
  27556. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27557. * - VertexBuffer.PositionKind
  27558. * - VertexBuffer.UVKind
  27559. * - VertexBuffer.UV2Kind
  27560. * - VertexBuffer.UV3Kind
  27561. * - VertexBuffer.UV4Kind
  27562. * - VertexBuffer.UV5Kind
  27563. * - VertexBuffer.UV6Kind
  27564. * - VertexBuffer.ColorKind
  27565. * - VertexBuffer.MatricesIndicesKind
  27566. * - VertexBuffer.MatricesIndicesExtraKind
  27567. * - VertexBuffer.MatricesWeightsKind
  27568. * - VertexBuffer.MatricesWeightsExtraKind
  27569. * @param data defines the data source
  27570. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27571. * @param stride defines the data stride size (can be null)
  27572. * @returns the current mesh
  27573. */
  27574. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27575. /**
  27576. * Delete a vertex buffer associated with this mesh
  27577. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27578. * - VertexBuffer.PositionKind
  27579. * - VertexBuffer.UVKind
  27580. * - VertexBuffer.UV2Kind
  27581. * - VertexBuffer.UV3Kind
  27582. * - VertexBuffer.UV4Kind
  27583. * - VertexBuffer.UV5Kind
  27584. * - VertexBuffer.UV6Kind
  27585. * - VertexBuffer.ColorKind
  27586. * - VertexBuffer.MatricesIndicesKind
  27587. * - VertexBuffer.MatricesIndicesExtraKind
  27588. * - VertexBuffer.MatricesWeightsKind
  27589. * - VertexBuffer.MatricesWeightsExtraKind
  27590. */
  27591. removeVerticesData(kind: string): void;
  27592. /**
  27593. * Flags an associated vertex buffer as updatable
  27594. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27595. * - VertexBuffer.PositionKind
  27596. * - VertexBuffer.UVKind
  27597. * - VertexBuffer.UV2Kind
  27598. * - VertexBuffer.UV3Kind
  27599. * - VertexBuffer.UV4Kind
  27600. * - VertexBuffer.UV5Kind
  27601. * - VertexBuffer.UV6Kind
  27602. * - VertexBuffer.ColorKind
  27603. * - VertexBuffer.MatricesIndicesKind
  27604. * - VertexBuffer.MatricesIndicesExtraKind
  27605. * - VertexBuffer.MatricesWeightsKind
  27606. * - VertexBuffer.MatricesWeightsExtraKind
  27607. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27608. */
  27609. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27610. /**
  27611. * Sets the mesh global Vertex Buffer
  27612. * @param buffer defines the buffer to use
  27613. * @returns the current mesh
  27614. */
  27615. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27616. /**
  27617. * Update a specific associated vertex buffer
  27618. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27619. * - VertexBuffer.PositionKind
  27620. * - VertexBuffer.UVKind
  27621. * - VertexBuffer.UV2Kind
  27622. * - VertexBuffer.UV3Kind
  27623. * - VertexBuffer.UV4Kind
  27624. * - VertexBuffer.UV5Kind
  27625. * - VertexBuffer.UV6Kind
  27626. * - VertexBuffer.ColorKind
  27627. * - VertexBuffer.MatricesIndicesKind
  27628. * - VertexBuffer.MatricesIndicesExtraKind
  27629. * - VertexBuffer.MatricesWeightsKind
  27630. * - VertexBuffer.MatricesWeightsExtraKind
  27631. * @param data defines the data source
  27632. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27633. * @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)
  27634. * @returns the current mesh
  27635. */
  27636. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27637. /**
  27638. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27639. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27640. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27641. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27642. * @returns the current mesh
  27643. */
  27644. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27645. /**
  27646. * Creates a un-shared specific occurence of the geometry for the mesh.
  27647. * @returns the current mesh
  27648. */
  27649. makeGeometryUnique(): Mesh;
  27650. /**
  27651. * Set the index buffer of this mesh
  27652. * @param indices defines the source data
  27653. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27654. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27655. * @returns the current mesh
  27656. */
  27657. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27658. /**
  27659. * Update the current index buffer
  27660. * @param indices defines the source data
  27661. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27662. * @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)
  27663. * @returns the current mesh
  27664. */
  27665. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27666. /**
  27667. * Invert the geometry to move from a right handed system to a left handed one.
  27668. * @returns the current mesh
  27669. */
  27670. toLeftHanded(): Mesh;
  27671. /** @hidden */
  27672. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27673. /** @hidden */
  27674. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27675. /**
  27676. * Registers for this mesh a javascript function called just before the rendering process
  27677. * @param func defines the function to call before rendering this mesh
  27678. * @returns the current mesh
  27679. */
  27680. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27681. /**
  27682. * Disposes a previously registered javascript function called before the rendering
  27683. * @param func defines the function to remove
  27684. * @returns the current mesh
  27685. */
  27686. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27687. /**
  27688. * Registers for this mesh a javascript function called just after the rendering is complete
  27689. * @param func defines the function to call after rendering this mesh
  27690. * @returns the current mesh
  27691. */
  27692. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27693. /**
  27694. * Disposes a previously registered javascript function called after the rendering.
  27695. * @param func defines the function to remove
  27696. * @returns the current mesh
  27697. */
  27698. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27699. /** @hidden */
  27700. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27701. /** @hidden */
  27702. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27703. /** @hidden */
  27704. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27705. /** @hidden */
  27706. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27707. /** @hidden */
  27708. _rebuild(): void;
  27709. /** @hidden */
  27710. _freeze(): void;
  27711. /** @hidden */
  27712. _unFreeze(): void;
  27713. /**
  27714. * 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
  27715. * @param subMesh defines the subMesh to render
  27716. * @param enableAlphaMode defines if alpha mode can be changed
  27717. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27718. * @returns the current mesh
  27719. */
  27720. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27721. private _onBeforeDraw;
  27722. /**
  27723. * Renormalize the mesh and patch it up if there are no weights
  27724. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27725. * However in the case of zero weights then we set just a single influence to 1.
  27726. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27727. */
  27728. cleanMatrixWeights(): void;
  27729. private normalizeSkinFourWeights;
  27730. private normalizeSkinWeightsAndExtra;
  27731. /**
  27732. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27733. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27734. * the user know there was an issue with importing the mesh
  27735. * @returns a validation object with skinned, valid and report string
  27736. */
  27737. validateSkinning(): {
  27738. skinned: boolean;
  27739. valid: boolean;
  27740. report: string;
  27741. };
  27742. /** @hidden */
  27743. _checkDelayState(): Mesh;
  27744. private _queueLoad;
  27745. /**
  27746. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27747. * A mesh is in the frustum if its bounding box intersects the frustum
  27748. * @param frustumPlanes defines the frustum to test
  27749. * @returns true if the mesh is in the frustum planes
  27750. */
  27751. isInFrustum(frustumPlanes: Plane[]): boolean;
  27752. /**
  27753. * Sets the mesh material by the material or multiMaterial `id` property
  27754. * @param id is a string identifying the material or the multiMaterial
  27755. * @returns the current mesh
  27756. */
  27757. setMaterialByID(id: string): Mesh;
  27758. /**
  27759. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27760. * @returns an array of IAnimatable
  27761. */
  27762. getAnimatables(): IAnimatable[];
  27763. /**
  27764. * Modifies the mesh geometry according to the passed transformation matrix.
  27765. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27766. * The mesh normals are modified using the same transformation.
  27767. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27768. * @param transform defines the transform matrix to use
  27769. * @see http://doc.babylonjs.com/resources/baking_transformations
  27770. * @returns the current mesh
  27771. */
  27772. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27773. /**
  27774. * Modifies the mesh geometry according to its own current World Matrix.
  27775. * The mesh World Matrix is then reset.
  27776. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27777. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27778. * @see http://doc.babylonjs.com/resources/baking_transformations
  27779. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27780. * @returns the current mesh
  27781. */
  27782. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27783. /** @hidden */
  27784. get _positions(): Nullable<Vector3[]>;
  27785. /** @hidden */
  27786. _resetPointsArrayCache(): Mesh;
  27787. /** @hidden */
  27788. _generatePointsArray(): boolean;
  27789. /**
  27790. * Returns a new Mesh object generated from the current mesh properties.
  27791. * This method must not get confused with createInstance()
  27792. * @param name is a string, the name given to the new mesh
  27793. * @param newParent can be any Node object (default `null`)
  27794. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27795. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27796. * @returns a new mesh
  27797. */
  27798. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27799. /**
  27800. * Releases resources associated with this mesh.
  27801. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27802. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27803. */
  27804. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27805. /** @hidden */
  27806. _disposeInstanceSpecificData(): void;
  27807. /**
  27808. * Modifies the mesh geometry according to a displacement map.
  27809. * 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.
  27810. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27811. * @param url is a string, the URL from the image file is to be downloaded.
  27812. * @param minHeight is the lower limit of the displacement.
  27813. * @param maxHeight is the upper limit of the displacement.
  27814. * @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.
  27815. * @param uvOffset is an optional vector2 used to offset UV.
  27816. * @param uvScale is an optional vector2 used to scale UV.
  27817. * @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.
  27818. * @returns the Mesh.
  27819. */
  27820. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27821. /**
  27822. * Modifies the mesh geometry according to a displacementMap buffer.
  27823. * 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.
  27824. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27825. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27826. * @param heightMapWidth is the width of the buffer image.
  27827. * @param heightMapHeight is the height of the buffer image.
  27828. * @param minHeight is the lower limit of the displacement.
  27829. * @param maxHeight is the upper limit of the displacement.
  27830. * @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.
  27831. * @param uvOffset is an optional vector2 used to offset UV.
  27832. * @param uvScale is an optional vector2 used to scale UV.
  27833. * @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.
  27834. * @returns the Mesh.
  27835. */
  27836. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27837. /**
  27838. * Modify the mesh to get a flat shading rendering.
  27839. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27840. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27841. * @returns current mesh
  27842. */
  27843. convertToFlatShadedMesh(): Mesh;
  27844. /**
  27845. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27846. * In other words, more vertices, no more indices and a single bigger VBO.
  27847. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27848. * @returns current mesh
  27849. */
  27850. convertToUnIndexedMesh(): Mesh;
  27851. /**
  27852. * Inverses facet orientations.
  27853. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27854. * @param flipNormals will also inverts the normals
  27855. * @returns current mesh
  27856. */
  27857. flipFaces(flipNormals?: boolean): Mesh;
  27858. /**
  27859. * Increase the number of facets and hence vertices in a mesh
  27860. * Vertex normals are interpolated from existing vertex normals
  27861. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27862. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27863. */
  27864. increaseVertices(numberPerEdge: number): void;
  27865. /**
  27866. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27867. * This will undo any application of covertToFlatShadedMesh
  27868. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27869. */
  27870. forceSharedVertices(): void;
  27871. /** @hidden */
  27872. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27873. /** @hidden */
  27874. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27875. /**
  27876. * Creates a new InstancedMesh object from the mesh model.
  27877. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27878. * @param name defines the name of the new instance
  27879. * @returns a new InstancedMesh
  27880. */
  27881. createInstance(name: string): InstancedMesh;
  27882. /**
  27883. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27884. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27885. * @returns the current mesh
  27886. */
  27887. synchronizeInstances(): Mesh;
  27888. /**
  27889. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27890. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27891. * This should be used together with the simplification to avoid disappearing triangles.
  27892. * @param successCallback an optional success callback to be called after the optimization finished.
  27893. * @returns the current mesh
  27894. */
  27895. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27896. /**
  27897. * Serialize current mesh
  27898. * @param serializationObject defines the object which will receive the serialization data
  27899. */
  27900. serialize(serializationObject: any): void;
  27901. /** @hidden */
  27902. _syncGeometryWithMorphTargetManager(): void;
  27903. /** @hidden */
  27904. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  27905. /**
  27906. * Returns a new Mesh object parsed from the source provided.
  27907. * @param parsedMesh is the source
  27908. * @param scene defines the hosting scene
  27909. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27910. * @returns a new Mesh
  27911. */
  27912. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27913. /**
  27914. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27915. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27916. * @param name defines the name of the mesh to create
  27917. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27918. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27919. * @param closePath creates a seam between the first and the last points of each path of the path array
  27920. * @param offset is taken in account only if the `pathArray` is containing a single path
  27921. * @param scene defines the hosting scene
  27922. * @param updatable defines if the mesh must be flagged as updatable
  27923. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27924. * @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)
  27925. * @returns a new Mesh
  27926. */
  27927. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27928. /**
  27929. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27930. * @param name defines the name of the mesh to create
  27931. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27932. * @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
  27933. * @param scene defines the hosting scene
  27934. * @param updatable defines if the mesh must be flagged as updatable
  27935. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27936. * @returns a new Mesh
  27937. */
  27938. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27939. /**
  27940. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27941. * @param name defines the name of the mesh to create
  27942. * @param size sets the size (float) of each box side (default 1)
  27943. * @param scene defines the hosting scene
  27944. * @param updatable defines if the mesh must be flagged as updatable
  27945. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27946. * @returns a new Mesh
  27947. */
  27948. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27949. /**
  27950. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27951. * @param name defines the name of the mesh to create
  27952. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27953. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27954. * @param scene defines the hosting scene
  27955. * @param updatable defines if the mesh must be flagged as updatable
  27956. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27957. * @returns a new Mesh
  27958. */
  27959. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27960. /**
  27961. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  27962. * @param name defines the name of the mesh to create
  27963. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27964. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27965. * @param scene defines the hosting scene
  27966. * @returns a new Mesh
  27967. */
  27968. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  27969. /**
  27970. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27971. * @param name defines the name of the mesh to create
  27972. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27973. * @param diameterTop set the top cap diameter (floats, default 1)
  27974. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27975. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27976. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27977. * @param scene defines the hosting scene
  27978. * @param updatable defines if the mesh must be flagged as updatable
  27979. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27980. * @returns a new Mesh
  27981. */
  27982. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27983. /**
  27984. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27985. * @param name defines the name of the mesh to create
  27986. * @param diameter sets the diameter size (float) of the torus (default 1)
  27987. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27988. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27989. * @param scene defines the hosting scene
  27990. * @param updatable defines if the mesh must be flagged as updatable
  27991. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27992. * @returns a new Mesh
  27993. */
  27994. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27995. /**
  27996. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27997. * @param name defines the name of the mesh to create
  27998. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27999. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28000. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28001. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28002. * @param p the number of windings on X axis (positive integers, default 2)
  28003. * @param q the number of windings on Y axis (positive integers, default 3)
  28004. * @param scene defines the hosting scene
  28005. * @param updatable defines if the mesh must be flagged as updatable
  28006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28007. * @returns a new Mesh
  28008. */
  28009. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28010. /**
  28011. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28012. * @param name defines the name of the mesh to create
  28013. * @param points is an array successive Vector3
  28014. * @param scene defines the hosting scene
  28015. * @param updatable defines if the mesh must be flagged as updatable
  28016. * @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).
  28017. * @returns a new Mesh
  28018. */
  28019. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28020. /**
  28021. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28022. * @param name defines the name of the mesh to create
  28023. * @param points is an array successive Vector3
  28024. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28025. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28026. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28027. * @param scene defines the hosting scene
  28028. * @param updatable defines if the mesh must be flagged as updatable
  28029. * @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)
  28030. * @returns a new Mesh
  28031. */
  28032. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28033. /**
  28034. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28035. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28036. * 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.
  28037. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28038. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28039. * Remember you can only change the shape positions, not their number when updating a polygon.
  28040. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28041. * @param name defines the name of the mesh to create
  28042. * @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
  28043. * @param scene defines the hosting scene
  28044. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28045. * @param updatable defines if the mesh must be flagged as updatable
  28046. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28047. * @param earcutInjection can be used to inject your own earcut reference
  28048. * @returns a new Mesh
  28049. */
  28050. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28051. /**
  28052. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28053. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28054. * @param name defines the name of the mesh to create
  28055. * @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
  28056. * @param depth defines the height of extrusion
  28057. * @param scene defines the hosting scene
  28058. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28059. * @param updatable defines if the mesh must be flagged as updatable
  28060. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28061. * @param earcutInjection can be used to inject your own earcut reference
  28062. * @returns a new Mesh
  28063. */
  28064. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28065. /**
  28066. * Creates an extruded shape mesh.
  28067. * 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
  28068. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28069. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28070. * @param name defines the name of the mesh to create
  28071. * @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
  28072. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28073. * @param scale is the value to scale the shape
  28074. * @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
  28075. * @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
  28076. * @param scene defines the hosting scene
  28077. * @param updatable defines if the mesh must be flagged as updatable
  28078. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28079. * @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)
  28080. * @returns a new Mesh
  28081. */
  28082. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28083. /**
  28084. * Creates an custom extruded shape mesh.
  28085. * The custom extrusion is a parametric shape.
  28086. * It has no predefined shape. Its final shape will depend on the input parameters.
  28087. * Please consider using the same method from the MeshBuilder class instead
  28088. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28089. * @param name defines the name of the mesh to create
  28090. * @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
  28091. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28092. * @param scaleFunction is a custom Javascript function called on each path point
  28093. * @param rotationFunction is a custom Javascript function called on each path point
  28094. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28095. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28096. * @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
  28097. * @param scene defines the hosting scene
  28098. * @param updatable defines if the mesh must be flagged as updatable
  28099. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28100. * @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)
  28101. * @returns a new Mesh
  28102. */
  28103. 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;
  28104. /**
  28105. * Creates lathe mesh.
  28106. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28107. * Please consider using the same method from the MeshBuilder class instead
  28108. * @param name defines the name of the mesh to create
  28109. * @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
  28110. * @param radius is the radius value of the lathe
  28111. * @param tessellation is the side number of the lathe.
  28112. * @param scene defines the hosting scene
  28113. * @param updatable defines if the mesh must be flagged as updatable
  28114. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28115. * @returns a new Mesh
  28116. */
  28117. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28118. /**
  28119. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28120. * @param name defines the name of the mesh to create
  28121. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28122. * @param scene defines the hosting scene
  28123. * @param updatable defines if the mesh must be flagged as updatable
  28124. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28125. * @returns a new Mesh
  28126. */
  28127. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28128. /**
  28129. * Creates a ground mesh.
  28130. * Please consider using the same method from the MeshBuilder class instead
  28131. * @param name defines the name of the mesh to create
  28132. * @param width set the width of the ground
  28133. * @param height set the height of the ground
  28134. * @param subdivisions sets the number of subdivisions per side
  28135. * @param scene defines the hosting scene
  28136. * @param updatable defines if the mesh must be flagged as updatable
  28137. * @returns a new Mesh
  28138. */
  28139. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28140. /**
  28141. * Creates a tiled ground mesh.
  28142. * Please consider using the same method from the MeshBuilder class instead
  28143. * @param name defines the name of the mesh to create
  28144. * @param xmin set the ground minimum X coordinate
  28145. * @param zmin set the ground minimum Y coordinate
  28146. * @param xmax set the ground maximum X coordinate
  28147. * @param zmax set the ground maximum Z coordinate
  28148. * @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
  28149. * @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
  28150. * @param scene defines the hosting scene
  28151. * @param updatable defines if the mesh must be flagged as updatable
  28152. * @returns a new Mesh
  28153. */
  28154. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28155. w: number;
  28156. h: number;
  28157. }, precision: {
  28158. w: number;
  28159. h: number;
  28160. }, scene: Scene, updatable?: boolean): Mesh;
  28161. /**
  28162. * Creates a ground mesh from a height map.
  28163. * Please consider using the same method from the MeshBuilder class instead
  28164. * @see http://doc.babylonjs.com/babylon101/height_map
  28165. * @param name defines the name of the mesh to create
  28166. * @param url sets the URL of the height map image resource
  28167. * @param width set the ground width size
  28168. * @param height set the ground height size
  28169. * @param subdivisions sets the number of subdivision per side
  28170. * @param minHeight is the minimum altitude on the ground
  28171. * @param maxHeight is the maximum altitude on the ground
  28172. * @param scene defines the hosting scene
  28173. * @param updatable defines if the mesh must be flagged as updatable
  28174. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28175. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28176. * @returns a new Mesh
  28177. */
  28178. 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;
  28179. /**
  28180. * Creates a tube mesh.
  28181. * The tube is a parametric shape.
  28182. * It has no predefined shape. Its final shape will depend on the input parameters.
  28183. * Please consider using the same method from the MeshBuilder class instead
  28184. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28185. * @param name defines the name of the mesh to create
  28186. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28187. * @param radius sets the tube radius size
  28188. * @param tessellation is the number of sides on the tubular surface
  28189. * @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
  28190. * @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
  28191. * @param scene defines the hosting scene
  28192. * @param updatable defines if the mesh must be flagged as updatable
  28193. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28194. * @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)
  28195. * @returns a new Mesh
  28196. */
  28197. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28198. (i: number, distance: number): number;
  28199. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28200. /**
  28201. * Creates a polyhedron mesh.
  28202. * Please consider using the same method from the MeshBuilder class instead.
  28203. * * 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
  28204. * * The parameter `size` (positive float, default 1) sets the polygon size
  28205. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28206. * * 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`
  28207. * * 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
  28208. * * 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)`)
  28209. * * 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
  28210. * * 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
  28211. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28212. * * 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
  28213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28214. * @param name defines the name of the mesh to create
  28215. * @param options defines the options used to create the mesh
  28216. * @param scene defines the hosting scene
  28217. * @returns a new Mesh
  28218. */
  28219. static CreatePolyhedron(name: string, options: {
  28220. type?: number;
  28221. size?: number;
  28222. sizeX?: number;
  28223. sizeY?: number;
  28224. sizeZ?: number;
  28225. custom?: any;
  28226. faceUV?: Vector4[];
  28227. faceColors?: Color4[];
  28228. updatable?: boolean;
  28229. sideOrientation?: number;
  28230. }, scene: Scene): Mesh;
  28231. /**
  28232. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28233. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28234. * * 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`)
  28235. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28236. * * 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
  28237. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28238. * * 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
  28239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28240. * @param name defines the name of the mesh
  28241. * @param options defines the options used to create the mesh
  28242. * @param scene defines the hosting scene
  28243. * @returns a new Mesh
  28244. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28245. */
  28246. static CreateIcoSphere(name: string, options: {
  28247. radius?: number;
  28248. flat?: boolean;
  28249. subdivisions?: number;
  28250. sideOrientation?: number;
  28251. updatable?: boolean;
  28252. }, scene: Scene): Mesh;
  28253. /**
  28254. * Creates a decal mesh.
  28255. * Please consider using the same method from the MeshBuilder class instead.
  28256. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28257. * @param name defines the name of the mesh
  28258. * @param sourceMesh defines the mesh receiving the decal
  28259. * @param position sets the position of the decal in world coordinates
  28260. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28261. * @param size sets the decal scaling
  28262. * @param angle sets the angle to rotate the decal
  28263. * @returns a new Mesh
  28264. */
  28265. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28266. /**
  28267. * Prepare internal position array for software CPU skinning
  28268. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28269. */
  28270. setPositionsForCPUSkinning(): Float32Array;
  28271. /**
  28272. * Prepare internal normal array for software CPU skinning
  28273. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28274. */
  28275. setNormalsForCPUSkinning(): Float32Array;
  28276. /**
  28277. * Updates the vertex buffer by applying transformation from the bones
  28278. * @param skeleton defines the skeleton to apply to current mesh
  28279. * @returns the current mesh
  28280. */
  28281. applySkeleton(skeleton: Skeleton): Mesh;
  28282. /**
  28283. * 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
  28284. * @param meshes defines the list of meshes to scan
  28285. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28286. */
  28287. static MinMax(meshes: AbstractMesh[]): {
  28288. min: Vector3;
  28289. max: Vector3;
  28290. };
  28291. /**
  28292. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28293. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28294. * @returns a vector3
  28295. */
  28296. static Center(meshesOrMinMaxVector: {
  28297. min: Vector3;
  28298. max: Vector3;
  28299. } | AbstractMesh[]): Vector3;
  28300. /**
  28301. * Merge the array of meshes into a single mesh for performance reasons.
  28302. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28303. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28304. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28305. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28306. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28307. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28308. * @returns a new mesh
  28309. */
  28310. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28311. /** @hidden */
  28312. addInstance(instance: InstancedMesh): void;
  28313. /** @hidden */
  28314. removeInstance(instance: InstancedMesh): void;
  28315. }
  28316. }
  28317. declare module BABYLON {
  28318. /**
  28319. * This is the base class of all the camera used in the application.
  28320. * @see http://doc.babylonjs.com/features/cameras
  28321. */
  28322. export class Camera extends Node {
  28323. /** @hidden */
  28324. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28325. /**
  28326. * This is the default projection mode used by the cameras.
  28327. * It helps recreating a feeling of perspective and better appreciate depth.
  28328. * This is the best way to simulate real life cameras.
  28329. */
  28330. static readonly PERSPECTIVE_CAMERA: number;
  28331. /**
  28332. * This helps creating camera with an orthographic mode.
  28333. * 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.
  28334. */
  28335. static readonly ORTHOGRAPHIC_CAMERA: number;
  28336. /**
  28337. * This is the default FOV mode for perspective cameras.
  28338. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28339. */
  28340. static readonly FOVMODE_VERTICAL_FIXED: number;
  28341. /**
  28342. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28343. */
  28344. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28345. /**
  28346. * This specifies ther is no need for a camera rig.
  28347. * Basically only one eye is rendered corresponding to the camera.
  28348. */
  28349. static readonly RIG_MODE_NONE: number;
  28350. /**
  28351. * Simulates a camera Rig with one blue eye and one red eye.
  28352. * This can be use with 3d blue and red glasses.
  28353. */
  28354. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28355. /**
  28356. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28357. */
  28358. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28359. /**
  28360. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28361. */
  28362. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28363. /**
  28364. * Defines that both eyes of the camera will be rendered over under each other.
  28365. */
  28366. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28367. /**
  28368. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28369. */
  28370. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28371. /**
  28372. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28373. */
  28374. static readonly RIG_MODE_VR: number;
  28375. /**
  28376. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28377. */
  28378. static readonly RIG_MODE_WEBVR: number;
  28379. /**
  28380. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28381. */
  28382. static readonly RIG_MODE_CUSTOM: number;
  28383. /**
  28384. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28385. */
  28386. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28387. /**
  28388. * Define the input manager associated with the camera.
  28389. */
  28390. inputs: CameraInputsManager<Camera>;
  28391. /** @hidden */
  28392. _position: Vector3;
  28393. /**
  28394. * Define the current local position of the camera in the scene
  28395. */
  28396. get position(): Vector3;
  28397. set position(newPosition: Vector3);
  28398. /**
  28399. * The vector the camera should consider as up.
  28400. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28401. */
  28402. upVector: Vector3;
  28403. /**
  28404. * Define the current limit on the left side for an orthographic camera
  28405. * In scene unit
  28406. */
  28407. orthoLeft: Nullable<number>;
  28408. /**
  28409. * Define the current limit on the right side for an orthographic camera
  28410. * In scene unit
  28411. */
  28412. orthoRight: Nullable<number>;
  28413. /**
  28414. * Define the current limit on the bottom side for an orthographic camera
  28415. * In scene unit
  28416. */
  28417. orthoBottom: Nullable<number>;
  28418. /**
  28419. * Define the current limit on the top side for an orthographic camera
  28420. * In scene unit
  28421. */
  28422. orthoTop: Nullable<number>;
  28423. /**
  28424. * Field Of View is set in Radians. (default is 0.8)
  28425. */
  28426. fov: number;
  28427. /**
  28428. * Define the minimum distance the camera can see from.
  28429. * This is important to note that the depth buffer are not infinite and the closer it starts
  28430. * the more your scene might encounter depth fighting issue.
  28431. */
  28432. minZ: number;
  28433. /**
  28434. * Define the maximum distance the camera can see to.
  28435. * This is important to note that the depth buffer are not infinite and the further it end
  28436. * the more your scene might encounter depth fighting issue.
  28437. */
  28438. maxZ: number;
  28439. /**
  28440. * Define the default inertia of the camera.
  28441. * This helps giving a smooth feeling to the camera movement.
  28442. */
  28443. inertia: number;
  28444. /**
  28445. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28446. */
  28447. mode: number;
  28448. /**
  28449. * Define whether the camera is intermediate.
  28450. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28451. */
  28452. isIntermediate: boolean;
  28453. /**
  28454. * Define the viewport of the camera.
  28455. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28456. */
  28457. viewport: Viewport;
  28458. /**
  28459. * Restricts the camera to viewing objects with the same layerMask.
  28460. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28461. */
  28462. layerMask: number;
  28463. /**
  28464. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28465. */
  28466. fovMode: number;
  28467. /**
  28468. * Rig mode of the camera.
  28469. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28470. * This is normally controlled byt the camera themselves as internal use.
  28471. */
  28472. cameraRigMode: number;
  28473. /**
  28474. * Defines the distance between both "eyes" in case of a RIG
  28475. */
  28476. interaxialDistance: number;
  28477. /**
  28478. * Defines if stereoscopic rendering is done side by side or over under.
  28479. */
  28480. isStereoscopicSideBySide: boolean;
  28481. /**
  28482. * 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
  28483. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28484. * else in the scene. (Eg. security camera)
  28485. *
  28486. * 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)
  28487. */
  28488. customRenderTargets: RenderTargetTexture[];
  28489. /**
  28490. * When set, the camera will render to this render target instead of the default canvas
  28491. *
  28492. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28493. */
  28494. outputRenderTarget: Nullable<RenderTargetTexture>;
  28495. /**
  28496. * Observable triggered when the camera view matrix has changed.
  28497. */
  28498. onViewMatrixChangedObservable: Observable<Camera>;
  28499. /**
  28500. * Observable triggered when the camera Projection matrix has changed.
  28501. */
  28502. onProjectionMatrixChangedObservable: Observable<Camera>;
  28503. /**
  28504. * Observable triggered when the inputs have been processed.
  28505. */
  28506. onAfterCheckInputsObservable: Observable<Camera>;
  28507. /**
  28508. * Observable triggered when reset has been called and applied to the camera.
  28509. */
  28510. onRestoreStateObservable: Observable<Camera>;
  28511. /**
  28512. * Is this camera a part of a rig system?
  28513. */
  28514. isRigCamera: boolean;
  28515. /**
  28516. * If isRigCamera set to true this will be set with the parent camera.
  28517. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28518. */
  28519. rigParent?: Camera;
  28520. /** @hidden */
  28521. _cameraRigParams: any;
  28522. /** @hidden */
  28523. _rigCameras: Camera[];
  28524. /** @hidden */
  28525. _rigPostProcess: Nullable<PostProcess>;
  28526. protected _webvrViewMatrix: Matrix;
  28527. /** @hidden */
  28528. _skipRendering: boolean;
  28529. /** @hidden */
  28530. _projectionMatrix: Matrix;
  28531. /** @hidden */
  28532. _postProcesses: Nullable<PostProcess>[];
  28533. /** @hidden */
  28534. _activeMeshes: SmartArray<AbstractMesh>;
  28535. protected _globalPosition: Vector3;
  28536. /** @hidden */
  28537. _computedViewMatrix: Matrix;
  28538. private _doNotComputeProjectionMatrix;
  28539. private _transformMatrix;
  28540. private _frustumPlanes;
  28541. private _refreshFrustumPlanes;
  28542. private _storedFov;
  28543. private _stateStored;
  28544. /**
  28545. * Instantiates a new camera object.
  28546. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28547. * @see http://doc.babylonjs.com/features/cameras
  28548. * @param name Defines the name of the camera in the scene
  28549. * @param position Defines the position of the camera
  28550. * @param scene Defines the scene the camera belongs too
  28551. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28552. */
  28553. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28554. /**
  28555. * Store current camera state (fov, position, etc..)
  28556. * @returns the camera
  28557. */
  28558. storeState(): Camera;
  28559. /**
  28560. * Restores the camera state values if it has been stored. You must call storeState() first
  28561. */
  28562. protected _restoreStateValues(): boolean;
  28563. /**
  28564. * Restored camera state. You must call storeState() first.
  28565. * @returns true if restored and false otherwise
  28566. */
  28567. restoreState(): boolean;
  28568. /**
  28569. * Gets the class name of the camera.
  28570. * @returns the class name
  28571. */
  28572. getClassName(): string;
  28573. /** @hidden */
  28574. readonly _isCamera: boolean;
  28575. /**
  28576. * Gets a string representation of the camera useful for debug purpose.
  28577. * @param fullDetails Defines that a more verboe level of logging is required
  28578. * @returns the string representation
  28579. */
  28580. toString(fullDetails?: boolean): string;
  28581. /**
  28582. * Gets the current world space position of the camera.
  28583. */
  28584. get globalPosition(): Vector3;
  28585. /**
  28586. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28587. * @returns the active meshe list
  28588. */
  28589. getActiveMeshes(): SmartArray<AbstractMesh>;
  28590. /**
  28591. * Check whether a mesh is part of the current active mesh list of the camera
  28592. * @param mesh Defines the mesh to check
  28593. * @returns true if active, false otherwise
  28594. */
  28595. isActiveMesh(mesh: Mesh): boolean;
  28596. /**
  28597. * Is this camera ready to be used/rendered
  28598. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28599. * @return true if the camera is ready
  28600. */
  28601. isReady(completeCheck?: boolean): boolean;
  28602. /** @hidden */
  28603. _initCache(): void;
  28604. /** @hidden */
  28605. _updateCache(ignoreParentClass?: boolean): void;
  28606. /** @hidden */
  28607. _isSynchronized(): boolean;
  28608. /** @hidden */
  28609. _isSynchronizedViewMatrix(): boolean;
  28610. /** @hidden */
  28611. _isSynchronizedProjectionMatrix(): boolean;
  28612. /**
  28613. * Attach the input controls to a specific dom element to get the input from.
  28614. * @param element Defines the element the controls should be listened from
  28615. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28616. */
  28617. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28618. /**
  28619. * Detach the current controls from the specified dom element.
  28620. * @param element Defines the element to stop listening the inputs from
  28621. */
  28622. detachControl(element: HTMLElement): void;
  28623. /**
  28624. * Update the camera state according to the different inputs gathered during the frame.
  28625. */
  28626. update(): void;
  28627. /** @hidden */
  28628. _checkInputs(): void;
  28629. /** @hidden */
  28630. get rigCameras(): Camera[];
  28631. /**
  28632. * Gets the post process used by the rig cameras
  28633. */
  28634. get rigPostProcess(): Nullable<PostProcess>;
  28635. /**
  28636. * Internal, gets the first post proces.
  28637. * @returns the first post process to be run on this camera.
  28638. */
  28639. _getFirstPostProcess(): Nullable<PostProcess>;
  28640. private _cascadePostProcessesToRigCams;
  28641. /**
  28642. * Attach a post process to the camera.
  28643. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28644. * @param postProcess The post process to attach to the camera
  28645. * @param insertAt The position of the post process in case several of them are in use in the scene
  28646. * @returns the position the post process has been inserted at
  28647. */
  28648. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28649. /**
  28650. * Detach a post process to the camera.
  28651. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28652. * @param postProcess The post process to detach from the camera
  28653. */
  28654. detachPostProcess(postProcess: PostProcess): void;
  28655. /**
  28656. * Gets the current world matrix of the camera
  28657. */
  28658. getWorldMatrix(): Matrix;
  28659. /** @hidden */
  28660. _getViewMatrix(): Matrix;
  28661. /**
  28662. * Gets the current view matrix of the camera.
  28663. * @param force forces the camera to recompute the matrix without looking at the cached state
  28664. * @returns the view matrix
  28665. */
  28666. getViewMatrix(force?: boolean): Matrix;
  28667. /**
  28668. * Freeze the projection matrix.
  28669. * It will prevent the cache check of the camera projection compute and can speed up perf
  28670. * if no parameter of the camera are meant to change
  28671. * @param projection Defines manually a projection if necessary
  28672. */
  28673. freezeProjectionMatrix(projection?: Matrix): void;
  28674. /**
  28675. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28676. */
  28677. unfreezeProjectionMatrix(): void;
  28678. /**
  28679. * Gets the current projection matrix of the camera.
  28680. * @param force forces the camera to recompute the matrix without looking at the cached state
  28681. * @returns the projection matrix
  28682. */
  28683. getProjectionMatrix(force?: boolean): Matrix;
  28684. /**
  28685. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28686. * @returns a Matrix
  28687. */
  28688. getTransformationMatrix(): Matrix;
  28689. private _updateFrustumPlanes;
  28690. /**
  28691. * Checks if a cullable object (mesh...) is in the camera frustum
  28692. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28693. * @param target The object to check
  28694. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28695. * @returns true if the object is in frustum otherwise false
  28696. */
  28697. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28698. /**
  28699. * Checks if a cullable object (mesh...) is in the camera frustum
  28700. * Unlike isInFrustum this cheks the full bounding box
  28701. * @param target The object to check
  28702. * @returns true if the object is in frustum otherwise false
  28703. */
  28704. isCompletelyInFrustum(target: ICullable): boolean;
  28705. /**
  28706. * Gets a ray in the forward direction from the camera.
  28707. * @param length Defines the length of the ray to create
  28708. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28709. * @param origin Defines the start point of the ray which defaults to the camera position
  28710. * @returns the forward ray
  28711. */
  28712. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28713. /**
  28714. * Releases resources associated with this node.
  28715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28717. */
  28718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28719. /** @hidden */
  28720. _isLeftCamera: boolean;
  28721. /**
  28722. * Gets the left camera of a rig setup in case of Rigged Camera
  28723. */
  28724. get isLeftCamera(): boolean;
  28725. /** @hidden */
  28726. _isRightCamera: boolean;
  28727. /**
  28728. * Gets the right camera of a rig setup in case of Rigged Camera
  28729. */
  28730. get isRightCamera(): boolean;
  28731. /**
  28732. * Gets the left camera of a rig setup in case of Rigged Camera
  28733. */
  28734. get leftCamera(): Nullable<FreeCamera>;
  28735. /**
  28736. * Gets the right camera of a rig setup in case of Rigged Camera
  28737. */
  28738. get rightCamera(): Nullable<FreeCamera>;
  28739. /**
  28740. * Gets the left camera target of a rig setup in case of Rigged Camera
  28741. * @returns the target position
  28742. */
  28743. getLeftTarget(): Nullable<Vector3>;
  28744. /**
  28745. * Gets the right camera target of a rig setup in case of Rigged Camera
  28746. * @returns the target position
  28747. */
  28748. getRightTarget(): Nullable<Vector3>;
  28749. /**
  28750. * @hidden
  28751. */
  28752. setCameraRigMode(mode: number, rigParams: any): void;
  28753. /** @hidden */
  28754. static _setStereoscopicRigMode(camera: Camera): void;
  28755. /** @hidden */
  28756. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28757. /** @hidden */
  28758. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28759. /** @hidden */
  28760. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28761. /** @hidden */
  28762. _getVRProjectionMatrix(): Matrix;
  28763. protected _updateCameraRotationMatrix(): void;
  28764. protected _updateWebVRCameraRotationMatrix(): void;
  28765. /**
  28766. * This function MUST be overwritten by the different WebVR cameras available.
  28767. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28768. * @hidden
  28769. */
  28770. _getWebVRProjectionMatrix(): Matrix;
  28771. /**
  28772. * This function MUST be overwritten by the different WebVR cameras available.
  28773. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28774. * @hidden
  28775. */
  28776. _getWebVRViewMatrix(): Matrix;
  28777. /** @hidden */
  28778. setCameraRigParameter(name: string, value: any): void;
  28779. /**
  28780. * needs to be overridden by children so sub has required properties to be copied
  28781. * @hidden
  28782. */
  28783. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28784. /**
  28785. * May need to be overridden by children
  28786. * @hidden
  28787. */
  28788. _updateRigCameras(): void;
  28789. /** @hidden */
  28790. _setupInputs(): void;
  28791. /**
  28792. * Serialiaze the camera setup to a json represention
  28793. * @returns the JSON representation
  28794. */
  28795. serialize(): any;
  28796. /**
  28797. * Clones the current camera.
  28798. * @param name The cloned camera name
  28799. * @returns the cloned camera
  28800. */
  28801. clone(name: string): Camera;
  28802. /**
  28803. * Gets the direction of the camera relative to a given local axis.
  28804. * @param localAxis Defines the reference axis to provide a relative direction.
  28805. * @return the direction
  28806. */
  28807. getDirection(localAxis: Vector3): Vector3;
  28808. /**
  28809. * Returns the current camera absolute rotation
  28810. */
  28811. get absoluteRotation(): Quaternion;
  28812. /**
  28813. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28814. * @param localAxis Defines the reference axis to provide a relative direction.
  28815. * @param result Defines the vector to store the result in
  28816. */
  28817. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28818. /**
  28819. * Gets a camera constructor for a given camera type
  28820. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28821. * @param name The name of the camera the result will be able to instantiate
  28822. * @param scene The scene the result will construct the camera in
  28823. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28824. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28825. * @returns a factory method to construc the camera
  28826. */
  28827. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28828. /**
  28829. * Compute the world matrix of the camera.
  28830. * @returns the camera world matrix
  28831. */
  28832. computeWorldMatrix(): Matrix;
  28833. /**
  28834. * Parse a JSON and creates the camera from the parsed information
  28835. * @param parsedCamera The JSON to parse
  28836. * @param scene The scene to instantiate the camera in
  28837. * @returns the newly constructed camera
  28838. */
  28839. static Parse(parsedCamera: any, scene: Scene): Camera;
  28840. }
  28841. }
  28842. declare module BABYLON {
  28843. /**
  28844. * Class containing static functions to help procedurally build meshes
  28845. */
  28846. export class DiscBuilder {
  28847. /**
  28848. * Creates a plane polygonal mesh. By default, this is a disc
  28849. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28850. * * 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
  28851. * * 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
  28852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28853. * * 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
  28854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28855. * @param name defines the name of the mesh
  28856. * @param options defines the options used to create the mesh
  28857. * @param scene defines the hosting scene
  28858. * @returns the plane polygonal mesh
  28859. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28860. */
  28861. static CreateDisc(name: string, options: {
  28862. radius?: number;
  28863. tessellation?: number;
  28864. arc?: number;
  28865. updatable?: boolean;
  28866. sideOrientation?: number;
  28867. frontUVs?: Vector4;
  28868. backUVs?: Vector4;
  28869. }, scene?: Nullable<Scene>): Mesh;
  28870. }
  28871. }
  28872. declare module BABYLON {
  28873. /**
  28874. * Options to be used when creating a FresnelParameters.
  28875. */
  28876. export type IFresnelParametersCreationOptions = {
  28877. /**
  28878. * Define the color used on edges (grazing angle)
  28879. */
  28880. leftColor?: Color3;
  28881. /**
  28882. * Define the color used on center
  28883. */
  28884. rightColor?: Color3;
  28885. /**
  28886. * Define bias applied to computed fresnel term
  28887. */
  28888. bias?: number;
  28889. /**
  28890. * Defined the power exponent applied to fresnel term
  28891. */
  28892. power?: number;
  28893. /**
  28894. * Define if the fresnel effect is enable or not.
  28895. */
  28896. isEnabled?: boolean;
  28897. };
  28898. /**
  28899. * Serialized format for FresnelParameters.
  28900. */
  28901. export type IFresnelParametersSerialized = {
  28902. /**
  28903. * Define the color used on edges (grazing angle) [as an array]
  28904. */
  28905. leftColor: number[];
  28906. /**
  28907. * Define the color used on center [as an array]
  28908. */
  28909. rightColor: number[];
  28910. /**
  28911. * Define bias applied to computed fresnel term
  28912. */
  28913. bias: number;
  28914. /**
  28915. * Defined the power exponent applied to fresnel term
  28916. */
  28917. power?: number;
  28918. /**
  28919. * Define if the fresnel effect is enable or not.
  28920. */
  28921. isEnabled: boolean;
  28922. };
  28923. /**
  28924. * This represents all the required information to add a fresnel effect on a material:
  28925. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28926. */
  28927. export class FresnelParameters {
  28928. private _isEnabled;
  28929. /**
  28930. * Define if the fresnel effect is enable or not.
  28931. */
  28932. get isEnabled(): boolean;
  28933. set isEnabled(value: boolean);
  28934. /**
  28935. * Define the color used on edges (grazing angle)
  28936. */
  28937. leftColor: Color3;
  28938. /**
  28939. * Define the color used on center
  28940. */
  28941. rightColor: Color3;
  28942. /**
  28943. * Define bias applied to computed fresnel term
  28944. */
  28945. bias: number;
  28946. /**
  28947. * Defined the power exponent applied to fresnel term
  28948. */
  28949. power: number;
  28950. /**
  28951. * Creates a new FresnelParameters object.
  28952. *
  28953. * @param options provide your own settings to optionally to override defaults
  28954. */
  28955. constructor(options?: IFresnelParametersCreationOptions);
  28956. /**
  28957. * Clones the current fresnel and its valuues
  28958. * @returns a clone fresnel configuration
  28959. */
  28960. clone(): FresnelParameters;
  28961. /**
  28962. * Determines equality between FresnelParameters objects
  28963. * @param otherFresnelParameters defines the second operand
  28964. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  28965. */
  28966. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  28967. /**
  28968. * Serializes the current fresnel parameters to a JSON representation.
  28969. * @return the JSON serialization
  28970. */
  28971. serialize(): IFresnelParametersSerialized;
  28972. /**
  28973. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28974. * @param parsedFresnelParameters Define the JSON representation
  28975. * @returns the parsed parameters
  28976. */
  28977. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  28978. }
  28979. }
  28980. declare module BABYLON {
  28981. /**
  28982. * This groups all the flags used to control the materials channel.
  28983. */
  28984. export class MaterialFlags {
  28985. private static _DiffuseTextureEnabled;
  28986. /**
  28987. * Are diffuse textures enabled in the application.
  28988. */
  28989. static get DiffuseTextureEnabled(): boolean;
  28990. static set DiffuseTextureEnabled(value: boolean);
  28991. private static _AmbientTextureEnabled;
  28992. /**
  28993. * Are ambient textures enabled in the application.
  28994. */
  28995. static get AmbientTextureEnabled(): boolean;
  28996. static set AmbientTextureEnabled(value: boolean);
  28997. private static _OpacityTextureEnabled;
  28998. /**
  28999. * Are opacity textures enabled in the application.
  29000. */
  29001. static get OpacityTextureEnabled(): boolean;
  29002. static set OpacityTextureEnabled(value: boolean);
  29003. private static _ReflectionTextureEnabled;
  29004. /**
  29005. * Are reflection textures enabled in the application.
  29006. */
  29007. static get ReflectionTextureEnabled(): boolean;
  29008. static set ReflectionTextureEnabled(value: boolean);
  29009. private static _EmissiveTextureEnabled;
  29010. /**
  29011. * Are emissive textures enabled in the application.
  29012. */
  29013. static get EmissiveTextureEnabled(): boolean;
  29014. static set EmissiveTextureEnabled(value: boolean);
  29015. private static _SpecularTextureEnabled;
  29016. /**
  29017. * Are specular textures enabled in the application.
  29018. */
  29019. static get SpecularTextureEnabled(): boolean;
  29020. static set SpecularTextureEnabled(value: boolean);
  29021. private static _BumpTextureEnabled;
  29022. /**
  29023. * Are bump textures enabled in the application.
  29024. */
  29025. static get BumpTextureEnabled(): boolean;
  29026. static set BumpTextureEnabled(value: boolean);
  29027. private static _LightmapTextureEnabled;
  29028. /**
  29029. * Are lightmap textures enabled in the application.
  29030. */
  29031. static get LightmapTextureEnabled(): boolean;
  29032. static set LightmapTextureEnabled(value: boolean);
  29033. private static _RefractionTextureEnabled;
  29034. /**
  29035. * Are refraction textures enabled in the application.
  29036. */
  29037. static get RefractionTextureEnabled(): boolean;
  29038. static set RefractionTextureEnabled(value: boolean);
  29039. private static _ColorGradingTextureEnabled;
  29040. /**
  29041. * Are color grading textures enabled in the application.
  29042. */
  29043. static get ColorGradingTextureEnabled(): boolean;
  29044. static set ColorGradingTextureEnabled(value: boolean);
  29045. private static _FresnelEnabled;
  29046. /**
  29047. * Are fresnels enabled in the application.
  29048. */
  29049. static get FresnelEnabled(): boolean;
  29050. static set FresnelEnabled(value: boolean);
  29051. private static _ClearCoatTextureEnabled;
  29052. /**
  29053. * Are clear coat textures enabled in the application.
  29054. */
  29055. static get ClearCoatTextureEnabled(): boolean;
  29056. static set ClearCoatTextureEnabled(value: boolean);
  29057. private static _ClearCoatBumpTextureEnabled;
  29058. /**
  29059. * Are clear coat bump textures enabled in the application.
  29060. */
  29061. static get ClearCoatBumpTextureEnabled(): boolean;
  29062. static set ClearCoatBumpTextureEnabled(value: boolean);
  29063. private static _ClearCoatTintTextureEnabled;
  29064. /**
  29065. * Are clear coat tint textures enabled in the application.
  29066. */
  29067. static get ClearCoatTintTextureEnabled(): boolean;
  29068. static set ClearCoatTintTextureEnabled(value: boolean);
  29069. private static _SheenTextureEnabled;
  29070. /**
  29071. * Are sheen textures enabled in the application.
  29072. */
  29073. static get SheenTextureEnabled(): boolean;
  29074. static set SheenTextureEnabled(value: boolean);
  29075. private static _AnisotropicTextureEnabled;
  29076. /**
  29077. * Are anisotropic textures enabled in the application.
  29078. */
  29079. static get AnisotropicTextureEnabled(): boolean;
  29080. static set AnisotropicTextureEnabled(value: boolean);
  29081. private static _ThicknessTextureEnabled;
  29082. /**
  29083. * Are thickness textures enabled in the application.
  29084. */
  29085. static get ThicknessTextureEnabled(): boolean;
  29086. static set ThicknessTextureEnabled(value: boolean);
  29087. }
  29088. }
  29089. declare module BABYLON {
  29090. /** @hidden */
  29091. export var defaultFragmentDeclaration: {
  29092. name: string;
  29093. shader: string;
  29094. };
  29095. }
  29096. declare module BABYLON {
  29097. /** @hidden */
  29098. export var defaultUboDeclaration: {
  29099. name: string;
  29100. shader: string;
  29101. };
  29102. }
  29103. declare module BABYLON {
  29104. /** @hidden */
  29105. export var lightFragmentDeclaration: {
  29106. name: string;
  29107. shader: string;
  29108. };
  29109. }
  29110. declare module BABYLON {
  29111. /** @hidden */
  29112. export var lightUboDeclaration: {
  29113. name: string;
  29114. shader: string;
  29115. };
  29116. }
  29117. declare module BABYLON {
  29118. /** @hidden */
  29119. export var lightsFragmentFunctions: {
  29120. name: string;
  29121. shader: string;
  29122. };
  29123. }
  29124. declare module BABYLON {
  29125. /** @hidden */
  29126. export var shadowsFragmentFunctions: {
  29127. name: string;
  29128. shader: string;
  29129. };
  29130. }
  29131. declare module BABYLON {
  29132. /** @hidden */
  29133. export var fresnelFunction: {
  29134. name: string;
  29135. shader: string;
  29136. };
  29137. }
  29138. declare module BABYLON {
  29139. /** @hidden */
  29140. export var bumpFragmentMainFunctions: {
  29141. name: string;
  29142. shader: string;
  29143. };
  29144. }
  29145. declare module BABYLON {
  29146. /** @hidden */
  29147. export var bumpFragmentFunctions: {
  29148. name: string;
  29149. shader: string;
  29150. };
  29151. }
  29152. declare module BABYLON {
  29153. /** @hidden */
  29154. export var logDepthDeclaration: {
  29155. name: string;
  29156. shader: string;
  29157. };
  29158. }
  29159. declare module BABYLON {
  29160. /** @hidden */
  29161. export var bumpFragment: {
  29162. name: string;
  29163. shader: string;
  29164. };
  29165. }
  29166. declare module BABYLON {
  29167. /** @hidden */
  29168. export var depthPrePass: {
  29169. name: string;
  29170. shader: string;
  29171. };
  29172. }
  29173. declare module BABYLON {
  29174. /** @hidden */
  29175. export var lightFragment: {
  29176. name: string;
  29177. shader: string;
  29178. };
  29179. }
  29180. declare module BABYLON {
  29181. /** @hidden */
  29182. export var logDepthFragment: {
  29183. name: string;
  29184. shader: string;
  29185. };
  29186. }
  29187. declare module BABYLON {
  29188. /** @hidden */
  29189. export var defaultPixelShader: {
  29190. name: string;
  29191. shader: string;
  29192. };
  29193. }
  29194. declare module BABYLON {
  29195. /** @hidden */
  29196. export var defaultVertexDeclaration: {
  29197. name: string;
  29198. shader: string;
  29199. };
  29200. }
  29201. declare module BABYLON {
  29202. /** @hidden */
  29203. export var bumpVertexDeclaration: {
  29204. name: string;
  29205. shader: string;
  29206. };
  29207. }
  29208. declare module BABYLON {
  29209. /** @hidden */
  29210. export var bumpVertex: {
  29211. name: string;
  29212. shader: string;
  29213. };
  29214. }
  29215. declare module BABYLON {
  29216. /** @hidden */
  29217. export var fogVertex: {
  29218. name: string;
  29219. shader: string;
  29220. };
  29221. }
  29222. declare module BABYLON {
  29223. /** @hidden */
  29224. export var shadowsVertex: {
  29225. name: string;
  29226. shader: string;
  29227. };
  29228. }
  29229. declare module BABYLON {
  29230. /** @hidden */
  29231. export var pointCloudVertex: {
  29232. name: string;
  29233. shader: string;
  29234. };
  29235. }
  29236. declare module BABYLON {
  29237. /** @hidden */
  29238. export var logDepthVertex: {
  29239. name: string;
  29240. shader: string;
  29241. };
  29242. }
  29243. declare module BABYLON {
  29244. /** @hidden */
  29245. export var defaultVertexShader: {
  29246. name: string;
  29247. shader: string;
  29248. };
  29249. }
  29250. declare module BABYLON {
  29251. /** @hidden */
  29252. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29253. MAINUV1: boolean;
  29254. MAINUV2: boolean;
  29255. DIFFUSE: boolean;
  29256. DIFFUSEDIRECTUV: number;
  29257. AMBIENT: boolean;
  29258. AMBIENTDIRECTUV: number;
  29259. OPACITY: boolean;
  29260. OPACITYDIRECTUV: number;
  29261. OPACITYRGB: boolean;
  29262. REFLECTION: boolean;
  29263. EMISSIVE: boolean;
  29264. EMISSIVEDIRECTUV: number;
  29265. SPECULAR: boolean;
  29266. SPECULARDIRECTUV: number;
  29267. BUMP: boolean;
  29268. BUMPDIRECTUV: number;
  29269. PARALLAX: boolean;
  29270. PARALLAXOCCLUSION: boolean;
  29271. SPECULAROVERALPHA: boolean;
  29272. CLIPPLANE: boolean;
  29273. CLIPPLANE2: boolean;
  29274. CLIPPLANE3: boolean;
  29275. CLIPPLANE4: boolean;
  29276. CLIPPLANE5: boolean;
  29277. CLIPPLANE6: boolean;
  29278. ALPHATEST: boolean;
  29279. DEPTHPREPASS: boolean;
  29280. ALPHAFROMDIFFUSE: boolean;
  29281. POINTSIZE: boolean;
  29282. FOG: boolean;
  29283. SPECULARTERM: boolean;
  29284. DIFFUSEFRESNEL: boolean;
  29285. OPACITYFRESNEL: boolean;
  29286. REFLECTIONFRESNEL: boolean;
  29287. REFRACTIONFRESNEL: boolean;
  29288. EMISSIVEFRESNEL: boolean;
  29289. FRESNEL: boolean;
  29290. NORMAL: boolean;
  29291. UV1: boolean;
  29292. UV2: boolean;
  29293. VERTEXCOLOR: boolean;
  29294. VERTEXALPHA: boolean;
  29295. NUM_BONE_INFLUENCERS: number;
  29296. BonesPerMesh: number;
  29297. BONETEXTURE: boolean;
  29298. INSTANCES: boolean;
  29299. GLOSSINESS: boolean;
  29300. ROUGHNESS: boolean;
  29301. EMISSIVEASILLUMINATION: boolean;
  29302. LINKEMISSIVEWITHDIFFUSE: boolean;
  29303. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29304. LIGHTMAP: boolean;
  29305. LIGHTMAPDIRECTUV: number;
  29306. OBJECTSPACE_NORMALMAP: boolean;
  29307. USELIGHTMAPASSHADOWMAP: boolean;
  29308. REFLECTIONMAP_3D: boolean;
  29309. REFLECTIONMAP_SPHERICAL: boolean;
  29310. REFLECTIONMAP_PLANAR: boolean;
  29311. REFLECTIONMAP_CUBIC: boolean;
  29312. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29313. REFLECTIONMAP_PROJECTION: boolean;
  29314. REFLECTIONMAP_SKYBOX: boolean;
  29315. REFLECTIONMAP_EXPLICIT: boolean;
  29316. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29317. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29318. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29319. INVERTCUBICMAP: boolean;
  29320. LOGARITHMICDEPTH: boolean;
  29321. REFRACTION: boolean;
  29322. REFRACTIONMAP_3D: boolean;
  29323. REFLECTIONOVERALPHA: boolean;
  29324. TWOSIDEDLIGHTING: boolean;
  29325. SHADOWFLOAT: boolean;
  29326. MORPHTARGETS: boolean;
  29327. MORPHTARGETS_NORMAL: boolean;
  29328. MORPHTARGETS_TANGENT: boolean;
  29329. MORPHTARGETS_UV: boolean;
  29330. NUM_MORPH_INFLUENCERS: number;
  29331. NONUNIFORMSCALING: boolean;
  29332. PREMULTIPLYALPHA: boolean;
  29333. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29334. ALPHABLEND: boolean;
  29335. RGBDLIGHTMAP: boolean;
  29336. RGBDREFLECTION: boolean;
  29337. RGBDREFRACTION: boolean;
  29338. IMAGEPROCESSING: boolean;
  29339. VIGNETTE: boolean;
  29340. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29341. VIGNETTEBLENDMODEOPAQUE: boolean;
  29342. TONEMAPPING: boolean;
  29343. TONEMAPPING_ACES: boolean;
  29344. CONTRAST: boolean;
  29345. COLORCURVES: boolean;
  29346. COLORGRADING: boolean;
  29347. COLORGRADING3D: boolean;
  29348. SAMPLER3DGREENDEPTH: boolean;
  29349. SAMPLER3DBGRMAP: boolean;
  29350. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29351. MULTIVIEW: boolean;
  29352. /**
  29353. * If the reflection texture on this material is in linear color space
  29354. * @hidden
  29355. */
  29356. IS_REFLECTION_LINEAR: boolean;
  29357. /**
  29358. * If the refraction texture on this material is in linear color space
  29359. * @hidden
  29360. */
  29361. IS_REFRACTION_LINEAR: boolean;
  29362. EXPOSURE: boolean;
  29363. constructor();
  29364. setReflectionMode(modeToEnable: string): void;
  29365. }
  29366. /**
  29367. * This is the default material used in Babylon. It is the best trade off between quality
  29368. * and performances.
  29369. * @see http://doc.babylonjs.com/babylon101/materials
  29370. */
  29371. export class StandardMaterial extends PushMaterial {
  29372. private _diffuseTexture;
  29373. /**
  29374. * The basic texture of the material as viewed under a light.
  29375. */
  29376. diffuseTexture: Nullable<BaseTexture>;
  29377. private _ambientTexture;
  29378. /**
  29379. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29380. */
  29381. ambientTexture: Nullable<BaseTexture>;
  29382. private _opacityTexture;
  29383. /**
  29384. * Define the transparency of the material from a texture.
  29385. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29386. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29387. */
  29388. opacityTexture: Nullable<BaseTexture>;
  29389. private _reflectionTexture;
  29390. /**
  29391. * Define the texture used to display the reflection.
  29392. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29393. */
  29394. reflectionTexture: Nullable<BaseTexture>;
  29395. private _emissiveTexture;
  29396. /**
  29397. * Define texture of the material as if self lit.
  29398. * This will be mixed in the final result even in the absence of light.
  29399. */
  29400. emissiveTexture: Nullable<BaseTexture>;
  29401. private _specularTexture;
  29402. /**
  29403. * Define how the color and intensity of the highlight given by the light in the material.
  29404. */
  29405. specularTexture: Nullable<BaseTexture>;
  29406. private _bumpTexture;
  29407. /**
  29408. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29409. * 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.
  29410. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29411. */
  29412. bumpTexture: Nullable<BaseTexture>;
  29413. private _lightmapTexture;
  29414. /**
  29415. * Complex lighting can be computationally expensive to compute at runtime.
  29416. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29417. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29418. */
  29419. lightmapTexture: Nullable<BaseTexture>;
  29420. private _refractionTexture;
  29421. /**
  29422. * Define the texture used to display the refraction.
  29423. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29424. */
  29425. refractionTexture: Nullable<BaseTexture>;
  29426. /**
  29427. * The color of the material lit by the environmental background lighting.
  29428. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29429. */
  29430. ambientColor: Color3;
  29431. /**
  29432. * The basic color of the material as viewed under a light.
  29433. */
  29434. diffuseColor: Color3;
  29435. /**
  29436. * Define how the color and intensity of the highlight given by the light in the material.
  29437. */
  29438. specularColor: Color3;
  29439. /**
  29440. * Define the color of the material as if self lit.
  29441. * This will be mixed in the final result even in the absence of light.
  29442. */
  29443. emissiveColor: Color3;
  29444. /**
  29445. * Defines how sharp are the highlights in the material.
  29446. * The bigger the value the sharper giving a more glossy feeling to the result.
  29447. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29448. */
  29449. specularPower: number;
  29450. private _useAlphaFromDiffuseTexture;
  29451. /**
  29452. * Does the transparency come from the diffuse texture alpha channel.
  29453. */
  29454. useAlphaFromDiffuseTexture: boolean;
  29455. private _useEmissiveAsIllumination;
  29456. /**
  29457. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29458. */
  29459. useEmissiveAsIllumination: boolean;
  29460. private _linkEmissiveWithDiffuse;
  29461. /**
  29462. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29463. * the emissive level when the final color is close to one.
  29464. */
  29465. linkEmissiveWithDiffuse: boolean;
  29466. private _useSpecularOverAlpha;
  29467. /**
  29468. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29469. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29470. */
  29471. useSpecularOverAlpha: boolean;
  29472. private _useReflectionOverAlpha;
  29473. /**
  29474. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29475. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29476. */
  29477. useReflectionOverAlpha: boolean;
  29478. private _disableLighting;
  29479. /**
  29480. * Does lights from the scene impacts this material.
  29481. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29482. */
  29483. disableLighting: boolean;
  29484. private _useObjectSpaceNormalMap;
  29485. /**
  29486. * Allows using an object space normal map (instead of tangent space).
  29487. */
  29488. useObjectSpaceNormalMap: boolean;
  29489. private _useParallax;
  29490. /**
  29491. * Is parallax enabled or not.
  29492. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29493. */
  29494. useParallax: boolean;
  29495. private _useParallaxOcclusion;
  29496. /**
  29497. * Is parallax occlusion enabled or not.
  29498. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29499. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29500. */
  29501. useParallaxOcclusion: boolean;
  29502. /**
  29503. * 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.
  29504. */
  29505. parallaxScaleBias: number;
  29506. private _roughness;
  29507. /**
  29508. * Helps to define how blurry the reflections should appears in the material.
  29509. */
  29510. roughness: number;
  29511. /**
  29512. * In case of refraction, define the value of the index of refraction.
  29513. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29514. */
  29515. indexOfRefraction: number;
  29516. /**
  29517. * Invert the refraction texture alongside the y axis.
  29518. * It can be useful with procedural textures or probe for instance.
  29519. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29520. */
  29521. invertRefractionY: boolean;
  29522. /**
  29523. * Defines the alpha limits in alpha test mode.
  29524. */
  29525. alphaCutOff: number;
  29526. private _useLightmapAsShadowmap;
  29527. /**
  29528. * In case of light mapping, define whether the map contains light or shadow informations.
  29529. */
  29530. useLightmapAsShadowmap: boolean;
  29531. private _diffuseFresnelParameters;
  29532. /**
  29533. * Define the diffuse fresnel parameters of the material.
  29534. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29535. */
  29536. diffuseFresnelParameters: FresnelParameters;
  29537. private _opacityFresnelParameters;
  29538. /**
  29539. * Define the opacity fresnel parameters of the material.
  29540. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29541. */
  29542. opacityFresnelParameters: FresnelParameters;
  29543. private _reflectionFresnelParameters;
  29544. /**
  29545. * Define the reflection fresnel parameters of the material.
  29546. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29547. */
  29548. reflectionFresnelParameters: FresnelParameters;
  29549. private _refractionFresnelParameters;
  29550. /**
  29551. * Define the refraction fresnel parameters of the material.
  29552. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29553. */
  29554. refractionFresnelParameters: FresnelParameters;
  29555. private _emissiveFresnelParameters;
  29556. /**
  29557. * Define the emissive fresnel parameters of the material.
  29558. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29559. */
  29560. emissiveFresnelParameters: FresnelParameters;
  29561. private _useReflectionFresnelFromSpecular;
  29562. /**
  29563. * If true automatically deducts the fresnels values from the material specularity.
  29564. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29565. */
  29566. useReflectionFresnelFromSpecular: boolean;
  29567. private _useGlossinessFromSpecularMapAlpha;
  29568. /**
  29569. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29570. */
  29571. useGlossinessFromSpecularMapAlpha: boolean;
  29572. private _maxSimultaneousLights;
  29573. /**
  29574. * Defines the maximum number of lights that can be used in the material
  29575. */
  29576. maxSimultaneousLights: number;
  29577. private _invertNormalMapX;
  29578. /**
  29579. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29580. */
  29581. invertNormalMapX: boolean;
  29582. private _invertNormalMapY;
  29583. /**
  29584. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29585. */
  29586. invertNormalMapY: boolean;
  29587. private _twoSidedLighting;
  29588. /**
  29589. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29590. */
  29591. twoSidedLighting: boolean;
  29592. /**
  29593. * Default configuration related to image processing available in the standard Material.
  29594. */
  29595. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29596. /**
  29597. * Gets the image processing configuration used either in this material.
  29598. */
  29599. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29600. /**
  29601. * Sets the Default image processing configuration used either in the this material.
  29602. *
  29603. * If sets to null, the scene one is in use.
  29604. */
  29605. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29606. /**
  29607. * Keep track of the image processing observer to allow dispose and replace.
  29608. */
  29609. private _imageProcessingObserver;
  29610. /**
  29611. * Attaches a new image processing configuration to the Standard Material.
  29612. * @param configuration
  29613. */
  29614. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29615. /**
  29616. * Gets wether the color curves effect is enabled.
  29617. */
  29618. get cameraColorCurvesEnabled(): boolean;
  29619. /**
  29620. * Sets wether the color curves effect is enabled.
  29621. */
  29622. set cameraColorCurvesEnabled(value: boolean);
  29623. /**
  29624. * Gets wether the color grading effect is enabled.
  29625. */
  29626. get cameraColorGradingEnabled(): boolean;
  29627. /**
  29628. * Gets wether the color grading effect is enabled.
  29629. */
  29630. set cameraColorGradingEnabled(value: boolean);
  29631. /**
  29632. * Gets wether tonemapping is enabled or not.
  29633. */
  29634. get cameraToneMappingEnabled(): boolean;
  29635. /**
  29636. * Sets wether tonemapping is enabled or not
  29637. */
  29638. set cameraToneMappingEnabled(value: boolean);
  29639. /**
  29640. * The camera exposure used on this material.
  29641. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29642. * This corresponds to a photographic exposure.
  29643. */
  29644. get cameraExposure(): number;
  29645. /**
  29646. * The camera exposure used on this material.
  29647. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29648. * This corresponds to a photographic exposure.
  29649. */
  29650. set cameraExposure(value: number);
  29651. /**
  29652. * Gets The camera contrast used on this material.
  29653. */
  29654. get cameraContrast(): number;
  29655. /**
  29656. * Sets The camera contrast used on this material.
  29657. */
  29658. set cameraContrast(value: number);
  29659. /**
  29660. * Gets the Color Grading 2D Lookup Texture.
  29661. */
  29662. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29663. /**
  29664. * Sets the Color Grading 2D Lookup Texture.
  29665. */
  29666. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29667. /**
  29668. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29669. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29670. * 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;
  29671. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29672. */
  29673. get cameraColorCurves(): Nullable<ColorCurves>;
  29674. /**
  29675. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29676. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29677. * 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;
  29678. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29679. */
  29680. set cameraColorCurves(value: Nullable<ColorCurves>);
  29681. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29682. protected _worldViewProjectionMatrix: Matrix;
  29683. protected _globalAmbientColor: Color3;
  29684. protected _useLogarithmicDepth: boolean;
  29685. protected _rebuildInParallel: boolean;
  29686. /**
  29687. * Instantiates a new standard material.
  29688. * This is the default material used in Babylon. It is the best trade off between quality
  29689. * and performances.
  29690. * @see http://doc.babylonjs.com/babylon101/materials
  29691. * @param name Define the name of the material in the scene
  29692. * @param scene Define the scene the material belong to
  29693. */
  29694. constructor(name: string, scene: Scene);
  29695. /**
  29696. * Gets a boolean indicating that current material needs to register RTT
  29697. */
  29698. get hasRenderTargetTextures(): boolean;
  29699. /**
  29700. * Gets the current class name of the material e.g. "StandardMaterial"
  29701. * Mainly use in serialization.
  29702. * @returns the class name
  29703. */
  29704. getClassName(): string;
  29705. /**
  29706. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29707. * You can try switching to logarithmic depth.
  29708. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29709. */
  29710. get useLogarithmicDepth(): boolean;
  29711. set useLogarithmicDepth(value: boolean);
  29712. /**
  29713. * Specifies if the material will require alpha blending
  29714. * @returns a boolean specifying if alpha blending is needed
  29715. */
  29716. needAlphaBlending(): boolean;
  29717. /**
  29718. * Specifies if this material should be rendered in alpha test mode
  29719. * @returns a boolean specifying if an alpha test is needed.
  29720. */
  29721. needAlphaTesting(): boolean;
  29722. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29723. /**
  29724. * Get the texture used for alpha test purpose.
  29725. * @returns the diffuse texture in case of the standard material.
  29726. */
  29727. getAlphaTestTexture(): Nullable<BaseTexture>;
  29728. /**
  29729. * Get if the submesh is ready to be used and all its information available.
  29730. * Child classes can use it to update shaders
  29731. * @param mesh defines the mesh to check
  29732. * @param subMesh defines which submesh to check
  29733. * @param useInstances specifies that instances should be used
  29734. * @returns a boolean indicating that the submesh is ready or not
  29735. */
  29736. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29737. /**
  29738. * Builds the material UBO layouts.
  29739. * Used internally during the effect preparation.
  29740. */
  29741. buildUniformLayout(): void;
  29742. /**
  29743. * Unbinds the material from the mesh
  29744. */
  29745. unbind(): void;
  29746. /**
  29747. * Binds the submesh to this material by preparing the effect and shader to draw
  29748. * @param world defines the world transformation matrix
  29749. * @param mesh defines the mesh containing the submesh
  29750. * @param subMesh defines the submesh to bind the material to
  29751. */
  29752. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29753. /**
  29754. * Get the list of animatables in the material.
  29755. * @returns the list of animatables object used in the material
  29756. */
  29757. getAnimatables(): IAnimatable[];
  29758. /**
  29759. * Gets the active textures from the material
  29760. * @returns an array of textures
  29761. */
  29762. getActiveTextures(): BaseTexture[];
  29763. /**
  29764. * Specifies if the material uses a texture
  29765. * @param texture defines the texture to check against the material
  29766. * @returns a boolean specifying if the material uses the texture
  29767. */
  29768. hasTexture(texture: BaseTexture): boolean;
  29769. /**
  29770. * Disposes the material
  29771. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29772. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29773. */
  29774. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29775. /**
  29776. * Makes a duplicate of the material, and gives it a new name
  29777. * @param name defines the new name for the duplicated material
  29778. * @returns the cloned material
  29779. */
  29780. clone(name: string): StandardMaterial;
  29781. /**
  29782. * Serializes this material in a JSON representation
  29783. * @returns the serialized material object
  29784. */
  29785. serialize(): any;
  29786. /**
  29787. * Creates a standard material from parsed material data
  29788. * @param source defines the JSON representation of the material
  29789. * @param scene defines the hosting scene
  29790. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29791. * @returns a new standard material
  29792. */
  29793. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29794. /**
  29795. * Are diffuse textures enabled in the application.
  29796. */
  29797. static get DiffuseTextureEnabled(): boolean;
  29798. static set DiffuseTextureEnabled(value: boolean);
  29799. /**
  29800. * Are ambient textures enabled in the application.
  29801. */
  29802. static get AmbientTextureEnabled(): boolean;
  29803. static set AmbientTextureEnabled(value: boolean);
  29804. /**
  29805. * Are opacity textures enabled in the application.
  29806. */
  29807. static get OpacityTextureEnabled(): boolean;
  29808. static set OpacityTextureEnabled(value: boolean);
  29809. /**
  29810. * Are reflection textures enabled in the application.
  29811. */
  29812. static get ReflectionTextureEnabled(): boolean;
  29813. static set ReflectionTextureEnabled(value: boolean);
  29814. /**
  29815. * Are emissive textures enabled in the application.
  29816. */
  29817. static get EmissiveTextureEnabled(): boolean;
  29818. static set EmissiveTextureEnabled(value: boolean);
  29819. /**
  29820. * Are specular textures enabled in the application.
  29821. */
  29822. static get SpecularTextureEnabled(): boolean;
  29823. static set SpecularTextureEnabled(value: boolean);
  29824. /**
  29825. * Are bump textures enabled in the application.
  29826. */
  29827. static get BumpTextureEnabled(): boolean;
  29828. static set BumpTextureEnabled(value: boolean);
  29829. /**
  29830. * Are lightmap textures enabled in the application.
  29831. */
  29832. static get LightmapTextureEnabled(): boolean;
  29833. static set LightmapTextureEnabled(value: boolean);
  29834. /**
  29835. * Are refraction textures enabled in the application.
  29836. */
  29837. static get RefractionTextureEnabled(): boolean;
  29838. static set RefractionTextureEnabled(value: boolean);
  29839. /**
  29840. * Are color grading textures enabled in the application.
  29841. */
  29842. static get ColorGradingTextureEnabled(): boolean;
  29843. static set ColorGradingTextureEnabled(value: boolean);
  29844. /**
  29845. * Are fresnels enabled in the application.
  29846. */
  29847. static get FresnelEnabled(): boolean;
  29848. static set FresnelEnabled(value: boolean);
  29849. }
  29850. }
  29851. declare module BABYLON {
  29852. /**
  29853. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  29854. *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.
  29855. * The SPS is also a particle system. It provides some methods to manage the particles.
  29856. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  29857. *
  29858. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  29859. */
  29860. export class SolidParticleSystem implements IDisposable {
  29861. /**
  29862. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  29863. * Example : var p = SPS.particles[i];
  29864. */
  29865. particles: SolidParticle[];
  29866. /**
  29867. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  29868. */
  29869. nbParticles: number;
  29870. /**
  29871. * If the particles must ever face the camera (default false). Useful for planar particles.
  29872. */
  29873. billboard: boolean;
  29874. /**
  29875. * Recompute normals when adding a shape
  29876. */
  29877. recomputeNormals: boolean;
  29878. /**
  29879. * This a counter ofr your own usage. It's not set by any SPS functions.
  29880. */
  29881. counter: number;
  29882. /**
  29883. * The SPS name. This name is also given to the underlying mesh.
  29884. */
  29885. name: string;
  29886. /**
  29887. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  29888. */
  29889. mesh: Mesh;
  29890. /**
  29891. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  29892. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  29893. */
  29894. vars: any;
  29895. /**
  29896. * This array is populated when the SPS is set as 'pickable'.
  29897. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  29898. * Each element of this array is an object `{idx: int, faceId: int}`.
  29899. * `idx` is the picked particle index in the `SPS.particles` array
  29900. * `faceId` is the picked face index counted within this particle.
  29901. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  29902. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  29903. * Use the method SPS.pickedParticle(pickingInfo) instead.
  29904. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29905. */
  29906. pickedParticles: {
  29907. idx: number;
  29908. faceId: number;
  29909. }[];
  29910. /**
  29911. * This array is populated when the SPS is set as 'pickable'
  29912. * Each key of this array is a submesh index.
  29913. * Each element of this array is a second array defined like this :
  29914. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  29915. * Each element of this second array is an object `{idx: int, faceId: int}`.
  29916. * `idx` is the picked particle index in the `SPS.particles` array
  29917. * `faceId` is the picked face index counted within this particle.
  29918. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  29919. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29920. */
  29921. pickedBySubMesh: {
  29922. idx: number;
  29923. faceId: number;
  29924. }[][];
  29925. /**
  29926. * This array is populated when `enableDepthSort` is set to true.
  29927. * Each element of this array is an instance of the class DepthSortedParticle.
  29928. */
  29929. depthSortedParticles: DepthSortedParticle[];
  29930. /**
  29931. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  29932. * @hidden
  29933. */
  29934. _bSphereOnly: boolean;
  29935. /**
  29936. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  29937. * @hidden
  29938. */
  29939. _bSphereRadiusFactor: number;
  29940. private _scene;
  29941. private _positions;
  29942. private _indices;
  29943. private _normals;
  29944. private _colors;
  29945. private _uvs;
  29946. private _indices32;
  29947. private _positions32;
  29948. private _normals32;
  29949. private _fixedNormal32;
  29950. private _colors32;
  29951. private _uvs32;
  29952. private _index;
  29953. private _updatable;
  29954. private _pickable;
  29955. private _isVisibilityBoxLocked;
  29956. private _alwaysVisible;
  29957. private _depthSort;
  29958. private _expandable;
  29959. private _shapeCounter;
  29960. private _copy;
  29961. private _color;
  29962. private _computeParticleColor;
  29963. private _computeParticleTexture;
  29964. private _computeParticleRotation;
  29965. private _computeParticleVertex;
  29966. private _computeBoundingBox;
  29967. private _depthSortParticles;
  29968. private _camera;
  29969. private _mustUnrotateFixedNormals;
  29970. private _particlesIntersect;
  29971. private _needs32Bits;
  29972. private _isNotBuilt;
  29973. private _lastParticleId;
  29974. private _idxOfId;
  29975. private _multimaterialEnabled;
  29976. private _useModelMaterial;
  29977. private _indicesByMaterial;
  29978. private _materialIndexes;
  29979. private _depthSortFunction;
  29980. private _materialSortFunction;
  29981. private _materials;
  29982. private _multimaterial;
  29983. private _materialIndexesById;
  29984. private _defaultMaterial;
  29985. private _autoUpdateSubMeshes;
  29986. private _tmpVertex;
  29987. /**
  29988. * Creates a SPS (Solid Particle System) object.
  29989. * @param name (String) is the SPS name, this will be the underlying mesh name.
  29990. * @param scene (Scene) is the scene in which the SPS is added.
  29991. * @param options defines the options of the sps e.g.
  29992. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  29993. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  29994. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  29995. * * 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.
  29996. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  29997. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  29998. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  29999. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30000. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30001. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30002. */
  30003. constructor(name: string, scene: Scene, options?: {
  30004. updatable?: boolean;
  30005. isPickable?: boolean;
  30006. enableDepthSort?: boolean;
  30007. particleIntersection?: boolean;
  30008. boundingSphereOnly?: boolean;
  30009. bSphereRadiusFactor?: number;
  30010. expandable?: boolean;
  30011. useModelMaterial?: boolean;
  30012. enableMultiMaterial?: boolean;
  30013. });
  30014. /**
  30015. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30016. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30017. * @returns the created mesh
  30018. */
  30019. buildMesh(): Mesh;
  30020. /**
  30021. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30022. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30023. * Thus the particles generated from `digest()` have their property `position` set yet.
  30024. * @param mesh ( Mesh ) is the mesh to be digested
  30025. * @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
  30026. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30027. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30028. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30029. * @returns the current SPS
  30030. */
  30031. digest(mesh: Mesh, options?: {
  30032. facetNb?: number;
  30033. number?: number;
  30034. delta?: number;
  30035. storage?: [];
  30036. }): SolidParticleSystem;
  30037. /**
  30038. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30039. * @hidden
  30040. */
  30041. private _unrotateFixedNormals;
  30042. /**
  30043. * Resets the temporary working copy particle
  30044. * @hidden
  30045. */
  30046. private _resetCopy;
  30047. /**
  30048. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30049. * @param p the current index in the positions array to be updated
  30050. * @param ind the current index in the indices array
  30051. * @param shape a Vector3 array, the shape geometry
  30052. * @param positions the positions array to be updated
  30053. * @param meshInd the shape indices array
  30054. * @param indices the indices array to be updated
  30055. * @param meshUV the shape uv array
  30056. * @param uvs the uv array to be updated
  30057. * @param meshCol the shape color array
  30058. * @param colors the color array to be updated
  30059. * @param meshNor the shape normals array
  30060. * @param normals the normals array to be updated
  30061. * @param idx the particle index
  30062. * @param idxInShape the particle index in its shape
  30063. * @param options the addShape() method passed options
  30064. * @model the particle model
  30065. * @hidden
  30066. */
  30067. private _meshBuilder;
  30068. /**
  30069. * Returns a shape Vector3 array from positions float array
  30070. * @param positions float array
  30071. * @returns a vector3 array
  30072. * @hidden
  30073. */
  30074. private _posToShape;
  30075. /**
  30076. * Returns a shapeUV array from a float uvs (array deep copy)
  30077. * @param uvs as a float array
  30078. * @returns a shapeUV array
  30079. * @hidden
  30080. */
  30081. private _uvsToShapeUV;
  30082. /**
  30083. * Adds a new particle object in the particles array
  30084. * @param idx particle index in particles array
  30085. * @param id particle id
  30086. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30087. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30088. * @param model particle ModelShape object
  30089. * @param shapeId model shape identifier
  30090. * @param idxInShape index of the particle in the current model
  30091. * @param bInfo model bounding info object
  30092. * @param storage target storage array, if any
  30093. * @hidden
  30094. */
  30095. private _addParticle;
  30096. /**
  30097. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30098. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30099. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30100. * @param nb (positive integer) the number of particles to be created from this model
  30101. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30102. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30103. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30104. * @returns the number of shapes in the system
  30105. */
  30106. addShape(mesh: Mesh, nb: number, options?: {
  30107. positionFunction?: any;
  30108. vertexFunction?: any;
  30109. storage?: [];
  30110. }): number;
  30111. /**
  30112. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30113. * @hidden
  30114. */
  30115. private _rebuildParticle;
  30116. /**
  30117. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30118. * @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.
  30119. * @returns the SPS.
  30120. */
  30121. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30122. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30123. * Returns an array with the removed particles.
  30124. * 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.
  30125. * The SPS can't be empty so at least one particle needs to remain in place.
  30126. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30127. * @param start index of the first particle to remove
  30128. * @param end index of the last particle to remove (included)
  30129. * @returns an array populated with the removed particles
  30130. */
  30131. removeParticles(start: number, end: number): SolidParticle[];
  30132. /**
  30133. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30134. * @param solidParticleArray an array populated with Solid Particles objects
  30135. * @returns the SPS
  30136. */
  30137. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30138. /**
  30139. * Creates a new particle and modifies the SPS mesh geometry :
  30140. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30141. * - calls _addParticle() to populate the particle array
  30142. * factorized code from addShape() and insertParticlesFromArray()
  30143. * @param idx particle index in the particles array
  30144. * @param i particle index in its shape
  30145. * @param modelShape particle ModelShape object
  30146. * @param shape shape vertex array
  30147. * @param meshInd shape indices array
  30148. * @param meshUV shape uv array
  30149. * @param meshCol shape color array
  30150. * @param meshNor shape normals array
  30151. * @param bbInfo shape bounding info
  30152. * @param storage target particle storage
  30153. * @options addShape() passed options
  30154. * @hidden
  30155. */
  30156. private _insertNewParticle;
  30157. /**
  30158. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30159. * This method calls `updateParticle()` for each particle of the SPS.
  30160. * For an animated SPS, it is usually called within the render loop.
  30161. * 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.
  30162. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30163. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30164. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30165. * @returns the SPS.
  30166. */
  30167. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30168. /**
  30169. * Disposes the SPS.
  30170. */
  30171. dispose(): void;
  30172. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30173. * idx is the particle index in the SPS
  30174. * faceId is the picked face index counted within this particle.
  30175. * Returns null if the pickInfo can't identify a picked particle.
  30176. * @param pickingInfo (PickingInfo object)
  30177. * @returns {idx: number, faceId: number} or null
  30178. */
  30179. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30180. idx: number;
  30181. faceId: number;
  30182. }>;
  30183. /**
  30184. * Returns a SolidParticle object from its identifier : particle.id
  30185. * @param id (integer) the particle Id
  30186. * @returns the searched particle or null if not found in the SPS.
  30187. */
  30188. getParticleById(id: number): Nullable<SolidParticle>;
  30189. /**
  30190. * Returns a new array populated with the particles having the passed shapeId.
  30191. * @param shapeId (integer) the shape identifier
  30192. * @returns a new solid particle array
  30193. */
  30194. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30195. /**
  30196. * Populates the passed array "ref" with the particles having the passed shapeId.
  30197. * @param shapeId the shape identifier
  30198. * @returns the SPS
  30199. * @param ref
  30200. */
  30201. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30202. /**
  30203. * Computes the required SubMeshes according the materials assigned to the particles.
  30204. * @returns the solid particle system.
  30205. * Does nothing if called before the SPS mesh is built.
  30206. */
  30207. computeSubMeshes(): SolidParticleSystem;
  30208. /**
  30209. * Sorts the solid particles by material when MultiMaterial is enabled.
  30210. * Updates the indices32 array.
  30211. * Updates the indicesByMaterial array.
  30212. * Updates the mesh indices array.
  30213. * @returns the SPS
  30214. * @hidden
  30215. */
  30216. private _sortParticlesByMaterial;
  30217. /**
  30218. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30219. * @hidden
  30220. */
  30221. private _setMaterialIndexesById;
  30222. /**
  30223. * Returns an array with unique values of Materials from the passed array
  30224. * @param array the material array to be checked and filtered
  30225. * @hidden
  30226. */
  30227. private _filterUniqueMaterialId;
  30228. /**
  30229. * Sets a new Standard Material as _defaultMaterial if not already set.
  30230. * @hidden
  30231. */
  30232. private _setDefaultMaterial;
  30233. /**
  30234. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30235. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30236. * @returns the SPS.
  30237. */
  30238. refreshVisibleSize(): SolidParticleSystem;
  30239. /**
  30240. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30241. * @param size the size (float) of the visibility box
  30242. * note : this doesn't lock the SPS mesh bounding box.
  30243. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30244. */
  30245. setVisibilityBox(size: number): void;
  30246. /**
  30247. * Gets whether the SPS as always visible or not
  30248. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30249. */
  30250. get isAlwaysVisible(): boolean;
  30251. /**
  30252. * Sets the SPS as always visible or not
  30253. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30254. */
  30255. set isAlwaysVisible(val: boolean);
  30256. /**
  30257. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30258. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30259. */
  30260. set isVisibilityBoxLocked(val: boolean);
  30261. /**
  30262. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30263. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30264. */
  30265. get isVisibilityBoxLocked(): boolean;
  30266. /**
  30267. * Tells to `setParticles()` to compute the particle rotations or not.
  30268. * Default value : true. The SPS is faster when it's set to false.
  30269. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30270. */
  30271. set computeParticleRotation(val: boolean);
  30272. /**
  30273. * Tells to `setParticles()` to compute the particle colors or not.
  30274. * Default value : true. The SPS is faster when it's set to false.
  30275. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30276. */
  30277. set computeParticleColor(val: boolean);
  30278. set computeParticleTexture(val: boolean);
  30279. /**
  30280. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30281. * Default value : false. The SPS is faster when it's set to false.
  30282. * Note : the particle custom vertex positions aren't stored values.
  30283. */
  30284. set computeParticleVertex(val: boolean);
  30285. /**
  30286. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30287. */
  30288. set computeBoundingBox(val: boolean);
  30289. /**
  30290. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30291. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30292. * Default : `true`
  30293. */
  30294. set depthSortParticles(val: boolean);
  30295. /**
  30296. * Gets if `setParticles()` computes the particle rotations or not.
  30297. * Default value : true. The SPS is faster when it's set to false.
  30298. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30299. */
  30300. get computeParticleRotation(): boolean;
  30301. /**
  30302. * Gets if `setParticles()` computes the particle colors or not.
  30303. * Default value : true. The SPS is faster when it's set to false.
  30304. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30305. */
  30306. get computeParticleColor(): boolean;
  30307. /**
  30308. * Gets if `setParticles()` computes the particle textures or not.
  30309. * Default value : true. The SPS is faster when it's set to false.
  30310. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30311. */
  30312. get computeParticleTexture(): boolean;
  30313. /**
  30314. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30315. * Default value : false. The SPS is faster when it's set to false.
  30316. * Note : the particle custom vertex positions aren't stored values.
  30317. */
  30318. get computeParticleVertex(): boolean;
  30319. /**
  30320. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30321. */
  30322. get computeBoundingBox(): boolean;
  30323. /**
  30324. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30325. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30326. * Default : `true`
  30327. */
  30328. get depthSortParticles(): boolean;
  30329. /**
  30330. * Gets if the SPS is created as expandable at construction time.
  30331. * Default : `false`
  30332. */
  30333. get expandable(): boolean;
  30334. /**
  30335. * Gets if the SPS supports the Multi Materials
  30336. */
  30337. get multimaterialEnabled(): boolean;
  30338. /**
  30339. * Gets if the SPS uses the model materials for its own multimaterial.
  30340. */
  30341. get useModelMaterial(): boolean;
  30342. /**
  30343. * The SPS used material array.
  30344. */
  30345. get materials(): Material[];
  30346. /**
  30347. * Sets the SPS MultiMaterial from the passed materials.
  30348. * Note : the passed array is internally copied and not used then by reference.
  30349. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30350. */
  30351. setMultiMaterial(materials: Material[]): void;
  30352. /**
  30353. * The SPS computed multimaterial object
  30354. */
  30355. get multimaterial(): MultiMaterial;
  30356. set multimaterial(mm: MultiMaterial);
  30357. /**
  30358. * If the subMeshes must be updated on the next call to setParticles()
  30359. */
  30360. get autoUpdateSubMeshes(): boolean;
  30361. set autoUpdateSubMeshes(val: boolean);
  30362. /**
  30363. * This function does nothing. It may be overwritten to set all the particle first values.
  30364. * The SPS doesn't call this function, you may have to call it by your own.
  30365. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30366. */
  30367. initParticles(): void;
  30368. /**
  30369. * This function does nothing. It may be overwritten to recycle a particle.
  30370. * The SPS doesn't call this function, you may have to call it by your own.
  30371. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30372. * @param particle The particle to recycle
  30373. * @returns the recycled particle
  30374. */
  30375. recycleParticle(particle: SolidParticle): SolidParticle;
  30376. /**
  30377. * Updates a particle : this function should be overwritten by the user.
  30378. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30379. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30380. * @example : just set a particle position or velocity and recycle conditions
  30381. * @param particle The particle to update
  30382. * @returns the updated particle
  30383. */
  30384. updateParticle(particle: SolidParticle): SolidParticle;
  30385. /**
  30386. * Updates a vertex of a particle : it can be overwritten by the user.
  30387. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30388. * @param particle the current particle
  30389. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30390. * @param pt the index of the current vertex in the particle shape
  30391. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30392. * @example : just set a vertex particle position or color
  30393. * @returns the sps
  30394. */
  30395. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30396. /**
  30397. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30398. * This does nothing and may be overwritten by the user.
  30399. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30400. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30401. * @param update the boolean update value actually passed to setParticles()
  30402. */
  30403. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30404. /**
  30405. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30406. * This will be passed three parameters.
  30407. * This does nothing and may be overwritten by the user.
  30408. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30409. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30410. * @param update the boolean update value actually passed to setParticles()
  30411. */
  30412. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30413. }
  30414. }
  30415. declare module BABYLON {
  30416. /**
  30417. * Represents one particle of a solid particle system.
  30418. */
  30419. export class SolidParticle {
  30420. /**
  30421. * particle global index
  30422. */
  30423. idx: number;
  30424. /**
  30425. * particle identifier
  30426. */
  30427. id: number;
  30428. /**
  30429. * The color of the particle
  30430. */
  30431. color: Nullable<Color4>;
  30432. /**
  30433. * The world space position of the particle.
  30434. */
  30435. position: Vector3;
  30436. /**
  30437. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30438. */
  30439. rotation: Vector3;
  30440. /**
  30441. * The world space rotation quaternion of the particle.
  30442. */
  30443. rotationQuaternion: Nullable<Quaternion>;
  30444. /**
  30445. * The scaling of the particle.
  30446. */
  30447. scaling: Vector3;
  30448. /**
  30449. * The uvs of the particle.
  30450. */
  30451. uvs: Vector4;
  30452. /**
  30453. * The current speed of the particle.
  30454. */
  30455. velocity: Vector3;
  30456. /**
  30457. * The pivot point in the particle local space.
  30458. */
  30459. pivot: Vector3;
  30460. /**
  30461. * Must the particle be translated from its pivot point in its local space ?
  30462. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30463. * Default : false
  30464. */
  30465. translateFromPivot: boolean;
  30466. /**
  30467. * Is the particle active or not ?
  30468. */
  30469. alive: boolean;
  30470. /**
  30471. * Is the particle visible or not ?
  30472. */
  30473. isVisible: boolean;
  30474. /**
  30475. * Index of this particle in the global "positions" array (Internal use)
  30476. * @hidden
  30477. */
  30478. _pos: number;
  30479. /**
  30480. * @hidden Index of this particle in the global "indices" array (Internal use)
  30481. */
  30482. _ind: number;
  30483. /**
  30484. * @hidden ModelShape of this particle (Internal use)
  30485. */
  30486. _model: ModelShape;
  30487. /**
  30488. * ModelShape id of this particle
  30489. */
  30490. shapeId: number;
  30491. /**
  30492. * Index of the particle in its shape id
  30493. */
  30494. idxInShape: number;
  30495. /**
  30496. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30497. */
  30498. _modelBoundingInfo: BoundingInfo;
  30499. /**
  30500. * @hidden Particle BoundingInfo object (Internal use)
  30501. */
  30502. _boundingInfo: BoundingInfo;
  30503. /**
  30504. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30505. */
  30506. _sps: SolidParticleSystem;
  30507. /**
  30508. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30509. */
  30510. _stillInvisible: boolean;
  30511. /**
  30512. * @hidden Last computed particle rotation matrix
  30513. */
  30514. _rotationMatrix: number[];
  30515. /**
  30516. * Parent particle Id, if any.
  30517. * Default null.
  30518. */
  30519. parentId: Nullable<number>;
  30520. /**
  30521. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30522. */
  30523. materialIndex: Nullable<number>;
  30524. /**
  30525. * Custom object or properties.
  30526. */
  30527. props: Nullable<any>;
  30528. /**
  30529. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30530. * The possible values are :
  30531. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30532. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30533. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30534. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30535. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30536. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30537. * */
  30538. cullingStrategy: number;
  30539. /**
  30540. * @hidden Internal global position in the SPS.
  30541. */
  30542. _globalPosition: Vector3;
  30543. /**
  30544. * Creates a Solid Particle object.
  30545. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30546. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30547. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30548. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30549. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30550. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30551. * @param shapeId (integer) is the model shape identifier in the SPS.
  30552. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30553. * @param sps defines the sps it is associated to
  30554. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30555. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30556. */
  30557. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30558. /**
  30559. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30560. * @param target the particle target
  30561. * @returns the current particle
  30562. */
  30563. copyToRef(target: SolidParticle): SolidParticle;
  30564. /**
  30565. * Legacy support, changed scale to scaling
  30566. */
  30567. get scale(): Vector3;
  30568. /**
  30569. * Legacy support, changed scale to scaling
  30570. */
  30571. set scale(scale: Vector3);
  30572. /**
  30573. * Legacy support, changed quaternion to rotationQuaternion
  30574. */
  30575. get quaternion(): Nullable<Quaternion>;
  30576. /**
  30577. * Legacy support, changed quaternion to rotationQuaternion
  30578. */
  30579. set quaternion(q: Nullable<Quaternion>);
  30580. /**
  30581. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30582. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30583. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30584. * @returns true if it intersects
  30585. */
  30586. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30587. /**
  30588. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30589. * A particle is in the frustum if its bounding box intersects the frustum
  30590. * @param frustumPlanes defines the frustum to test
  30591. * @returns true if the particle is in the frustum planes
  30592. */
  30593. isInFrustum(frustumPlanes: Plane[]): boolean;
  30594. /**
  30595. * get the rotation matrix of the particle
  30596. * @hidden
  30597. */
  30598. getRotationMatrix(m: Matrix): void;
  30599. }
  30600. /**
  30601. * Represents the shape of the model used by one particle of a solid particle system.
  30602. * SPS internal tool, don't use it manually.
  30603. */
  30604. export class ModelShape {
  30605. /**
  30606. * The shape id
  30607. * @hidden
  30608. */
  30609. shapeID: number;
  30610. /**
  30611. * flat array of model positions (internal use)
  30612. * @hidden
  30613. */
  30614. _shape: Vector3[];
  30615. /**
  30616. * flat array of model UVs (internal use)
  30617. * @hidden
  30618. */
  30619. _shapeUV: number[];
  30620. /**
  30621. * color array of the model
  30622. * @hidden
  30623. */
  30624. _shapeColors: number[];
  30625. /**
  30626. * indices array of the model
  30627. * @hidden
  30628. */
  30629. _indices: number[];
  30630. /**
  30631. * normals array of the model
  30632. * @hidden
  30633. */
  30634. _normals: number[];
  30635. /**
  30636. * length of the shape in the model indices array (internal use)
  30637. * @hidden
  30638. */
  30639. _indicesLength: number;
  30640. /**
  30641. * Custom position function (internal use)
  30642. * @hidden
  30643. */
  30644. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30645. /**
  30646. * Custom vertex function (internal use)
  30647. * @hidden
  30648. */
  30649. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30650. /**
  30651. * Model material (internal use)
  30652. * @hidden
  30653. */
  30654. _material: Nullable<Material>;
  30655. /**
  30656. * 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.
  30657. * SPS internal tool, don't use it manually.
  30658. * @hidden
  30659. */
  30660. 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>);
  30661. }
  30662. /**
  30663. * Represents a Depth Sorted Particle in the solid particle system.
  30664. * @hidden
  30665. */
  30666. export class DepthSortedParticle {
  30667. /**
  30668. * Particle index
  30669. */
  30670. idx: number;
  30671. /**
  30672. * Index of the particle in the "indices" array
  30673. */
  30674. ind: number;
  30675. /**
  30676. * Length of the particle shape in the "indices" array
  30677. */
  30678. indicesLength: number;
  30679. /**
  30680. * Squared distance from the particle to the camera
  30681. */
  30682. sqDistance: number;
  30683. /**
  30684. * Material index when used with MultiMaterials
  30685. */
  30686. materialIndex: number;
  30687. /**
  30688. * Creates a new sorted particle
  30689. * @param materialIndex
  30690. */
  30691. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30692. }
  30693. /**
  30694. * Represents a solid particle vertex
  30695. */
  30696. export class SolidParticleVertex {
  30697. /**
  30698. * Vertex position
  30699. */
  30700. position: Vector3;
  30701. /**
  30702. * Vertex color
  30703. */
  30704. color: Color4;
  30705. /**
  30706. * Vertex UV
  30707. */
  30708. uv: Vector2;
  30709. /**
  30710. * Creates a new solid particle vertex
  30711. */
  30712. constructor();
  30713. /** Vertex x coordinate */
  30714. get x(): number;
  30715. set x(val: number);
  30716. /** Vertex y coordinate */
  30717. get y(): number;
  30718. set y(val: number);
  30719. /** Vertex z coordinate */
  30720. get z(): number;
  30721. set z(val: number);
  30722. }
  30723. }
  30724. declare module BABYLON {
  30725. /**
  30726. * @hidden
  30727. */
  30728. export class _MeshCollisionData {
  30729. _checkCollisions: boolean;
  30730. _collisionMask: number;
  30731. _collisionGroup: number;
  30732. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30733. _collider: Nullable<Collider>;
  30734. _oldPositionForCollisions: Vector3;
  30735. _diffPositionForCollisions: Vector3;
  30736. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30737. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30738. }
  30739. }
  30740. declare module BABYLON {
  30741. /** @hidden */
  30742. class _FacetDataStorage {
  30743. facetPositions: Vector3[];
  30744. facetNormals: Vector3[];
  30745. facetPartitioning: number[][];
  30746. facetNb: number;
  30747. partitioningSubdivisions: number;
  30748. partitioningBBoxRatio: number;
  30749. facetDataEnabled: boolean;
  30750. facetParameters: any;
  30751. bbSize: Vector3;
  30752. subDiv: {
  30753. max: number;
  30754. X: number;
  30755. Y: number;
  30756. Z: number;
  30757. };
  30758. facetDepthSort: boolean;
  30759. facetDepthSortEnabled: boolean;
  30760. depthSortedIndices: IndicesArray;
  30761. depthSortedFacets: {
  30762. ind: number;
  30763. sqDistance: number;
  30764. }[];
  30765. facetDepthSortFunction: (f1: {
  30766. ind: number;
  30767. sqDistance: number;
  30768. }, f2: {
  30769. ind: number;
  30770. sqDistance: number;
  30771. }) => number;
  30772. facetDepthSortFrom: Vector3;
  30773. facetDepthSortOrigin: Vector3;
  30774. invertedMatrix: Matrix;
  30775. }
  30776. /**
  30777. * @hidden
  30778. **/
  30779. class _InternalAbstractMeshDataInfo {
  30780. _hasVertexAlpha: boolean;
  30781. _useVertexColors: boolean;
  30782. _numBoneInfluencers: number;
  30783. _applyFog: boolean;
  30784. _receiveShadows: boolean;
  30785. _facetData: _FacetDataStorage;
  30786. _visibility: number;
  30787. _skeleton: Nullable<Skeleton>;
  30788. _layerMask: number;
  30789. _computeBonesUsingShaders: boolean;
  30790. _isActive: boolean;
  30791. _onlyForInstances: boolean;
  30792. _isActiveIntermediate: boolean;
  30793. _onlyForInstancesIntermediate: boolean;
  30794. _actAsRegularMesh: boolean;
  30795. }
  30796. /**
  30797. * Class used to store all common mesh properties
  30798. */
  30799. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30800. /** No occlusion */
  30801. static OCCLUSION_TYPE_NONE: number;
  30802. /** Occlusion set to optimisitic */
  30803. static OCCLUSION_TYPE_OPTIMISTIC: number;
  30804. /** Occlusion set to strict */
  30805. static OCCLUSION_TYPE_STRICT: number;
  30806. /** Use an accurante occlusion algorithm */
  30807. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  30808. /** Use a conservative occlusion algorithm */
  30809. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  30810. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30811. * Test order :
  30812. * Is the bounding sphere outside the frustum ?
  30813. * If not, are the bounding box vertices outside the frustum ?
  30814. * It not, then the cullable object is in the frustum.
  30815. */
  30816. static readonly CULLINGSTRATEGY_STANDARD: number;
  30817. /** Culling strategy : Bounding Sphere Only.
  30818. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30819. * It's also less accurate than the standard because some not visible objects can still be selected.
  30820. * Test : is the bounding sphere outside the frustum ?
  30821. * If not, then the cullable object is in the frustum.
  30822. */
  30823. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  30824. /** Culling strategy : Optimistic Inclusion.
  30825. * This in an inclusion test first, then the standard exclusion test.
  30826. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  30827. * 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.
  30828. * Anyway, it's as accurate as the standard strategy.
  30829. * Test :
  30830. * Is the cullable object bounding sphere center in the frustum ?
  30831. * If not, apply the default culling strategy.
  30832. */
  30833. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  30834. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  30835. * This in an inclusion test first, then the bounding sphere only exclusion test.
  30836. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  30837. * 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.
  30838. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  30839. * Test :
  30840. * Is the cullable object bounding sphere center in the frustum ?
  30841. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  30842. */
  30843. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  30844. /**
  30845. * No billboard
  30846. */
  30847. static get BILLBOARDMODE_NONE(): number;
  30848. /** Billboard on X axis */
  30849. static get BILLBOARDMODE_X(): number;
  30850. /** Billboard on Y axis */
  30851. static get BILLBOARDMODE_Y(): number;
  30852. /** Billboard on Z axis */
  30853. static get BILLBOARDMODE_Z(): number;
  30854. /** Billboard on all axes */
  30855. static get BILLBOARDMODE_ALL(): number;
  30856. /** Billboard on using position instead of orientation */
  30857. static get BILLBOARDMODE_USE_POSITION(): number;
  30858. /** @hidden */
  30859. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  30860. /**
  30861. * The culling strategy to use to check whether the mesh must be rendered or not.
  30862. * This value can be changed at any time and will be used on the next render mesh selection.
  30863. * The possible values are :
  30864. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30865. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30866. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30867. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30868. * Please read each static variable documentation to get details about the culling process.
  30869. * */
  30870. cullingStrategy: number;
  30871. /**
  30872. * Gets the number of facets in the mesh
  30873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30874. */
  30875. get facetNb(): number;
  30876. /**
  30877. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  30878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30879. */
  30880. get partitioningSubdivisions(): number;
  30881. set partitioningSubdivisions(nb: number);
  30882. /**
  30883. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  30884. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  30885. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30886. */
  30887. get partitioningBBoxRatio(): number;
  30888. set partitioningBBoxRatio(ratio: number);
  30889. /**
  30890. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  30891. * Works only for updatable meshes.
  30892. * Doesn't work with multi-materials
  30893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30894. */
  30895. get mustDepthSortFacets(): boolean;
  30896. set mustDepthSortFacets(sort: boolean);
  30897. /**
  30898. * The location (Vector3) where the facet depth sort must be computed from.
  30899. * By default, the active camera position.
  30900. * Used only when facet depth sort is enabled
  30901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30902. */
  30903. get facetDepthSortFrom(): Vector3;
  30904. set facetDepthSortFrom(location: Vector3);
  30905. /**
  30906. * gets a boolean indicating if facetData is enabled
  30907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30908. */
  30909. get isFacetDataEnabled(): boolean;
  30910. /** @hidden */
  30911. _updateNonUniformScalingState(value: boolean): boolean;
  30912. /**
  30913. * An event triggered when this mesh collides with another one
  30914. */
  30915. onCollideObservable: Observable<AbstractMesh>;
  30916. /** Set a function to call when this mesh collides with another one */
  30917. set onCollide(callback: () => void);
  30918. /**
  30919. * An event triggered when the collision's position changes
  30920. */
  30921. onCollisionPositionChangeObservable: Observable<Vector3>;
  30922. /** Set a function to call when the collision's position changes */
  30923. set onCollisionPositionChange(callback: () => void);
  30924. /**
  30925. * An event triggered when material is changed
  30926. */
  30927. onMaterialChangedObservable: Observable<AbstractMesh>;
  30928. /**
  30929. * Gets or sets the orientation for POV movement & rotation
  30930. */
  30931. definedFacingForward: boolean;
  30932. /** @hidden */
  30933. _occlusionQuery: Nullable<WebGLQuery>;
  30934. /** @hidden */
  30935. _renderingGroup: Nullable<RenderingGroup>;
  30936. /**
  30937. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30938. */
  30939. get visibility(): number;
  30940. /**
  30941. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30942. */
  30943. set visibility(value: number);
  30944. /** Gets or sets the alpha index used to sort transparent meshes
  30945. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  30946. */
  30947. alphaIndex: number;
  30948. /**
  30949. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  30950. */
  30951. isVisible: boolean;
  30952. /**
  30953. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  30954. */
  30955. isPickable: boolean;
  30956. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  30957. showSubMeshesBoundingBox: boolean;
  30958. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  30959. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  30960. */
  30961. isBlocker: boolean;
  30962. /**
  30963. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  30964. */
  30965. enablePointerMoveEvents: boolean;
  30966. /**
  30967. * Specifies the rendering group id for this mesh (0 by default)
  30968. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  30969. */
  30970. renderingGroupId: number;
  30971. private _material;
  30972. /** Gets or sets current material */
  30973. get material(): Nullable<Material>;
  30974. set material(value: Nullable<Material>);
  30975. /**
  30976. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  30977. * @see http://doc.babylonjs.com/babylon101/shadows
  30978. */
  30979. get receiveShadows(): boolean;
  30980. set receiveShadows(value: boolean);
  30981. /** Defines color to use when rendering outline */
  30982. outlineColor: Color3;
  30983. /** Define width to use when rendering outline */
  30984. outlineWidth: number;
  30985. /** Defines color to use when rendering overlay */
  30986. overlayColor: Color3;
  30987. /** Defines alpha to use when rendering overlay */
  30988. overlayAlpha: number;
  30989. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  30990. get hasVertexAlpha(): boolean;
  30991. set hasVertexAlpha(value: boolean);
  30992. /** 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) */
  30993. get useVertexColors(): boolean;
  30994. set useVertexColors(value: boolean);
  30995. /**
  30996. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  30997. */
  30998. get computeBonesUsingShaders(): boolean;
  30999. set computeBonesUsingShaders(value: boolean);
  31000. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31001. get numBoneInfluencers(): number;
  31002. set numBoneInfluencers(value: number);
  31003. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31004. get applyFog(): boolean;
  31005. set applyFog(value: boolean);
  31006. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31007. useOctreeForRenderingSelection: boolean;
  31008. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31009. useOctreeForPicking: boolean;
  31010. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31011. useOctreeForCollisions: boolean;
  31012. /**
  31013. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31014. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31015. */
  31016. get layerMask(): number;
  31017. set layerMask(value: number);
  31018. /**
  31019. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31020. */
  31021. alwaysSelectAsActiveMesh: boolean;
  31022. /**
  31023. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31024. */
  31025. doNotSyncBoundingInfo: boolean;
  31026. /**
  31027. * Gets or sets the current action manager
  31028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31029. */
  31030. actionManager: Nullable<AbstractActionManager>;
  31031. private _meshCollisionData;
  31032. /**
  31033. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31034. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31035. */
  31036. ellipsoid: Vector3;
  31037. /**
  31038. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31039. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31040. */
  31041. ellipsoidOffset: Vector3;
  31042. /**
  31043. * Gets or sets a collision mask used to mask collisions (default is -1).
  31044. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31045. */
  31046. get collisionMask(): number;
  31047. set collisionMask(mask: number);
  31048. /**
  31049. * Gets or sets the current collision group mask (-1 by default).
  31050. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31051. */
  31052. get collisionGroup(): number;
  31053. set collisionGroup(mask: number);
  31054. /**
  31055. * Gets or sets current surrounding meshes (null by default).
  31056. *
  31057. * By default collision detection is tested against every mesh in the scene.
  31058. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31059. * meshes will be tested for the collision.
  31060. *
  31061. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31062. */
  31063. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31064. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31065. /**
  31066. * Defines edge width used when edgesRenderer is enabled
  31067. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31068. */
  31069. edgesWidth: number;
  31070. /**
  31071. * Defines edge color used when edgesRenderer is enabled
  31072. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31073. */
  31074. edgesColor: Color4;
  31075. /** @hidden */
  31076. _edgesRenderer: Nullable<IEdgesRenderer>;
  31077. /** @hidden */
  31078. _masterMesh: Nullable<AbstractMesh>;
  31079. /** @hidden */
  31080. _boundingInfo: Nullable<BoundingInfo>;
  31081. /** @hidden */
  31082. _renderId: number;
  31083. /**
  31084. * Gets or sets the list of subMeshes
  31085. * @see http://doc.babylonjs.com/how_to/multi_materials
  31086. */
  31087. subMeshes: SubMesh[];
  31088. /** @hidden */
  31089. _intersectionsInProgress: AbstractMesh[];
  31090. /** @hidden */
  31091. _unIndexed: boolean;
  31092. /** @hidden */
  31093. _lightSources: Light[];
  31094. /** Gets the list of lights affecting that mesh */
  31095. get lightSources(): Light[];
  31096. /** @hidden */
  31097. get _positions(): Nullable<Vector3[]>;
  31098. /** @hidden */
  31099. _waitingData: {
  31100. lods: Nullable<any>;
  31101. actions: Nullable<any>;
  31102. freezeWorldMatrix: Nullable<boolean>;
  31103. };
  31104. /** @hidden */
  31105. _bonesTransformMatrices: Nullable<Float32Array>;
  31106. /** @hidden */
  31107. _transformMatrixTexture: Nullable<RawTexture>;
  31108. /**
  31109. * Gets or sets a skeleton to apply skining transformations
  31110. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31111. */
  31112. set skeleton(value: Nullable<Skeleton>);
  31113. get skeleton(): Nullable<Skeleton>;
  31114. /**
  31115. * An event triggered when the mesh is rebuilt.
  31116. */
  31117. onRebuildObservable: Observable<AbstractMesh>;
  31118. /**
  31119. * Creates a new AbstractMesh
  31120. * @param name defines the name of the mesh
  31121. * @param scene defines the hosting scene
  31122. */
  31123. constructor(name: string, scene?: Nullable<Scene>);
  31124. /**
  31125. * Returns the string "AbstractMesh"
  31126. * @returns "AbstractMesh"
  31127. */
  31128. getClassName(): string;
  31129. /**
  31130. * Gets a string representation of the current mesh
  31131. * @param fullDetails defines a boolean indicating if full details must be included
  31132. * @returns a string representation of the current mesh
  31133. */
  31134. toString(fullDetails?: boolean): string;
  31135. /**
  31136. * @hidden
  31137. */
  31138. protected _getEffectiveParent(): Nullable<Node>;
  31139. /** @hidden */
  31140. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31141. /** @hidden */
  31142. _rebuild(): void;
  31143. /** @hidden */
  31144. _resyncLightSources(): void;
  31145. /** @hidden */
  31146. _resyncLightSource(light: Light): void;
  31147. /** @hidden */
  31148. _unBindEffect(): void;
  31149. /** @hidden */
  31150. _removeLightSource(light: Light, dispose: boolean): void;
  31151. private _markSubMeshesAsDirty;
  31152. /** @hidden */
  31153. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31154. /** @hidden */
  31155. _markSubMeshesAsAttributesDirty(): void;
  31156. /** @hidden */
  31157. _markSubMeshesAsMiscDirty(): void;
  31158. /**
  31159. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31160. */
  31161. get scaling(): Vector3;
  31162. set scaling(newScaling: Vector3);
  31163. /**
  31164. * Returns true if the mesh is blocked. Implemented by child classes
  31165. */
  31166. get isBlocked(): boolean;
  31167. /**
  31168. * Returns the mesh itself by default. Implemented by child classes
  31169. * @param camera defines the camera to use to pick the right LOD level
  31170. * @returns the currentAbstractMesh
  31171. */
  31172. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31173. /**
  31174. * Returns 0 by default. Implemented by child classes
  31175. * @returns an integer
  31176. */
  31177. getTotalVertices(): number;
  31178. /**
  31179. * Returns a positive integer : the total number of indices in this mesh geometry.
  31180. * @returns the numner of indices or zero if the mesh has no geometry.
  31181. */
  31182. getTotalIndices(): number;
  31183. /**
  31184. * Returns null by default. Implemented by child classes
  31185. * @returns null
  31186. */
  31187. getIndices(): Nullable<IndicesArray>;
  31188. /**
  31189. * Returns the array of the requested vertex data kind. Implemented by child classes
  31190. * @param kind defines the vertex data kind to use
  31191. * @returns null
  31192. */
  31193. getVerticesData(kind: string): Nullable<FloatArray>;
  31194. /**
  31195. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31196. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31197. * Note that a new underlying VertexBuffer object is created each call.
  31198. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31199. * @param kind defines vertex data kind:
  31200. * * VertexBuffer.PositionKind
  31201. * * VertexBuffer.UVKind
  31202. * * VertexBuffer.UV2Kind
  31203. * * VertexBuffer.UV3Kind
  31204. * * VertexBuffer.UV4Kind
  31205. * * VertexBuffer.UV5Kind
  31206. * * VertexBuffer.UV6Kind
  31207. * * VertexBuffer.ColorKind
  31208. * * VertexBuffer.MatricesIndicesKind
  31209. * * VertexBuffer.MatricesIndicesExtraKind
  31210. * * VertexBuffer.MatricesWeightsKind
  31211. * * VertexBuffer.MatricesWeightsExtraKind
  31212. * @param data defines the data source
  31213. * @param updatable defines if the data must be flagged as updatable (or static)
  31214. * @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
  31215. * @returns the current mesh
  31216. */
  31217. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31218. /**
  31219. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31220. * If the mesh has no geometry, it is simply returned as it is.
  31221. * @param kind defines vertex data kind:
  31222. * * VertexBuffer.PositionKind
  31223. * * VertexBuffer.UVKind
  31224. * * VertexBuffer.UV2Kind
  31225. * * VertexBuffer.UV3Kind
  31226. * * VertexBuffer.UV4Kind
  31227. * * VertexBuffer.UV5Kind
  31228. * * VertexBuffer.UV6Kind
  31229. * * VertexBuffer.ColorKind
  31230. * * VertexBuffer.MatricesIndicesKind
  31231. * * VertexBuffer.MatricesIndicesExtraKind
  31232. * * VertexBuffer.MatricesWeightsKind
  31233. * * VertexBuffer.MatricesWeightsExtraKind
  31234. * @param data defines the data source
  31235. * @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
  31236. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31237. * @returns the current mesh
  31238. */
  31239. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31240. /**
  31241. * Sets the mesh indices,
  31242. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31243. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31244. * @param totalVertices Defines the total number of vertices
  31245. * @returns the current mesh
  31246. */
  31247. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31248. /**
  31249. * Gets a boolean indicating if specific vertex data is present
  31250. * @param kind defines the vertex data kind to use
  31251. * @returns true is data kind is present
  31252. */
  31253. isVerticesDataPresent(kind: string): boolean;
  31254. /**
  31255. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31256. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31257. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31258. * @returns a BoundingInfo
  31259. */
  31260. getBoundingInfo(): BoundingInfo;
  31261. /**
  31262. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31263. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31264. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31265. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31266. * @returns the current mesh
  31267. */
  31268. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31269. /**
  31270. * Overwrite the current bounding info
  31271. * @param boundingInfo defines the new bounding info
  31272. * @returns the current mesh
  31273. */
  31274. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31275. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31276. get useBones(): boolean;
  31277. /** @hidden */
  31278. _preActivate(): void;
  31279. /** @hidden */
  31280. _preActivateForIntermediateRendering(renderId: number): void;
  31281. /** @hidden */
  31282. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31283. /** @hidden */
  31284. _postActivate(): void;
  31285. /** @hidden */
  31286. _freeze(): void;
  31287. /** @hidden */
  31288. _unFreeze(): void;
  31289. /**
  31290. * Gets the current world matrix
  31291. * @returns a Matrix
  31292. */
  31293. getWorldMatrix(): Matrix;
  31294. /** @hidden */
  31295. _getWorldMatrixDeterminant(): number;
  31296. /**
  31297. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31298. */
  31299. get isAnInstance(): boolean;
  31300. /**
  31301. * Gets a boolean indicating if this mesh has instances
  31302. */
  31303. get hasInstances(): boolean;
  31304. /**
  31305. * Perform relative position change from the point of view of behind the front of the mesh.
  31306. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31307. * Supports definition of mesh facing forward or backward
  31308. * @param amountRight defines the distance on the right axis
  31309. * @param amountUp defines the distance on the up axis
  31310. * @param amountForward defines the distance on the forward axis
  31311. * @returns the current mesh
  31312. */
  31313. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31314. /**
  31315. * Calculate relative position change from the point of view of behind the front of the mesh.
  31316. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31317. * Supports definition of mesh facing forward or backward
  31318. * @param amountRight defines the distance on the right axis
  31319. * @param amountUp defines the distance on the up axis
  31320. * @param amountForward defines the distance on the forward axis
  31321. * @returns the new displacement vector
  31322. */
  31323. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31324. /**
  31325. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31326. * Supports definition of mesh facing forward or backward
  31327. * @param flipBack defines the flip
  31328. * @param twirlClockwise defines the twirl
  31329. * @param tiltRight defines the tilt
  31330. * @returns the current mesh
  31331. */
  31332. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31333. /**
  31334. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31335. * Supports definition of mesh facing forward or backward.
  31336. * @param flipBack defines the flip
  31337. * @param twirlClockwise defines the twirl
  31338. * @param tiltRight defines the tilt
  31339. * @returns the new rotation vector
  31340. */
  31341. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31342. /**
  31343. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31344. * This means the mesh underlying bounding box and sphere are recomputed.
  31345. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31346. * @returns the current mesh
  31347. */
  31348. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31349. /** @hidden */
  31350. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31351. /** @hidden */
  31352. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31353. /** @hidden */
  31354. _updateBoundingInfo(): AbstractMesh;
  31355. /** @hidden */
  31356. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31357. /** @hidden */
  31358. protected _afterComputeWorldMatrix(): void;
  31359. /** @hidden */
  31360. get _effectiveMesh(): AbstractMesh;
  31361. /**
  31362. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31363. * A mesh is in the frustum if its bounding box intersects the frustum
  31364. * @param frustumPlanes defines the frustum to test
  31365. * @returns true if the mesh is in the frustum planes
  31366. */
  31367. isInFrustum(frustumPlanes: Plane[]): boolean;
  31368. /**
  31369. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31370. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31371. * @param frustumPlanes defines the frustum to test
  31372. * @returns true if the mesh is completely in the frustum planes
  31373. */
  31374. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31375. /**
  31376. * True if the mesh intersects another mesh or a SolidParticle object
  31377. * @param mesh defines a target mesh or SolidParticle to test
  31378. * @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)
  31379. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31380. * @returns true if there is an intersection
  31381. */
  31382. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31383. /**
  31384. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31385. * @param point defines the point to test
  31386. * @returns true if there is an intersection
  31387. */
  31388. intersectsPoint(point: Vector3): boolean;
  31389. /**
  31390. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31391. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31392. */
  31393. get checkCollisions(): boolean;
  31394. set checkCollisions(collisionEnabled: boolean);
  31395. /**
  31396. * Gets Collider object used to compute collisions (not physics)
  31397. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31398. */
  31399. get collider(): Nullable<Collider>;
  31400. /**
  31401. * Move the mesh using collision engine
  31402. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31403. * @param displacement defines the requested displacement vector
  31404. * @returns the current mesh
  31405. */
  31406. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31407. private _onCollisionPositionChange;
  31408. /** @hidden */
  31409. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31410. /** @hidden */
  31411. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31412. /** @hidden */
  31413. _checkCollision(collider: Collider): AbstractMesh;
  31414. /** @hidden */
  31415. _generatePointsArray(): boolean;
  31416. /**
  31417. * Checks if the passed Ray intersects with the mesh
  31418. * @param ray defines the ray to use
  31419. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31420. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31421. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31422. * @returns the picking info
  31423. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31424. */
  31425. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31426. /**
  31427. * Clones the current mesh
  31428. * @param name defines the mesh name
  31429. * @param newParent defines the new mesh parent
  31430. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31431. * @returns the new mesh
  31432. */
  31433. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31434. /**
  31435. * Disposes all the submeshes of the current meshnp
  31436. * @returns the current mesh
  31437. */
  31438. releaseSubMeshes(): AbstractMesh;
  31439. /**
  31440. * Releases resources associated with this abstract mesh.
  31441. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31442. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31443. */
  31444. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31445. /**
  31446. * Adds the passed mesh as a child to the current mesh
  31447. * @param mesh defines the child mesh
  31448. * @returns the current mesh
  31449. */
  31450. addChild(mesh: AbstractMesh): AbstractMesh;
  31451. /**
  31452. * Removes the passed mesh from the current mesh children list
  31453. * @param mesh defines the child mesh
  31454. * @returns the current mesh
  31455. */
  31456. removeChild(mesh: AbstractMesh): AbstractMesh;
  31457. /** @hidden */
  31458. private _initFacetData;
  31459. /**
  31460. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31461. * This method can be called within the render loop.
  31462. * 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
  31463. * @returns the current mesh
  31464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31465. */
  31466. updateFacetData(): AbstractMesh;
  31467. /**
  31468. * Returns the facetLocalNormals array.
  31469. * The normals are expressed in the mesh local spac
  31470. * @returns an array of Vector3
  31471. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31472. */
  31473. getFacetLocalNormals(): Vector3[];
  31474. /**
  31475. * Returns the facetLocalPositions array.
  31476. * The facet positions are expressed in the mesh local space
  31477. * @returns an array of Vector3
  31478. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31479. */
  31480. getFacetLocalPositions(): Vector3[];
  31481. /**
  31482. * Returns the facetLocalPartioning array
  31483. * @returns an array of array of numbers
  31484. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31485. */
  31486. getFacetLocalPartitioning(): number[][];
  31487. /**
  31488. * Returns the i-th facet position in the world system.
  31489. * This method allocates a new Vector3 per call
  31490. * @param i defines the facet index
  31491. * @returns a new Vector3
  31492. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31493. */
  31494. getFacetPosition(i: number): Vector3;
  31495. /**
  31496. * Sets the reference Vector3 with the i-th facet position in the world system
  31497. * @param i defines the facet index
  31498. * @param ref defines the target vector
  31499. * @returns the current mesh
  31500. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31501. */
  31502. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31503. /**
  31504. * Returns the i-th facet normal in the world system.
  31505. * This method allocates a new Vector3 per call
  31506. * @param i defines the facet index
  31507. * @returns a new Vector3
  31508. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31509. */
  31510. getFacetNormal(i: number): Vector3;
  31511. /**
  31512. * Sets the reference Vector3 with the i-th facet normal in the world system
  31513. * @param i defines the facet index
  31514. * @param ref defines the target vector
  31515. * @returns the current mesh
  31516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31517. */
  31518. getFacetNormalToRef(i: number, ref: Vector3): this;
  31519. /**
  31520. * 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)
  31521. * @param x defines x coordinate
  31522. * @param y defines y coordinate
  31523. * @param z defines z coordinate
  31524. * @returns the array of facet indexes
  31525. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31526. */
  31527. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31528. /**
  31529. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31530. * @param projected sets as the (x,y,z) world projection on the facet
  31531. * @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
  31532. * @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
  31533. * @param x defines x coordinate
  31534. * @param y defines y coordinate
  31535. * @param z defines z coordinate
  31536. * @returns the face index if found (or null instead)
  31537. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31538. */
  31539. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31540. /**
  31541. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31542. * @param projected sets as the (x,y,z) local projection on the facet
  31543. * @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
  31544. * @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
  31545. * @param x defines x coordinate
  31546. * @param y defines y coordinate
  31547. * @param z defines z coordinate
  31548. * @returns the face index if found (or null instead)
  31549. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31550. */
  31551. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31552. /**
  31553. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31554. * @returns the parameters
  31555. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31556. */
  31557. getFacetDataParameters(): any;
  31558. /**
  31559. * Disables the feature FacetData and frees the related memory
  31560. * @returns the current mesh
  31561. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31562. */
  31563. disableFacetData(): AbstractMesh;
  31564. /**
  31565. * Updates the AbstractMesh indices array
  31566. * @param indices defines the data source
  31567. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31568. * @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)
  31569. * @returns the current mesh
  31570. */
  31571. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31572. /**
  31573. * Creates new normals data for the mesh
  31574. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31575. * @returns the current mesh
  31576. */
  31577. createNormals(updatable: boolean): AbstractMesh;
  31578. /**
  31579. * Align the mesh with a normal
  31580. * @param normal defines the normal to use
  31581. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31582. * @returns the current mesh
  31583. */
  31584. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31585. /** @hidden */
  31586. _checkOcclusionQuery(): boolean;
  31587. /**
  31588. * Disables the mesh edge rendering mode
  31589. * @returns the currentAbstractMesh
  31590. */
  31591. disableEdgesRendering(): AbstractMesh;
  31592. /**
  31593. * Enables the edge rendering mode on the mesh.
  31594. * This mode makes the mesh edges visible
  31595. * @param epsilon defines the maximal distance between two angles to detect a face
  31596. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31597. * @returns the currentAbstractMesh
  31598. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31599. */
  31600. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31601. }
  31602. }
  31603. declare module BABYLON {
  31604. /**
  31605. * Interface used to define ActionEvent
  31606. */
  31607. export interface IActionEvent {
  31608. /** The mesh or sprite that triggered the action */
  31609. source: any;
  31610. /** The X mouse cursor position at the time of the event */
  31611. pointerX: number;
  31612. /** The Y mouse cursor position at the time of the event */
  31613. pointerY: number;
  31614. /** The mesh that is currently pointed at (can be null) */
  31615. meshUnderPointer: Nullable<AbstractMesh>;
  31616. /** the original (browser) event that triggered the ActionEvent */
  31617. sourceEvent?: any;
  31618. /** additional data for the event */
  31619. additionalData?: any;
  31620. }
  31621. /**
  31622. * ActionEvent is the event being sent when an action is triggered.
  31623. */
  31624. export class ActionEvent implements IActionEvent {
  31625. /** The mesh or sprite that triggered the action */
  31626. source: any;
  31627. /** The X mouse cursor position at the time of the event */
  31628. pointerX: number;
  31629. /** The Y mouse cursor position at the time of the event */
  31630. pointerY: number;
  31631. /** The mesh that is currently pointed at (can be null) */
  31632. meshUnderPointer: Nullable<AbstractMesh>;
  31633. /** the original (browser) event that triggered the ActionEvent */
  31634. sourceEvent?: any;
  31635. /** additional data for the event */
  31636. additionalData?: any;
  31637. /**
  31638. * Creates a new ActionEvent
  31639. * @param source The mesh or sprite that triggered the action
  31640. * @param pointerX The X mouse cursor position at the time of the event
  31641. * @param pointerY The Y mouse cursor position at the time of the event
  31642. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31643. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31644. * @param additionalData additional data for the event
  31645. */
  31646. constructor(
  31647. /** The mesh or sprite that triggered the action */
  31648. source: any,
  31649. /** The X mouse cursor position at the time of the event */
  31650. pointerX: number,
  31651. /** The Y mouse cursor position at the time of the event */
  31652. pointerY: number,
  31653. /** The mesh that is currently pointed at (can be null) */
  31654. meshUnderPointer: Nullable<AbstractMesh>,
  31655. /** the original (browser) event that triggered the ActionEvent */
  31656. sourceEvent?: any,
  31657. /** additional data for the event */
  31658. additionalData?: any);
  31659. /**
  31660. * Helper function to auto-create an ActionEvent from a source mesh.
  31661. * @param source The source mesh that triggered the event
  31662. * @param evt The original (browser) event
  31663. * @param additionalData additional data for the event
  31664. * @returns the new ActionEvent
  31665. */
  31666. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31667. /**
  31668. * Helper function to auto-create an ActionEvent from a source sprite
  31669. * @param source The source sprite that triggered the event
  31670. * @param scene Scene associated with the sprite
  31671. * @param evt The original (browser) event
  31672. * @param additionalData additional data for the event
  31673. * @returns the new ActionEvent
  31674. */
  31675. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31676. /**
  31677. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31678. * @param scene the scene where the event occurred
  31679. * @param evt The original (browser) event
  31680. * @returns the new ActionEvent
  31681. */
  31682. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31683. /**
  31684. * Helper function to auto-create an ActionEvent from a primitive
  31685. * @param prim defines the target primitive
  31686. * @param pointerPos defines the pointer position
  31687. * @param evt The original (browser) event
  31688. * @param additionalData additional data for the event
  31689. * @returns the new ActionEvent
  31690. */
  31691. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31692. }
  31693. }
  31694. declare module BABYLON {
  31695. /**
  31696. * Abstract class used to decouple action Manager from scene and meshes.
  31697. * Do not instantiate.
  31698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31699. */
  31700. export abstract class AbstractActionManager implements IDisposable {
  31701. /** Gets the list of active triggers */
  31702. static Triggers: {
  31703. [key: string]: number;
  31704. };
  31705. /** Gets the cursor to use when hovering items */
  31706. hoverCursor: string;
  31707. /** Gets the list of actions */
  31708. actions: IAction[];
  31709. /**
  31710. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31711. */
  31712. isRecursive: boolean;
  31713. /**
  31714. * Releases all associated resources
  31715. */
  31716. abstract dispose(): void;
  31717. /**
  31718. * Does this action manager has pointer triggers
  31719. */
  31720. abstract get hasPointerTriggers(): boolean;
  31721. /**
  31722. * Does this action manager has pick triggers
  31723. */
  31724. abstract get hasPickTriggers(): boolean;
  31725. /**
  31726. * Process a specific trigger
  31727. * @param trigger defines the trigger to process
  31728. * @param evt defines the event details to be processed
  31729. */
  31730. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31731. /**
  31732. * Does this action manager handles actions of any of the given triggers
  31733. * @param triggers defines the triggers to be tested
  31734. * @return a boolean indicating whether one (or more) of the triggers is handled
  31735. */
  31736. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31737. /**
  31738. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31739. * speed.
  31740. * @param triggerA defines the trigger to be tested
  31741. * @param triggerB defines the trigger to be tested
  31742. * @return a boolean indicating whether one (or more) of the triggers is handled
  31743. */
  31744. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31745. /**
  31746. * Does this action manager handles actions of a given trigger
  31747. * @param trigger defines the trigger to be tested
  31748. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31749. * @return whether the trigger is handled
  31750. */
  31751. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31752. /**
  31753. * Serialize this manager to a JSON object
  31754. * @param name defines the property name to store this manager
  31755. * @returns a JSON representation of this manager
  31756. */
  31757. abstract serialize(name: string): any;
  31758. /**
  31759. * Registers an action to this action manager
  31760. * @param action defines the action to be registered
  31761. * @return the action amended (prepared) after registration
  31762. */
  31763. abstract registerAction(action: IAction): Nullable<IAction>;
  31764. /**
  31765. * Unregisters an action to this action manager
  31766. * @param action defines the action to be unregistered
  31767. * @return a boolean indicating whether the action has been unregistered
  31768. */
  31769. abstract unregisterAction(action: IAction): Boolean;
  31770. /**
  31771. * Does exist one action manager with at least one trigger
  31772. **/
  31773. static get HasTriggers(): boolean;
  31774. /**
  31775. * Does exist one action manager with at least one pick trigger
  31776. **/
  31777. static get HasPickTriggers(): boolean;
  31778. /**
  31779. * Does exist one action manager that handles actions of a given trigger
  31780. * @param trigger defines the trigger to be tested
  31781. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31782. **/
  31783. static HasSpecificTrigger(trigger: number): boolean;
  31784. }
  31785. }
  31786. declare module BABYLON {
  31787. /**
  31788. * Defines how a node can be built from a string name.
  31789. */
  31790. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31791. /**
  31792. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31793. */
  31794. export class Node implements IBehaviorAware<Node> {
  31795. /** @hidden */
  31796. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31797. private static _NodeConstructors;
  31798. /**
  31799. * Add a new node constructor
  31800. * @param type defines the type name of the node to construct
  31801. * @param constructorFunc defines the constructor function
  31802. */
  31803. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31804. /**
  31805. * Returns a node constructor based on type name
  31806. * @param type defines the type name
  31807. * @param name defines the new node name
  31808. * @param scene defines the hosting scene
  31809. * @param options defines optional options to transmit to constructors
  31810. * @returns the new constructor or null
  31811. */
  31812. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31813. /**
  31814. * Gets or sets the name of the node
  31815. */
  31816. name: string;
  31817. /**
  31818. * Gets or sets the id of the node
  31819. */
  31820. id: string;
  31821. /**
  31822. * Gets or sets the unique id of the node
  31823. */
  31824. uniqueId: number;
  31825. /**
  31826. * Gets or sets a string used to store user defined state for the node
  31827. */
  31828. state: string;
  31829. /**
  31830. * Gets or sets an object used to store user defined information for the node
  31831. */
  31832. metadata: any;
  31833. /**
  31834. * For internal use only. Please do not use.
  31835. */
  31836. reservedDataStore: any;
  31837. /**
  31838. * List of inspectable custom properties (used by the Inspector)
  31839. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31840. */
  31841. inspectableCustomProperties: IInspectable[];
  31842. private _doNotSerialize;
  31843. /**
  31844. * Gets or sets a boolean used to define if the node must be serialized
  31845. */
  31846. get doNotSerialize(): boolean;
  31847. set doNotSerialize(value: boolean);
  31848. /** @hidden */
  31849. _isDisposed: boolean;
  31850. /**
  31851. * Gets a list of Animations associated with the node
  31852. */
  31853. animations: Animation[];
  31854. protected _ranges: {
  31855. [name: string]: Nullable<AnimationRange>;
  31856. };
  31857. /**
  31858. * Callback raised when the node is ready to be used
  31859. */
  31860. onReady: Nullable<(node: Node) => void>;
  31861. private _isEnabled;
  31862. private _isParentEnabled;
  31863. private _isReady;
  31864. /** @hidden */
  31865. _currentRenderId: number;
  31866. private _parentUpdateId;
  31867. /** @hidden */
  31868. _childUpdateId: number;
  31869. /** @hidden */
  31870. _waitingParentId: Nullable<string>;
  31871. /** @hidden */
  31872. _scene: Scene;
  31873. /** @hidden */
  31874. _cache: any;
  31875. private _parentNode;
  31876. private _children;
  31877. /** @hidden */
  31878. _worldMatrix: Matrix;
  31879. /** @hidden */
  31880. _worldMatrixDeterminant: number;
  31881. /** @hidden */
  31882. _worldMatrixDeterminantIsDirty: boolean;
  31883. /** @hidden */
  31884. private _sceneRootNodesIndex;
  31885. /**
  31886. * Gets a boolean indicating if the node has been disposed
  31887. * @returns true if the node was disposed
  31888. */
  31889. isDisposed(): boolean;
  31890. /**
  31891. * Gets or sets the parent of the node (without keeping the current position in the scene)
  31892. * @see https://doc.babylonjs.com/how_to/parenting
  31893. */
  31894. set parent(parent: Nullable<Node>);
  31895. get parent(): Nullable<Node>;
  31896. /** @hidden */
  31897. _addToSceneRootNodes(): void;
  31898. /** @hidden */
  31899. _removeFromSceneRootNodes(): void;
  31900. private _animationPropertiesOverride;
  31901. /**
  31902. * Gets or sets the animation properties override
  31903. */
  31904. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31905. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31906. /**
  31907. * Gets a string idenfifying the name of the class
  31908. * @returns "Node" string
  31909. */
  31910. getClassName(): string;
  31911. /** @hidden */
  31912. readonly _isNode: boolean;
  31913. /**
  31914. * An event triggered when the mesh is disposed
  31915. */
  31916. onDisposeObservable: Observable<Node>;
  31917. private _onDisposeObserver;
  31918. /**
  31919. * Sets a callback that will be raised when the node will be disposed
  31920. */
  31921. set onDispose(callback: () => void);
  31922. /**
  31923. * Creates a new Node
  31924. * @param name the name and id to be given to this node
  31925. * @param scene the scene this node will be added to
  31926. */
  31927. constructor(name: string, scene?: Nullable<Scene>);
  31928. /**
  31929. * Gets the scene of the node
  31930. * @returns a scene
  31931. */
  31932. getScene(): Scene;
  31933. /**
  31934. * Gets the engine of the node
  31935. * @returns a Engine
  31936. */
  31937. getEngine(): Engine;
  31938. private _behaviors;
  31939. /**
  31940. * Attach a behavior to the node
  31941. * @see http://doc.babylonjs.com/features/behaviour
  31942. * @param behavior defines the behavior to attach
  31943. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  31944. * @returns the current Node
  31945. */
  31946. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  31947. /**
  31948. * Remove an attached behavior
  31949. * @see http://doc.babylonjs.com/features/behaviour
  31950. * @param behavior defines the behavior to attach
  31951. * @returns the current Node
  31952. */
  31953. removeBehavior(behavior: Behavior<Node>): Node;
  31954. /**
  31955. * Gets the list of attached behaviors
  31956. * @see http://doc.babylonjs.com/features/behaviour
  31957. */
  31958. get behaviors(): Behavior<Node>[];
  31959. /**
  31960. * Gets an attached behavior by name
  31961. * @param name defines the name of the behavior to look for
  31962. * @see http://doc.babylonjs.com/features/behaviour
  31963. * @returns null if behavior was not found else the requested behavior
  31964. */
  31965. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  31966. /**
  31967. * Returns the latest update of the World matrix
  31968. * @returns a Matrix
  31969. */
  31970. getWorldMatrix(): Matrix;
  31971. /** @hidden */
  31972. _getWorldMatrixDeterminant(): number;
  31973. /**
  31974. * Returns directly the latest state of the mesh World matrix.
  31975. * A Matrix is returned.
  31976. */
  31977. get worldMatrixFromCache(): Matrix;
  31978. /** @hidden */
  31979. _initCache(): void;
  31980. /** @hidden */
  31981. updateCache(force?: boolean): void;
  31982. /** @hidden */
  31983. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31984. /** @hidden */
  31985. _updateCache(ignoreParentClass?: boolean): void;
  31986. /** @hidden */
  31987. _isSynchronized(): boolean;
  31988. /** @hidden */
  31989. _markSyncedWithParent(): void;
  31990. /** @hidden */
  31991. isSynchronizedWithParent(): boolean;
  31992. /** @hidden */
  31993. isSynchronized(): boolean;
  31994. /**
  31995. * Is this node ready to be used/rendered
  31996. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  31997. * @return true if the node is ready
  31998. */
  31999. isReady(completeCheck?: boolean): boolean;
  32000. /**
  32001. * Is this node enabled?
  32002. * 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
  32003. * @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
  32004. * @return whether this node (and its parent) is enabled
  32005. */
  32006. isEnabled(checkAncestors?: boolean): boolean;
  32007. /** @hidden */
  32008. protected _syncParentEnabledState(): void;
  32009. /**
  32010. * Set the enabled state of this node
  32011. * @param value defines the new enabled state
  32012. */
  32013. setEnabled(value: boolean): void;
  32014. /**
  32015. * Is this node a descendant of the given node?
  32016. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32017. * @param ancestor defines the parent node to inspect
  32018. * @returns a boolean indicating if this node is a descendant of the given node
  32019. */
  32020. isDescendantOf(ancestor: Node): boolean;
  32021. /** @hidden */
  32022. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32023. /**
  32024. * Will return all nodes that have this node as ascendant
  32025. * @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
  32026. * @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
  32027. * @return all children nodes of all types
  32028. */
  32029. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32030. /**
  32031. * Get all child-meshes of this node
  32032. * @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)
  32033. * @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
  32034. * @returns an array of AbstractMesh
  32035. */
  32036. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32037. /**
  32038. * Get all direct children of this node
  32039. * @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
  32040. * @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)
  32041. * @returns an array of Node
  32042. */
  32043. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32044. /** @hidden */
  32045. _setReady(state: boolean): void;
  32046. /**
  32047. * Get an animation by name
  32048. * @param name defines the name of the animation to look for
  32049. * @returns null if not found else the requested animation
  32050. */
  32051. getAnimationByName(name: string): Nullable<Animation>;
  32052. /**
  32053. * Creates an animation range for this node
  32054. * @param name defines the name of the range
  32055. * @param from defines the starting key
  32056. * @param to defines the end key
  32057. */
  32058. createAnimationRange(name: string, from: number, to: number): void;
  32059. /**
  32060. * Delete a specific animation range
  32061. * @param name defines the name of the range to delete
  32062. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32063. */
  32064. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32065. /**
  32066. * Get an animation range by name
  32067. * @param name defines the name of the animation range to look for
  32068. * @returns null if not found else the requested animation range
  32069. */
  32070. getAnimationRange(name: string): Nullable<AnimationRange>;
  32071. /**
  32072. * Gets the list of all animation ranges defined on this node
  32073. * @returns an array
  32074. */
  32075. getAnimationRanges(): Nullable<AnimationRange>[];
  32076. /**
  32077. * Will start the animation sequence
  32078. * @param name defines the range frames for animation sequence
  32079. * @param loop defines if the animation should loop (false by default)
  32080. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32081. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32082. * @returns the object created for this animation. If range does not exist, it will return null
  32083. */
  32084. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32085. /**
  32086. * Serialize animation ranges into a JSON compatible object
  32087. * @returns serialization object
  32088. */
  32089. serializeAnimationRanges(): any;
  32090. /**
  32091. * Computes the world matrix of the node
  32092. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32093. * @returns the world matrix
  32094. */
  32095. computeWorldMatrix(force?: boolean): Matrix;
  32096. /**
  32097. * Releases resources associated with this node.
  32098. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32099. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32100. */
  32101. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32102. /**
  32103. * Parse animation range data from a serialization object and store them into a given node
  32104. * @param node defines where to store the animation ranges
  32105. * @param parsedNode defines the serialization object to read data from
  32106. * @param scene defines the hosting scene
  32107. */
  32108. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32109. /**
  32110. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32111. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32112. * @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
  32113. * @returns the new bounding vectors
  32114. */
  32115. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32116. min: Vector3;
  32117. max: Vector3;
  32118. };
  32119. }
  32120. }
  32121. declare module BABYLON {
  32122. /**
  32123. * @hidden
  32124. */
  32125. export class _IAnimationState {
  32126. key: number;
  32127. repeatCount: number;
  32128. workValue?: any;
  32129. loopMode?: number;
  32130. offsetValue?: any;
  32131. highLimitValue?: any;
  32132. }
  32133. /**
  32134. * Class used to store any kind of animation
  32135. */
  32136. export class Animation {
  32137. /**Name of the animation */
  32138. name: string;
  32139. /**Property to animate */
  32140. targetProperty: string;
  32141. /**The frames per second of the animation */
  32142. framePerSecond: number;
  32143. /**The data type of the animation */
  32144. dataType: number;
  32145. /**The loop mode of the animation */
  32146. loopMode?: number | undefined;
  32147. /**Specifies if blending should be enabled */
  32148. enableBlending?: boolean | undefined;
  32149. /**
  32150. * Use matrix interpolation instead of using direct key value when animating matrices
  32151. */
  32152. static AllowMatricesInterpolation: boolean;
  32153. /**
  32154. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32155. */
  32156. static AllowMatrixDecomposeForInterpolation: boolean;
  32157. /**
  32158. * Stores the key frames of the animation
  32159. */
  32160. private _keys;
  32161. /**
  32162. * Stores the easing function of the animation
  32163. */
  32164. private _easingFunction;
  32165. /**
  32166. * @hidden Internal use only
  32167. */
  32168. _runtimeAnimations: RuntimeAnimation[];
  32169. /**
  32170. * The set of event that will be linked to this animation
  32171. */
  32172. private _events;
  32173. /**
  32174. * Stores an array of target property paths
  32175. */
  32176. targetPropertyPath: string[];
  32177. /**
  32178. * Stores the blending speed of the animation
  32179. */
  32180. blendingSpeed: number;
  32181. /**
  32182. * Stores the animation ranges for the animation
  32183. */
  32184. private _ranges;
  32185. /**
  32186. * @hidden Internal use
  32187. */
  32188. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32189. /**
  32190. * Sets up an animation
  32191. * @param property The property to animate
  32192. * @param animationType The animation type to apply
  32193. * @param framePerSecond The frames per second of the animation
  32194. * @param easingFunction The easing function used in the animation
  32195. * @returns The created animation
  32196. */
  32197. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32198. /**
  32199. * Create and start an animation on a node
  32200. * @param name defines the name of the global animation that will be run on all nodes
  32201. * @param node defines the root node where the animation will take place
  32202. * @param targetProperty defines property to animate
  32203. * @param framePerSecond defines the number of frame per second yo use
  32204. * @param totalFrame defines the number of frames in total
  32205. * @param from defines the initial value
  32206. * @param to defines the final value
  32207. * @param loopMode defines which loop mode you want to use (off by default)
  32208. * @param easingFunction defines the easing function to use (linear by default)
  32209. * @param onAnimationEnd defines the callback to call when animation end
  32210. * @returns the animatable created for this animation
  32211. */
  32212. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32213. /**
  32214. * Create and start an animation on a node and its descendants
  32215. * @param name defines the name of the global animation that will be run on all nodes
  32216. * @param node defines the root node where the animation will take place
  32217. * @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
  32218. * @param targetProperty defines property to animate
  32219. * @param framePerSecond defines the number of frame per second to use
  32220. * @param totalFrame defines the number of frames in total
  32221. * @param from defines the initial value
  32222. * @param to defines the final value
  32223. * @param loopMode defines which loop mode you want to use (off by default)
  32224. * @param easingFunction defines the easing function to use (linear by default)
  32225. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32226. * @returns the list of animatables created for all nodes
  32227. * @example https://www.babylonjs-playground.com/#MH0VLI
  32228. */
  32229. 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[]>;
  32230. /**
  32231. * Creates a new animation, merges it with the existing animations and starts it
  32232. * @param name Name of the animation
  32233. * @param node Node which contains the scene that begins the animations
  32234. * @param targetProperty Specifies which property to animate
  32235. * @param framePerSecond The frames per second of the animation
  32236. * @param totalFrame The total number of frames
  32237. * @param from The frame at the beginning of the animation
  32238. * @param to The frame at the end of the animation
  32239. * @param loopMode Specifies the loop mode of the animation
  32240. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32241. * @param onAnimationEnd Callback to run once the animation is complete
  32242. * @returns Nullable animation
  32243. */
  32244. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32245. /**
  32246. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32247. * @param sourceAnimation defines the Animation containing keyframes to convert
  32248. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32249. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32250. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32251. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32252. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32253. */
  32254. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32255. /**
  32256. * Transition property of an host to the target Value
  32257. * @param property The property to transition
  32258. * @param targetValue The target Value of the property
  32259. * @param host The object where the property to animate belongs
  32260. * @param scene Scene used to run the animation
  32261. * @param frameRate Framerate (in frame/s) to use
  32262. * @param transition The transition type we want to use
  32263. * @param duration The duration of the animation, in milliseconds
  32264. * @param onAnimationEnd Callback trigger at the end of the animation
  32265. * @returns Nullable animation
  32266. */
  32267. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32268. /**
  32269. * Return the array of runtime animations currently using this animation
  32270. */
  32271. get runtimeAnimations(): RuntimeAnimation[];
  32272. /**
  32273. * Specifies if any of the runtime animations are currently running
  32274. */
  32275. get hasRunningRuntimeAnimations(): boolean;
  32276. /**
  32277. * Initializes the animation
  32278. * @param name Name of the animation
  32279. * @param targetProperty Property to animate
  32280. * @param framePerSecond The frames per second of the animation
  32281. * @param dataType The data type of the animation
  32282. * @param loopMode The loop mode of the animation
  32283. * @param enableBlending Specifies if blending should be enabled
  32284. */
  32285. constructor(
  32286. /**Name of the animation */
  32287. name: string,
  32288. /**Property to animate */
  32289. targetProperty: string,
  32290. /**The frames per second of the animation */
  32291. framePerSecond: number,
  32292. /**The data type of the animation */
  32293. dataType: number,
  32294. /**The loop mode of the animation */
  32295. loopMode?: number | undefined,
  32296. /**Specifies if blending should be enabled */
  32297. enableBlending?: boolean | undefined);
  32298. /**
  32299. * Converts the animation to a string
  32300. * @param fullDetails support for multiple levels of logging within scene loading
  32301. * @returns String form of the animation
  32302. */
  32303. toString(fullDetails?: boolean): string;
  32304. /**
  32305. * Add an event to this animation
  32306. * @param event Event to add
  32307. */
  32308. addEvent(event: AnimationEvent): void;
  32309. /**
  32310. * Remove all events found at the given frame
  32311. * @param frame The frame to remove events from
  32312. */
  32313. removeEvents(frame: number): void;
  32314. /**
  32315. * Retrieves all the events from the animation
  32316. * @returns Events from the animation
  32317. */
  32318. getEvents(): AnimationEvent[];
  32319. /**
  32320. * Creates an animation range
  32321. * @param name Name of the animation range
  32322. * @param from Starting frame of the animation range
  32323. * @param to Ending frame of the animation
  32324. */
  32325. createRange(name: string, from: number, to: number): void;
  32326. /**
  32327. * Deletes an animation range by name
  32328. * @param name Name of the animation range to delete
  32329. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32330. */
  32331. deleteRange(name: string, deleteFrames?: boolean): void;
  32332. /**
  32333. * Gets the animation range by name, or null if not defined
  32334. * @param name Name of the animation range
  32335. * @returns Nullable animation range
  32336. */
  32337. getRange(name: string): Nullable<AnimationRange>;
  32338. /**
  32339. * Gets the key frames from the animation
  32340. * @returns The key frames of the animation
  32341. */
  32342. getKeys(): Array<IAnimationKey>;
  32343. /**
  32344. * Gets the highest frame rate of the animation
  32345. * @returns Highest frame rate of the animation
  32346. */
  32347. getHighestFrame(): number;
  32348. /**
  32349. * Gets the easing function of the animation
  32350. * @returns Easing function of the animation
  32351. */
  32352. getEasingFunction(): IEasingFunction;
  32353. /**
  32354. * Sets the easing function of the animation
  32355. * @param easingFunction A custom mathematical formula for animation
  32356. */
  32357. setEasingFunction(easingFunction: EasingFunction): void;
  32358. /**
  32359. * Interpolates a scalar linearly
  32360. * @param startValue Start value of the animation curve
  32361. * @param endValue End value of the animation curve
  32362. * @param gradient Scalar amount to interpolate
  32363. * @returns Interpolated scalar value
  32364. */
  32365. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32366. /**
  32367. * Interpolates a scalar cubically
  32368. * @param startValue Start value of the animation curve
  32369. * @param outTangent End tangent of the animation
  32370. * @param endValue End value of the animation curve
  32371. * @param inTangent Start tangent of the animation curve
  32372. * @param gradient Scalar amount to interpolate
  32373. * @returns Interpolated scalar value
  32374. */
  32375. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32376. /**
  32377. * Interpolates a quaternion using a spherical linear interpolation
  32378. * @param startValue Start value of the animation curve
  32379. * @param endValue End value of the animation curve
  32380. * @param gradient Scalar amount to interpolate
  32381. * @returns Interpolated quaternion value
  32382. */
  32383. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32384. /**
  32385. * Interpolates a quaternion cubically
  32386. * @param startValue Start value of the animation curve
  32387. * @param outTangent End tangent of the animation curve
  32388. * @param endValue End value of the animation curve
  32389. * @param inTangent Start tangent of the animation curve
  32390. * @param gradient Scalar amount to interpolate
  32391. * @returns Interpolated quaternion value
  32392. */
  32393. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32394. /**
  32395. * Interpolates a Vector3 linearl
  32396. * @param startValue Start value of the animation curve
  32397. * @param endValue End value of the animation curve
  32398. * @param gradient Scalar amount to interpolate
  32399. * @returns Interpolated scalar value
  32400. */
  32401. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32402. /**
  32403. * Interpolates a Vector3 cubically
  32404. * @param startValue Start value of the animation curve
  32405. * @param outTangent End tangent of the animation
  32406. * @param endValue End value of the animation curve
  32407. * @param inTangent Start tangent of the animation curve
  32408. * @param gradient Scalar amount to interpolate
  32409. * @returns InterpolatedVector3 value
  32410. */
  32411. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32412. /**
  32413. * Interpolates a Vector2 linearly
  32414. * @param startValue Start value of the animation curve
  32415. * @param endValue End value of the animation curve
  32416. * @param gradient Scalar amount to interpolate
  32417. * @returns Interpolated Vector2 value
  32418. */
  32419. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32420. /**
  32421. * Interpolates a Vector2 cubically
  32422. * @param startValue Start value of the animation curve
  32423. * @param outTangent End tangent of the animation
  32424. * @param endValue End value of the animation curve
  32425. * @param inTangent Start tangent of the animation curve
  32426. * @param gradient Scalar amount to interpolate
  32427. * @returns Interpolated Vector2 value
  32428. */
  32429. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32430. /**
  32431. * Interpolates a size linearly
  32432. * @param startValue Start value of the animation curve
  32433. * @param endValue End value of the animation curve
  32434. * @param gradient Scalar amount to interpolate
  32435. * @returns Interpolated Size value
  32436. */
  32437. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32438. /**
  32439. * Interpolates a Color3 linearly
  32440. * @param startValue Start value of the animation curve
  32441. * @param endValue End value of the animation curve
  32442. * @param gradient Scalar amount to interpolate
  32443. * @returns Interpolated Color3 value
  32444. */
  32445. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32446. /**
  32447. * Interpolates a Color4 linearly
  32448. * @param startValue Start value of the animation curve
  32449. * @param endValue End value of the animation curve
  32450. * @param gradient Scalar amount to interpolate
  32451. * @returns Interpolated Color3 value
  32452. */
  32453. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32454. /**
  32455. * @hidden Internal use only
  32456. */
  32457. _getKeyValue(value: any): any;
  32458. /**
  32459. * @hidden Internal use only
  32460. */
  32461. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32462. /**
  32463. * Defines the function to use to interpolate matrices
  32464. * @param startValue defines the start matrix
  32465. * @param endValue defines the end matrix
  32466. * @param gradient defines the gradient between both matrices
  32467. * @param result defines an optional target matrix where to store the interpolation
  32468. * @returns the interpolated matrix
  32469. */
  32470. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32471. /**
  32472. * Makes a copy of the animation
  32473. * @returns Cloned animation
  32474. */
  32475. clone(): Animation;
  32476. /**
  32477. * Sets the key frames of the animation
  32478. * @param values The animation key frames to set
  32479. */
  32480. setKeys(values: Array<IAnimationKey>): void;
  32481. /**
  32482. * Serializes the animation to an object
  32483. * @returns Serialized object
  32484. */
  32485. serialize(): any;
  32486. /**
  32487. * Float animation type
  32488. */
  32489. static readonly ANIMATIONTYPE_FLOAT: number;
  32490. /**
  32491. * Vector3 animation type
  32492. */
  32493. static readonly ANIMATIONTYPE_VECTOR3: number;
  32494. /**
  32495. * Quaternion animation type
  32496. */
  32497. static readonly ANIMATIONTYPE_QUATERNION: number;
  32498. /**
  32499. * Matrix animation type
  32500. */
  32501. static readonly ANIMATIONTYPE_MATRIX: number;
  32502. /**
  32503. * Color3 animation type
  32504. */
  32505. static readonly ANIMATIONTYPE_COLOR3: number;
  32506. /**
  32507. * Color3 animation type
  32508. */
  32509. static readonly ANIMATIONTYPE_COLOR4: number;
  32510. /**
  32511. * Vector2 animation type
  32512. */
  32513. static readonly ANIMATIONTYPE_VECTOR2: number;
  32514. /**
  32515. * Size animation type
  32516. */
  32517. static readonly ANIMATIONTYPE_SIZE: number;
  32518. /**
  32519. * Relative Loop Mode
  32520. */
  32521. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32522. /**
  32523. * Cycle Loop Mode
  32524. */
  32525. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32526. /**
  32527. * Constant Loop Mode
  32528. */
  32529. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32530. /** @hidden */
  32531. static _UniversalLerp(left: any, right: any, amount: number): any;
  32532. /**
  32533. * Parses an animation object and creates an animation
  32534. * @param parsedAnimation Parsed animation object
  32535. * @returns Animation object
  32536. */
  32537. static Parse(parsedAnimation: any): Animation;
  32538. /**
  32539. * Appends the serialized animations from the source animations
  32540. * @param source Source containing the animations
  32541. * @param destination Target to store the animations
  32542. */
  32543. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32544. }
  32545. }
  32546. declare module BABYLON {
  32547. /**
  32548. * Interface containing an array of animations
  32549. */
  32550. export interface IAnimatable {
  32551. /**
  32552. * Array of animations
  32553. */
  32554. animations: Nullable<Array<Animation>>;
  32555. }
  32556. }
  32557. declare module BABYLON {
  32558. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32559. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32560. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32561. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32562. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32563. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32564. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32565. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32566. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32567. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32568. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32569. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32570. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32571. /**
  32572. * Decorator used to define property that can be serialized as reference to a camera
  32573. * @param sourceName defines the name of the property to decorate
  32574. */
  32575. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32576. /**
  32577. * Class used to help serialization objects
  32578. */
  32579. export class SerializationHelper {
  32580. /** @hidden */
  32581. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32582. /** @hidden */
  32583. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32584. /** @hidden */
  32585. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32586. /** @hidden */
  32587. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32588. /**
  32589. * Appends the serialized animations from the source animations
  32590. * @param source Source containing the animations
  32591. * @param destination Target to store the animations
  32592. */
  32593. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32594. /**
  32595. * Static function used to serialized a specific entity
  32596. * @param entity defines the entity to serialize
  32597. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32598. * @returns a JSON compatible object representing the serialization of the entity
  32599. */
  32600. static Serialize<T>(entity: T, serializationObject?: any): any;
  32601. /**
  32602. * Creates a new entity from a serialization data object
  32603. * @param creationFunction defines a function used to instanciated the new entity
  32604. * @param source defines the source serialization data
  32605. * @param scene defines the hosting scene
  32606. * @param rootUrl defines the root url for resources
  32607. * @returns a new entity
  32608. */
  32609. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32610. /**
  32611. * Clones an object
  32612. * @param creationFunction defines the function used to instanciate the new object
  32613. * @param source defines the source object
  32614. * @returns the cloned object
  32615. */
  32616. static Clone<T>(creationFunction: () => T, source: T): T;
  32617. /**
  32618. * Instanciates a new object based on a source one (some data will be shared between both object)
  32619. * @param creationFunction defines the function used to instanciate the new object
  32620. * @param source defines the source object
  32621. * @returns the new object
  32622. */
  32623. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32624. }
  32625. }
  32626. declare module BABYLON {
  32627. /**
  32628. * Base class of all the textures in babylon.
  32629. * It groups all the common properties the materials, post process, lights... might need
  32630. * in order to make a correct use of the texture.
  32631. */
  32632. export class BaseTexture implements IAnimatable {
  32633. /**
  32634. * Default anisotropic filtering level for the application.
  32635. * It is set to 4 as a good tradeoff between perf and quality.
  32636. */
  32637. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32638. /**
  32639. * Gets or sets the unique id of the texture
  32640. */
  32641. uniqueId: number;
  32642. /**
  32643. * Define the name of the texture.
  32644. */
  32645. name: string;
  32646. /**
  32647. * Gets or sets an object used to store user defined information.
  32648. */
  32649. metadata: any;
  32650. /**
  32651. * For internal use only. Please do not use.
  32652. */
  32653. reservedDataStore: any;
  32654. private _hasAlpha;
  32655. /**
  32656. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32657. */
  32658. set hasAlpha(value: boolean);
  32659. get hasAlpha(): boolean;
  32660. /**
  32661. * Defines if the alpha value should be determined via the rgb values.
  32662. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32663. */
  32664. getAlphaFromRGB: boolean;
  32665. /**
  32666. * Intensity or strength of the texture.
  32667. * It is commonly used by materials to fine tune the intensity of the texture
  32668. */
  32669. level: number;
  32670. /**
  32671. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32672. * This is part of the texture as textures usually maps to one uv set.
  32673. */
  32674. coordinatesIndex: number;
  32675. private _coordinatesMode;
  32676. /**
  32677. * How a texture is mapped.
  32678. *
  32679. * | Value | Type | Description |
  32680. * | ----- | ----------------------------------- | ----------- |
  32681. * | 0 | EXPLICIT_MODE | |
  32682. * | 1 | SPHERICAL_MODE | |
  32683. * | 2 | PLANAR_MODE | |
  32684. * | 3 | CUBIC_MODE | |
  32685. * | 4 | PROJECTION_MODE | |
  32686. * | 5 | SKYBOX_MODE | |
  32687. * | 6 | INVCUBIC_MODE | |
  32688. * | 7 | EQUIRECTANGULAR_MODE | |
  32689. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32690. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32691. */
  32692. set coordinatesMode(value: number);
  32693. get coordinatesMode(): number;
  32694. /**
  32695. * | Value | Type | Description |
  32696. * | ----- | ------------------ | ----------- |
  32697. * | 0 | CLAMP_ADDRESSMODE | |
  32698. * | 1 | WRAP_ADDRESSMODE | |
  32699. * | 2 | MIRROR_ADDRESSMODE | |
  32700. */
  32701. wrapU: number;
  32702. /**
  32703. * | Value | Type | Description |
  32704. * | ----- | ------------------ | ----------- |
  32705. * | 0 | CLAMP_ADDRESSMODE | |
  32706. * | 1 | WRAP_ADDRESSMODE | |
  32707. * | 2 | MIRROR_ADDRESSMODE | |
  32708. */
  32709. wrapV: number;
  32710. /**
  32711. * | Value | Type | Description |
  32712. * | ----- | ------------------ | ----------- |
  32713. * | 0 | CLAMP_ADDRESSMODE | |
  32714. * | 1 | WRAP_ADDRESSMODE | |
  32715. * | 2 | MIRROR_ADDRESSMODE | |
  32716. */
  32717. wrapR: number;
  32718. /**
  32719. * With compliant hardware and browser (supporting anisotropic filtering)
  32720. * this defines the level of anisotropic filtering in the texture.
  32721. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32722. */
  32723. anisotropicFilteringLevel: number;
  32724. /**
  32725. * Define if the texture is a cube texture or if false a 2d texture.
  32726. */
  32727. get isCube(): boolean;
  32728. set isCube(value: boolean);
  32729. /**
  32730. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32731. */
  32732. get is3D(): boolean;
  32733. set is3D(value: boolean);
  32734. /**
  32735. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32736. */
  32737. get is2DArray(): boolean;
  32738. set is2DArray(value: boolean);
  32739. /**
  32740. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32741. * HDR texture are usually stored in linear space.
  32742. * This only impacts the PBR and Background materials
  32743. */
  32744. gammaSpace: boolean;
  32745. /**
  32746. * Gets or sets whether or not the texture contains RGBD data.
  32747. */
  32748. get isRGBD(): boolean;
  32749. set isRGBD(value: boolean);
  32750. /**
  32751. * Is Z inverted in the texture (useful in a cube texture).
  32752. */
  32753. invertZ: boolean;
  32754. /**
  32755. * Are mip maps generated for this texture or not.
  32756. */
  32757. get noMipmap(): boolean;
  32758. /**
  32759. * @hidden
  32760. */
  32761. lodLevelInAlpha: boolean;
  32762. /**
  32763. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32764. */
  32765. get lodGenerationOffset(): number;
  32766. set lodGenerationOffset(value: number);
  32767. /**
  32768. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32769. */
  32770. get lodGenerationScale(): number;
  32771. set lodGenerationScale(value: number);
  32772. /**
  32773. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32774. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32775. * average roughness values.
  32776. */
  32777. get linearSpecularLOD(): boolean;
  32778. set linearSpecularLOD(value: boolean);
  32779. /**
  32780. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32781. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32782. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32783. */
  32784. get irradianceTexture(): Nullable<BaseTexture>;
  32785. set irradianceTexture(value: Nullable<BaseTexture>);
  32786. /**
  32787. * Define if the texture is a render target.
  32788. */
  32789. isRenderTarget: boolean;
  32790. /**
  32791. * Define the unique id of the texture in the scene.
  32792. */
  32793. get uid(): string;
  32794. /** @hidden */
  32795. _prefiltered: boolean;
  32796. /**
  32797. * Return a string representation of the texture.
  32798. * @returns the texture as a string
  32799. */
  32800. toString(): string;
  32801. /**
  32802. * Get the class name of the texture.
  32803. * @returns "BaseTexture"
  32804. */
  32805. getClassName(): string;
  32806. /**
  32807. * Define the list of animation attached to the texture.
  32808. */
  32809. animations: Animation[];
  32810. /**
  32811. * An event triggered when the texture is disposed.
  32812. */
  32813. onDisposeObservable: Observable<BaseTexture>;
  32814. private _onDisposeObserver;
  32815. /**
  32816. * Callback triggered when the texture has been disposed.
  32817. * Kept for back compatibility, you can use the onDisposeObservable instead.
  32818. */
  32819. set onDispose(callback: () => void);
  32820. /**
  32821. * Define the current state of the loading sequence when in delayed load mode.
  32822. */
  32823. delayLoadState: number;
  32824. private _scene;
  32825. private _engine;
  32826. /** @hidden */
  32827. _texture: Nullable<InternalTexture>;
  32828. private _uid;
  32829. /**
  32830. * Define if the texture is preventinga material to render or not.
  32831. * If not and the texture is not ready, the engine will use a default black texture instead.
  32832. */
  32833. get isBlocking(): boolean;
  32834. /**
  32835. * Instantiates a new BaseTexture.
  32836. * Base class of all the textures in babylon.
  32837. * It groups all the common properties the materials, post process, lights... might need
  32838. * in order to make a correct use of the texture.
  32839. * @param sceneOrEngine Define the scene or engine the texture blongs to
  32840. */
  32841. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  32842. /**
  32843. * Get the scene the texture belongs to.
  32844. * @returns the scene or null if undefined
  32845. */
  32846. getScene(): Nullable<Scene>;
  32847. /** @hidden */
  32848. protected _getEngine(): Nullable<ThinEngine>;
  32849. /**
  32850. * Get the texture transform matrix used to offset tile the texture for istance.
  32851. * @returns the transformation matrix
  32852. */
  32853. getTextureMatrix(): Matrix;
  32854. /**
  32855. * Get the texture reflection matrix used to rotate/transform the reflection.
  32856. * @returns the reflection matrix
  32857. */
  32858. getReflectionTextureMatrix(): Matrix;
  32859. /**
  32860. * Get the underlying lower level texture from Babylon.
  32861. * @returns the insternal texture
  32862. */
  32863. getInternalTexture(): Nullable<InternalTexture>;
  32864. /**
  32865. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  32866. * @returns true if ready or not blocking
  32867. */
  32868. isReadyOrNotBlocking(): boolean;
  32869. /**
  32870. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  32871. * @returns true if fully ready
  32872. */
  32873. isReady(): boolean;
  32874. private _cachedSize;
  32875. /**
  32876. * Get the size of the texture.
  32877. * @returns the texture size.
  32878. */
  32879. getSize(): ISize;
  32880. /**
  32881. * Get the base size of the texture.
  32882. * It can be different from the size if the texture has been resized for POT for instance
  32883. * @returns the base size
  32884. */
  32885. getBaseSize(): ISize;
  32886. /**
  32887. * Update the sampling mode of the texture.
  32888. * Default is Trilinear mode.
  32889. *
  32890. * | Value | Type | Description |
  32891. * | ----- | ------------------ | ----------- |
  32892. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  32893. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  32894. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  32895. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  32896. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  32897. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  32898. * | 7 | NEAREST_LINEAR | |
  32899. * | 8 | NEAREST_NEAREST | |
  32900. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  32901. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  32902. * | 11 | LINEAR_LINEAR | |
  32903. * | 12 | LINEAR_NEAREST | |
  32904. *
  32905. * > _mag_: magnification filter (close to the viewer)
  32906. * > _min_: minification filter (far from the viewer)
  32907. * > _mip_: filter used between mip map levels
  32908. *@param samplingMode Define the new sampling mode of the texture
  32909. */
  32910. updateSamplingMode(samplingMode: number): void;
  32911. /**
  32912. * Scales the texture if is `canRescale()`
  32913. * @param ratio the resize factor we want to use to rescale
  32914. */
  32915. scale(ratio: number): void;
  32916. /**
  32917. * Get if the texture can rescale.
  32918. */
  32919. get canRescale(): boolean;
  32920. /** @hidden */
  32921. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  32922. /** @hidden */
  32923. _rebuild(): void;
  32924. /**
  32925. * Triggers the load sequence in delayed load mode.
  32926. */
  32927. delayLoad(): void;
  32928. /**
  32929. * Clones the texture.
  32930. * @returns the cloned texture
  32931. */
  32932. clone(): Nullable<BaseTexture>;
  32933. /**
  32934. * Get the texture underlying type (INT, FLOAT...)
  32935. */
  32936. get textureType(): number;
  32937. /**
  32938. * Get the texture underlying format (RGB, RGBA...)
  32939. */
  32940. get textureFormat(): number;
  32941. /**
  32942. * Indicates that textures need to be re-calculated for all materials
  32943. */
  32944. protected _markAllSubMeshesAsTexturesDirty(): void;
  32945. /**
  32946. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  32947. * This will returns an RGBA array buffer containing either in values (0-255) or
  32948. * float values (0-1) depending of the underlying buffer type.
  32949. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  32950. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  32951. * @param buffer defines a user defined buffer to fill with data (can be null)
  32952. * @returns The Array buffer containing the pixels data.
  32953. */
  32954. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  32955. /**
  32956. * Release and destroy the underlying lower level texture aka internalTexture.
  32957. */
  32958. releaseInternalTexture(): void;
  32959. /** @hidden */
  32960. get _lodTextureHigh(): Nullable<BaseTexture>;
  32961. /** @hidden */
  32962. get _lodTextureMid(): Nullable<BaseTexture>;
  32963. /** @hidden */
  32964. get _lodTextureLow(): Nullable<BaseTexture>;
  32965. /**
  32966. * Dispose the texture and release its associated resources.
  32967. */
  32968. dispose(): void;
  32969. /**
  32970. * Serialize the texture into a JSON representation that can be parsed later on.
  32971. * @returns the JSON representation of the texture
  32972. */
  32973. serialize(): any;
  32974. /**
  32975. * Helper function to be called back once a list of texture contains only ready textures.
  32976. * @param textures Define the list of textures to wait for
  32977. * @param callback Define the callback triggered once the entire list will be ready
  32978. */
  32979. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  32980. private static _isScene;
  32981. }
  32982. }
  32983. declare module BABYLON {
  32984. /**
  32985. * Options to be used when creating an effect.
  32986. */
  32987. export interface IEffectCreationOptions {
  32988. /**
  32989. * Atrributes that will be used in the shader.
  32990. */
  32991. attributes: string[];
  32992. /**
  32993. * Uniform varible names that will be set in the shader.
  32994. */
  32995. uniformsNames: string[];
  32996. /**
  32997. * Uniform buffer variable names that will be set in the shader.
  32998. */
  32999. uniformBuffersNames: string[];
  33000. /**
  33001. * Sampler texture variable names that will be set in the shader.
  33002. */
  33003. samplers: string[];
  33004. /**
  33005. * Define statements that will be set in the shader.
  33006. */
  33007. defines: any;
  33008. /**
  33009. * Possible fallbacks for this effect to improve performance when needed.
  33010. */
  33011. fallbacks: Nullable<IEffectFallbacks>;
  33012. /**
  33013. * Callback that will be called when the shader is compiled.
  33014. */
  33015. onCompiled: Nullable<(effect: Effect) => void>;
  33016. /**
  33017. * Callback that will be called if an error occurs during shader compilation.
  33018. */
  33019. onError: Nullable<(effect: Effect, errors: string) => void>;
  33020. /**
  33021. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33022. */
  33023. indexParameters?: any;
  33024. /**
  33025. * Max number of lights that can be used in the shader.
  33026. */
  33027. maxSimultaneousLights?: number;
  33028. /**
  33029. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33030. */
  33031. transformFeedbackVaryings?: Nullable<string[]>;
  33032. }
  33033. /**
  33034. * Effect containing vertex and fragment shader that can be executed on an object.
  33035. */
  33036. export class Effect implements IDisposable {
  33037. /**
  33038. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33039. */
  33040. static ShadersRepository: string;
  33041. /**
  33042. * Enable logging of the shader code when a compilation error occurs
  33043. */
  33044. static LogShaderCodeOnCompilationError: boolean;
  33045. /**
  33046. * Name of the effect.
  33047. */
  33048. name: any;
  33049. /**
  33050. * String container all the define statements that should be set on the shader.
  33051. */
  33052. defines: string;
  33053. /**
  33054. * Callback that will be called when the shader is compiled.
  33055. */
  33056. onCompiled: Nullable<(effect: Effect) => void>;
  33057. /**
  33058. * Callback that will be called if an error occurs during shader compilation.
  33059. */
  33060. onError: Nullable<(effect: Effect, errors: string) => void>;
  33061. /**
  33062. * Callback that will be called when effect is bound.
  33063. */
  33064. onBind: Nullable<(effect: Effect) => void>;
  33065. /**
  33066. * Unique ID of the effect.
  33067. */
  33068. uniqueId: number;
  33069. /**
  33070. * Observable that will be called when the shader is compiled.
  33071. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33072. */
  33073. onCompileObservable: Observable<Effect>;
  33074. /**
  33075. * Observable that will be called if an error occurs during shader compilation.
  33076. */
  33077. onErrorObservable: Observable<Effect>;
  33078. /** @hidden */
  33079. _onBindObservable: Nullable<Observable<Effect>>;
  33080. /**
  33081. * @hidden
  33082. * Specifies if the effect was previously ready
  33083. */
  33084. _wasPreviouslyReady: boolean;
  33085. /**
  33086. * Observable that will be called when effect is bound.
  33087. */
  33088. get onBindObservable(): Observable<Effect>;
  33089. /** @hidden */
  33090. _bonesComputationForcedToCPU: boolean;
  33091. private static _uniqueIdSeed;
  33092. private _engine;
  33093. private _uniformBuffersNames;
  33094. private _uniformBuffersNamesList;
  33095. private _uniformsNames;
  33096. private _samplerList;
  33097. private _samplers;
  33098. private _isReady;
  33099. private _compilationError;
  33100. private _allFallbacksProcessed;
  33101. private _attributesNames;
  33102. private _attributes;
  33103. private _attributeLocationByName;
  33104. private _uniforms;
  33105. /**
  33106. * Key for the effect.
  33107. * @hidden
  33108. */
  33109. _key: string;
  33110. private _indexParameters;
  33111. private _fallbacks;
  33112. private _vertexSourceCode;
  33113. private _fragmentSourceCode;
  33114. private _vertexSourceCodeOverride;
  33115. private _fragmentSourceCodeOverride;
  33116. private _transformFeedbackVaryings;
  33117. /**
  33118. * Compiled shader to webGL program.
  33119. * @hidden
  33120. */
  33121. _pipelineContext: Nullable<IPipelineContext>;
  33122. private _valueCache;
  33123. private static _baseCache;
  33124. /**
  33125. * Instantiates an effect.
  33126. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33127. * @param baseName Name of the effect.
  33128. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33129. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33130. * @param samplers List of sampler variables that will be passed to the shader.
  33131. * @param engine Engine to be used to render the effect
  33132. * @param defines Define statements to be added to the shader.
  33133. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33134. * @param onCompiled Callback that will be called when the shader is compiled.
  33135. * @param onError Callback that will be called if an error occurs during shader compilation.
  33136. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33137. */
  33138. 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);
  33139. private _useFinalCode;
  33140. /**
  33141. * Unique key for this effect
  33142. */
  33143. get key(): string;
  33144. /**
  33145. * If the effect has been compiled and prepared.
  33146. * @returns if the effect is compiled and prepared.
  33147. */
  33148. isReady(): boolean;
  33149. private _isReadyInternal;
  33150. /**
  33151. * The engine the effect was initialized with.
  33152. * @returns the engine.
  33153. */
  33154. getEngine(): Engine;
  33155. /**
  33156. * The pipeline context for this effect
  33157. * @returns the associated pipeline context
  33158. */
  33159. getPipelineContext(): Nullable<IPipelineContext>;
  33160. /**
  33161. * The set of names of attribute variables for the shader.
  33162. * @returns An array of attribute names.
  33163. */
  33164. getAttributesNames(): string[];
  33165. /**
  33166. * Returns the attribute at the given index.
  33167. * @param index The index of the attribute.
  33168. * @returns The location of the attribute.
  33169. */
  33170. getAttributeLocation(index: number): number;
  33171. /**
  33172. * Returns the attribute based on the name of the variable.
  33173. * @param name of the attribute to look up.
  33174. * @returns the attribute location.
  33175. */
  33176. getAttributeLocationByName(name: string): number;
  33177. /**
  33178. * The number of attributes.
  33179. * @returns the numnber of attributes.
  33180. */
  33181. getAttributesCount(): number;
  33182. /**
  33183. * Gets the index of a uniform variable.
  33184. * @param uniformName of the uniform to look up.
  33185. * @returns the index.
  33186. */
  33187. getUniformIndex(uniformName: string): number;
  33188. /**
  33189. * Returns the attribute based on the name of the variable.
  33190. * @param uniformName of the uniform to look up.
  33191. * @returns the location of the uniform.
  33192. */
  33193. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33194. /**
  33195. * Returns an array of sampler variable names
  33196. * @returns The array of sampler variable names.
  33197. */
  33198. getSamplers(): string[];
  33199. /**
  33200. * Returns an array of uniform variable names
  33201. * @returns The array of uniform variable names.
  33202. */
  33203. getUniformNames(): string[];
  33204. /**
  33205. * Returns an array of uniform buffer variable names
  33206. * @returns The array of uniform buffer variable names.
  33207. */
  33208. getUniformBuffersNames(): string[];
  33209. /**
  33210. * Returns the index parameters used to create the effect
  33211. * @returns The index parameters object
  33212. */
  33213. getIndexParameters(): any;
  33214. /**
  33215. * The error from the last compilation.
  33216. * @returns the error string.
  33217. */
  33218. getCompilationError(): string;
  33219. /**
  33220. * Gets a boolean indicating that all fallbacks were used during compilation
  33221. * @returns true if all fallbacks were used
  33222. */
  33223. allFallbacksProcessed(): boolean;
  33224. /**
  33225. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33226. * @param func The callback to be used.
  33227. */
  33228. executeWhenCompiled(func: (effect: Effect) => void): void;
  33229. private _checkIsReady;
  33230. private _loadShader;
  33231. /**
  33232. * Gets the vertex shader source code of this effect
  33233. */
  33234. get vertexSourceCode(): string;
  33235. /**
  33236. * Gets the fragment shader source code of this effect
  33237. */
  33238. get fragmentSourceCode(): string;
  33239. /**
  33240. * Recompiles the webGL program
  33241. * @param vertexSourceCode The source code for the vertex shader.
  33242. * @param fragmentSourceCode The source code for the fragment shader.
  33243. * @param onCompiled Callback called when completed.
  33244. * @param onError Callback called on error.
  33245. * @hidden
  33246. */
  33247. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33248. /**
  33249. * Prepares the effect
  33250. * @hidden
  33251. */
  33252. _prepareEffect(): void;
  33253. private _getShaderCodeAndErrorLine;
  33254. private _processCompilationErrors;
  33255. /**
  33256. * Checks if the effect is supported. (Must be called after compilation)
  33257. */
  33258. get isSupported(): boolean;
  33259. /**
  33260. * Binds a texture to the engine to be used as output of the shader.
  33261. * @param channel Name of the output variable.
  33262. * @param texture Texture to bind.
  33263. * @hidden
  33264. */
  33265. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33266. /**
  33267. * Sets a texture on the engine to be used in the shader.
  33268. * @param channel Name of the sampler variable.
  33269. * @param texture Texture to set.
  33270. */
  33271. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33272. /**
  33273. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33274. * @param channel Name of the sampler variable.
  33275. * @param texture Texture to set.
  33276. */
  33277. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33278. /**
  33279. * Sets an array of textures on the engine to be used in the shader.
  33280. * @param channel Name of the variable.
  33281. * @param textures Textures to set.
  33282. */
  33283. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33284. /**
  33285. * 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)
  33286. * @param channel Name of the sampler variable.
  33287. * @param postProcess Post process to get the input texture from.
  33288. */
  33289. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33290. /**
  33291. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33292. * 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)
  33293. * @param channel Name of the sampler variable.
  33294. * @param postProcess Post process to get the output texture from.
  33295. */
  33296. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33297. /** @hidden */
  33298. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33299. /** @hidden */
  33300. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33301. /** @hidden */
  33302. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33303. /** @hidden */
  33304. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33305. /**
  33306. * Binds a buffer to a uniform.
  33307. * @param buffer Buffer to bind.
  33308. * @param name Name of the uniform variable to bind to.
  33309. */
  33310. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33311. /**
  33312. * Binds block to a uniform.
  33313. * @param blockName Name of the block to bind.
  33314. * @param index Index to bind.
  33315. */
  33316. bindUniformBlock(blockName: string, index: number): void;
  33317. /**
  33318. * Sets an interger value on a uniform variable.
  33319. * @param uniformName Name of the variable.
  33320. * @param value Value to be set.
  33321. * @returns this effect.
  33322. */
  33323. setInt(uniformName: string, value: number): Effect;
  33324. /**
  33325. * Sets an int array on a uniform variable.
  33326. * @param uniformName Name of the variable.
  33327. * @param array array to be set.
  33328. * @returns this effect.
  33329. */
  33330. setIntArray(uniformName: string, array: Int32Array): Effect;
  33331. /**
  33332. * 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)
  33333. * @param uniformName Name of the variable.
  33334. * @param array array to be set.
  33335. * @returns this effect.
  33336. */
  33337. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33338. /**
  33339. * 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)
  33340. * @param uniformName Name of the variable.
  33341. * @param array array to be set.
  33342. * @returns this effect.
  33343. */
  33344. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33345. /**
  33346. * 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)
  33347. * @param uniformName Name of the variable.
  33348. * @param array array to be set.
  33349. * @returns this effect.
  33350. */
  33351. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33352. /**
  33353. * Sets an float array on a uniform variable.
  33354. * @param uniformName Name of the variable.
  33355. * @param array array to be set.
  33356. * @returns this effect.
  33357. */
  33358. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33359. /**
  33360. * 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)
  33361. * @param uniformName Name of the variable.
  33362. * @param array array to be set.
  33363. * @returns this effect.
  33364. */
  33365. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33366. /**
  33367. * 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)
  33368. * @param uniformName Name of the variable.
  33369. * @param array array to be set.
  33370. * @returns this effect.
  33371. */
  33372. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33373. /**
  33374. * 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)
  33375. * @param uniformName Name of the variable.
  33376. * @param array array to be set.
  33377. * @returns this effect.
  33378. */
  33379. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33380. /**
  33381. * Sets an array on a uniform variable.
  33382. * @param uniformName Name of the variable.
  33383. * @param array array to be set.
  33384. * @returns this effect.
  33385. */
  33386. setArray(uniformName: string, array: number[]): Effect;
  33387. /**
  33388. * 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)
  33389. * @param uniformName Name of the variable.
  33390. * @param array array to be set.
  33391. * @returns this effect.
  33392. */
  33393. setArray2(uniformName: string, array: number[]): Effect;
  33394. /**
  33395. * 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)
  33396. * @param uniformName Name of the variable.
  33397. * @param array array to be set.
  33398. * @returns this effect.
  33399. */
  33400. setArray3(uniformName: string, array: number[]): Effect;
  33401. /**
  33402. * 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)
  33403. * @param uniformName Name of the variable.
  33404. * @param array array to be set.
  33405. * @returns this effect.
  33406. */
  33407. setArray4(uniformName: string, array: number[]): Effect;
  33408. /**
  33409. * Sets matrices on a uniform variable.
  33410. * @param uniformName Name of the variable.
  33411. * @param matrices matrices to be set.
  33412. * @returns this effect.
  33413. */
  33414. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33415. /**
  33416. * Sets matrix on a uniform variable.
  33417. * @param uniformName Name of the variable.
  33418. * @param matrix matrix to be set.
  33419. * @returns this effect.
  33420. */
  33421. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33422. /**
  33423. * 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)
  33424. * @param uniformName Name of the variable.
  33425. * @param matrix matrix to be set.
  33426. * @returns this effect.
  33427. */
  33428. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33429. /**
  33430. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33431. * @param uniformName Name of the variable.
  33432. * @param matrix matrix to be set.
  33433. * @returns this effect.
  33434. */
  33435. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33436. /**
  33437. * Sets a float on a uniform variable.
  33438. * @param uniformName Name of the variable.
  33439. * @param value value to be set.
  33440. * @returns this effect.
  33441. */
  33442. setFloat(uniformName: string, value: number): Effect;
  33443. /**
  33444. * Sets a boolean on a uniform variable.
  33445. * @param uniformName Name of the variable.
  33446. * @param bool value to be set.
  33447. * @returns this effect.
  33448. */
  33449. setBool(uniformName: string, bool: boolean): Effect;
  33450. /**
  33451. * Sets a Vector2 on a uniform variable.
  33452. * @param uniformName Name of the variable.
  33453. * @param vector2 vector2 to be set.
  33454. * @returns this effect.
  33455. */
  33456. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33457. /**
  33458. * Sets a float2 on a uniform variable.
  33459. * @param uniformName Name of the variable.
  33460. * @param x First float in float2.
  33461. * @param y Second float in float2.
  33462. * @returns this effect.
  33463. */
  33464. setFloat2(uniformName: string, x: number, y: number): Effect;
  33465. /**
  33466. * Sets a Vector3 on a uniform variable.
  33467. * @param uniformName Name of the variable.
  33468. * @param vector3 Value to be set.
  33469. * @returns this effect.
  33470. */
  33471. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33472. /**
  33473. * Sets a float3 on a uniform variable.
  33474. * @param uniformName Name of the variable.
  33475. * @param x First float in float3.
  33476. * @param y Second float in float3.
  33477. * @param z Third float in float3.
  33478. * @returns this effect.
  33479. */
  33480. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33481. /**
  33482. * Sets a Vector4 on a uniform variable.
  33483. * @param uniformName Name of the variable.
  33484. * @param vector4 Value to be set.
  33485. * @returns this effect.
  33486. */
  33487. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33488. /**
  33489. * Sets a float4 on a uniform variable.
  33490. * @param uniformName Name of the variable.
  33491. * @param x First float in float4.
  33492. * @param y Second float in float4.
  33493. * @param z Third float in float4.
  33494. * @param w Fourth float in float4.
  33495. * @returns this effect.
  33496. */
  33497. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33498. /**
  33499. * Sets a Color3 on a uniform variable.
  33500. * @param uniformName Name of the variable.
  33501. * @param color3 Value to be set.
  33502. * @returns this effect.
  33503. */
  33504. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33505. /**
  33506. * Sets a Color4 on a uniform variable.
  33507. * @param uniformName Name of the variable.
  33508. * @param color3 Value to be set.
  33509. * @param alpha Alpha value to be set.
  33510. * @returns this effect.
  33511. */
  33512. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33513. /**
  33514. * Sets a Color4 on a uniform variable
  33515. * @param uniformName defines the name of the variable
  33516. * @param color4 defines the value to be set
  33517. * @returns this effect.
  33518. */
  33519. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33520. /** Release all associated resources */
  33521. dispose(): void;
  33522. /**
  33523. * This function will add a new shader to the shader store
  33524. * @param name the name of the shader
  33525. * @param pixelShader optional pixel shader content
  33526. * @param vertexShader optional vertex shader content
  33527. */
  33528. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33529. /**
  33530. * Store of each shader (The can be looked up using effect.key)
  33531. */
  33532. static ShadersStore: {
  33533. [key: string]: string;
  33534. };
  33535. /**
  33536. * Store of each included file for a shader (The can be looked up using effect.key)
  33537. */
  33538. static IncludesShadersStore: {
  33539. [key: string]: string;
  33540. };
  33541. /**
  33542. * Resets the cache of effects.
  33543. */
  33544. static ResetCache(): void;
  33545. }
  33546. }
  33547. declare module BABYLON {
  33548. /**
  33549. * Interface used to describe the capabilities of the engine relatively to the current browser
  33550. */
  33551. export interface EngineCapabilities {
  33552. /** Maximum textures units per fragment shader */
  33553. maxTexturesImageUnits: number;
  33554. /** Maximum texture units per vertex shader */
  33555. maxVertexTextureImageUnits: number;
  33556. /** Maximum textures units in the entire pipeline */
  33557. maxCombinedTexturesImageUnits: number;
  33558. /** Maximum texture size */
  33559. maxTextureSize: number;
  33560. /** Maximum texture samples */
  33561. maxSamples?: number;
  33562. /** Maximum cube texture size */
  33563. maxCubemapTextureSize: number;
  33564. /** Maximum render texture size */
  33565. maxRenderTextureSize: number;
  33566. /** Maximum number of vertex attributes */
  33567. maxVertexAttribs: number;
  33568. /** Maximum number of varyings */
  33569. maxVaryingVectors: number;
  33570. /** Maximum number of uniforms per vertex shader */
  33571. maxVertexUniformVectors: number;
  33572. /** Maximum number of uniforms per fragment shader */
  33573. maxFragmentUniformVectors: number;
  33574. /** Defines if standard derivates (dx/dy) are supported */
  33575. standardDerivatives: boolean;
  33576. /** Defines if s3tc texture compression is supported */
  33577. s3tc?: WEBGL_compressed_texture_s3tc;
  33578. /** Defines if pvrtc texture compression is supported */
  33579. pvrtc: any;
  33580. /** Defines if etc1 texture compression is supported */
  33581. etc1: any;
  33582. /** Defines if etc2 texture compression is supported */
  33583. etc2: any;
  33584. /** Defines if astc texture compression is supported */
  33585. astc: any;
  33586. /** Defines if float textures are supported */
  33587. textureFloat: boolean;
  33588. /** Defines if vertex array objects are supported */
  33589. vertexArrayObject: boolean;
  33590. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33591. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33592. /** Gets the maximum level of anisotropy supported */
  33593. maxAnisotropy: number;
  33594. /** Defines if instancing is supported */
  33595. instancedArrays: boolean;
  33596. /** Defines if 32 bits indices are supported */
  33597. uintIndices: boolean;
  33598. /** Defines if high precision shaders are supported */
  33599. highPrecisionShaderSupported: boolean;
  33600. /** Defines if depth reading in the fragment shader is supported */
  33601. fragmentDepthSupported: boolean;
  33602. /** Defines if float texture linear filtering is supported*/
  33603. textureFloatLinearFiltering: boolean;
  33604. /** Defines if rendering to float textures is supported */
  33605. textureFloatRender: boolean;
  33606. /** Defines if half float textures are supported*/
  33607. textureHalfFloat: boolean;
  33608. /** Defines if half float texture linear filtering is supported*/
  33609. textureHalfFloatLinearFiltering: boolean;
  33610. /** Defines if rendering to half float textures is supported */
  33611. textureHalfFloatRender: boolean;
  33612. /** Defines if textureLOD shader command is supported */
  33613. textureLOD: boolean;
  33614. /** Defines if draw buffers extension is supported */
  33615. drawBuffersExtension: boolean;
  33616. /** Defines if depth textures are supported */
  33617. depthTextureExtension: boolean;
  33618. /** Defines if float color buffer are supported */
  33619. colorBufferFloat: boolean;
  33620. /** Gets disjoint timer query extension (null if not supported) */
  33621. timerQuery?: EXT_disjoint_timer_query;
  33622. /** Defines if timestamp can be used with timer query */
  33623. canUseTimestampForTimerQuery: boolean;
  33624. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33625. multiview?: any;
  33626. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33627. oculusMultiview?: any;
  33628. /** Function used to let the system compiles shaders in background */
  33629. parallelShaderCompile?: {
  33630. COMPLETION_STATUS_KHR: number;
  33631. };
  33632. /** Max number of texture samples for MSAA */
  33633. maxMSAASamples: number;
  33634. /** Defines if the blend min max extension is supported */
  33635. blendMinMax: boolean;
  33636. }
  33637. }
  33638. declare module BABYLON {
  33639. /**
  33640. * @hidden
  33641. **/
  33642. export class DepthCullingState {
  33643. private _isDepthTestDirty;
  33644. private _isDepthMaskDirty;
  33645. private _isDepthFuncDirty;
  33646. private _isCullFaceDirty;
  33647. private _isCullDirty;
  33648. private _isZOffsetDirty;
  33649. private _isFrontFaceDirty;
  33650. private _depthTest;
  33651. private _depthMask;
  33652. private _depthFunc;
  33653. private _cull;
  33654. private _cullFace;
  33655. private _zOffset;
  33656. private _frontFace;
  33657. /**
  33658. * Initializes the state.
  33659. */
  33660. constructor();
  33661. get isDirty(): boolean;
  33662. get zOffset(): number;
  33663. set zOffset(value: number);
  33664. get cullFace(): Nullable<number>;
  33665. set cullFace(value: Nullable<number>);
  33666. get cull(): Nullable<boolean>;
  33667. set cull(value: Nullable<boolean>);
  33668. get depthFunc(): Nullable<number>;
  33669. set depthFunc(value: Nullable<number>);
  33670. get depthMask(): boolean;
  33671. set depthMask(value: boolean);
  33672. get depthTest(): boolean;
  33673. set depthTest(value: boolean);
  33674. get frontFace(): Nullable<number>;
  33675. set frontFace(value: Nullable<number>);
  33676. reset(): void;
  33677. apply(gl: WebGLRenderingContext): void;
  33678. }
  33679. }
  33680. declare module BABYLON {
  33681. /**
  33682. * @hidden
  33683. **/
  33684. export class StencilState {
  33685. /** 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 */
  33686. static readonly ALWAYS: number;
  33687. /** Passed to stencilOperation to specify that stencil value must be kept */
  33688. static readonly KEEP: number;
  33689. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33690. static readonly REPLACE: number;
  33691. private _isStencilTestDirty;
  33692. private _isStencilMaskDirty;
  33693. private _isStencilFuncDirty;
  33694. private _isStencilOpDirty;
  33695. private _stencilTest;
  33696. private _stencilMask;
  33697. private _stencilFunc;
  33698. private _stencilFuncRef;
  33699. private _stencilFuncMask;
  33700. private _stencilOpStencilFail;
  33701. private _stencilOpDepthFail;
  33702. private _stencilOpStencilDepthPass;
  33703. get isDirty(): boolean;
  33704. get stencilFunc(): number;
  33705. set stencilFunc(value: number);
  33706. get stencilFuncRef(): number;
  33707. set stencilFuncRef(value: number);
  33708. get stencilFuncMask(): number;
  33709. set stencilFuncMask(value: number);
  33710. get stencilOpStencilFail(): number;
  33711. set stencilOpStencilFail(value: number);
  33712. get stencilOpDepthFail(): number;
  33713. set stencilOpDepthFail(value: number);
  33714. get stencilOpStencilDepthPass(): number;
  33715. set stencilOpStencilDepthPass(value: number);
  33716. get stencilMask(): number;
  33717. set stencilMask(value: number);
  33718. get stencilTest(): boolean;
  33719. set stencilTest(value: boolean);
  33720. constructor();
  33721. reset(): void;
  33722. apply(gl: WebGLRenderingContext): void;
  33723. }
  33724. }
  33725. declare module BABYLON {
  33726. /**
  33727. * @hidden
  33728. **/
  33729. export class AlphaState {
  33730. private _isAlphaBlendDirty;
  33731. private _isBlendFunctionParametersDirty;
  33732. private _isBlendEquationParametersDirty;
  33733. private _isBlendConstantsDirty;
  33734. private _alphaBlend;
  33735. private _blendFunctionParameters;
  33736. private _blendEquationParameters;
  33737. private _blendConstants;
  33738. /**
  33739. * Initializes the state.
  33740. */
  33741. constructor();
  33742. get isDirty(): boolean;
  33743. get alphaBlend(): boolean;
  33744. set alphaBlend(value: boolean);
  33745. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33746. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33747. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33748. reset(): void;
  33749. apply(gl: WebGLRenderingContext): void;
  33750. }
  33751. }
  33752. declare module BABYLON {
  33753. /** @hidden */
  33754. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33755. attributeProcessor(attribute: string): string;
  33756. varyingProcessor(varying: string, isFragment: boolean): string;
  33757. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33758. }
  33759. }
  33760. declare module BABYLON {
  33761. /**
  33762. * Interface for attribute information associated with buffer instanciation
  33763. */
  33764. export interface InstancingAttributeInfo {
  33765. /**
  33766. * Name of the GLSL attribute
  33767. * if attribute index is not specified, this is used to retrieve the index from the effect
  33768. */
  33769. attributeName: string;
  33770. /**
  33771. * Index/offset of the attribute in the vertex shader
  33772. * if not specified, this will be computes from the name.
  33773. */
  33774. index?: number;
  33775. /**
  33776. * size of the attribute, 1, 2, 3 or 4
  33777. */
  33778. attributeSize: number;
  33779. /**
  33780. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33781. */
  33782. offset: number;
  33783. /**
  33784. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33785. * default to 1
  33786. */
  33787. divisor?: number;
  33788. /**
  33789. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33790. * default is FLOAT
  33791. */
  33792. attributeType?: number;
  33793. /**
  33794. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33795. */
  33796. normalized?: boolean;
  33797. }
  33798. }
  33799. declare module BABYLON {
  33800. interface ThinEngine {
  33801. /**
  33802. * Update a video texture
  33803. * @param texture defines the texture to update
  33804. * @param video defines the video element to use
  33805. * @param invertY defines if data must be stored with Y axis inverted
  33806. */
  33807. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  33808. }
  33809. }
  33810. declare module BABYLON {
  33811. /**
  33812. * Settings for finer control over video usage
  33813. */
  33814. export interface VideoTextureSettings {
  33815. /**
  33816. * Applies `autoplay` to video, if specified
  33817. */
  33818. autoPlay?: boolean;
  33819. /**
  33820. * Applies `loop` to video, if specified
  33821. */
  33822. loop?: boolean;
  33823. /**
  33824. * Automatically updates internal texture from video at every frame in the render loop
  33825. */
  33826. autoUpdateTexture: boolean;
  33827. /**
  33828. * Image src displayed during the video loading or until the user interacts with the video.
  33829. */
  33830. poster?: string;
  33831. }
  33832. /**
  33833. * If you want to display a video in your scene, this is the special texture for that.
  33834. * This special texture works similar to other textures, with the exception of a few parameters.
  33835. * @see https://doc.babylonjs.com/how_to/video_texture
  33836. */
  33837. export class VideoTexture extends Texture {
  33838. /**
  33839. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33840. */
  33841. readonly autoUpdateTexture: boolean;
  33842. /**
  33843. * The video instance used by the texture internally
  33844. */
  33845. readonly video: HTMLVideoElement;
  33846. private _onUserActionRequestedObservable;
  33847. /**
  33848. * Event triggerd when a dom action is required by the user to play the video.
  33849. * This happens due to recent changes in browser policies preventing video to auto start.
  33850. */
  33851. get onUserActionRequestedObservable(): Observable<Texture>;
  33852. private _generateMipMaps;
  33853. private _stillImageCaptured;
  33854. private _displayingPosterTexture;
  33855. private _settings;
  33856. private _createInternalTextureOnEvent;
  33857. private _frameId;
  33858. private _currentSrc;
  33859. /**
  33860. * Creates a video texture.
  33861. * If you want to display a video in your scene, this is the special texture for that.
  33862. * This special texture works similar to other textures, with the exception of a few parameters.
  33863. * @see https://doc.babylonjs.com/how_to/video_texture
  33864. * @param name optional name, will detect from video source, if not defined
  33865. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  33866. * @param scene is obviously the current scene.
  33867. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33868. * @param invertY is false by default but can be used to invert video on Y axis
  33869. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33870. * @param settings allows finer control over video usage
  33871. */
  33872. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33873. private _getName;
  33874. private _getVideo;
  33875. private _createInternalTexture;
  33876. private reset;
  33877. /**
  33878. * @hidden Internal method to initiate `update`.
  33879. */
  33880. _rebuild(): void;
  33881. /**
  33882. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33883. */
  33884. update(): void;
  33885. /**
  33886. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33887. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33888. */
  33889. updateTexture(isVisible: boolean): void;
  33890. protected _updateInternalTexture: () => void;
  33891. /**
  33892. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33893. * @param url New url.
  33894. */
  33895. updateURL(url: string): void;
  33896. /**
  33897. * Clones the texture.
  33898. * @returns the cloned texture
  33899. */
  33900. clone(): VideoTexture;
  33901. /**
  33902. * Dispose the texture and release its associated resources.
  33903. */
  33904. dispose(): void;
  33905. /**
  33906. * Creates a video texture straight from a stream.
  33907. * @param scene Define the scene the texture should be created in
  33908. * @param stream Define the stream the texture should be created from
  33909. * @returns The created video texture as a promise
  33910. */
  33911. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  33912. /**
  33913. * Creates a video texture straight from your WebCam video feed.
  33914. * @param scene Define the scene the texture should be created in
  33915. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33916. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33917. * @returns The created video texture as a promise
  33918. */
  33919. static CreateFromWebCamAsync(scene: Scene, constraints: {
  33920. minWidth: number;
  33921. maxWidth: number;
  33922. minHeight: number;
  33923. maxHeight: number;
  33924. deviceId: string;
  33925. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  33926. /**
  33927. * Creates a video texture straight from your WebCam video feed.
  33928. * @param scene Define the scene the texture should be created in
  33929. * @param onReady Define a callback to triggered once the texture will be ready
  33930. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33931. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33932. */
  33933. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33934. minWidth: number;
  33935. maxWidth: number;
  33936. minHeight: number;
  33937. maxHeight: number;
  33938. deviceId: string;
  33939. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  33940. }
  33941. }
  33942. declare module BABYLON {
  33943. /**
  33944. * Defines the interface used by objects working like Scene
  33945. * @hidden
  33946. */
  33947. export interface ISceneLike {
  33948. _addPendingData(data: any): void;
  33949. _removePendingData(data: any): void;
  33950. offlineProvider: IOfflineProvider;
  33951. }
  33952. /** Interface defining initialization parameters for Engine class */
  33953. export interface EngineOptions extends WebGLContextAttributes {
  33954. /**
  33955. * Defines if the engine should no exceed a specified device ratio
  33956. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  33957. */
  33958. limitDeviceRatio?: number;
  33959. /**
  33960. * Defines if webvr should be enabled automatically
  33961. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33962. */
  33963. autoEnableWebVR?: boolean;
  33964. /**
  33965. * Defines if webgl2 should be turned off even if supported
  33966. * @see http://doc.babylonjs.com/features/webgl2
  33967. */
  33968. disableWebGL2Support?: boolean;
  33969. /**
  33970. * Defines if webaudio should be initialized as well
  33971. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33972. */
  33973. audioEngine?: boolean;
  33974. /**
  33975. * Defines if animations should run using a deterministic lock step
  33976. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33977. */
  33978. deterministicLockstep?: boolean;
  33979. /** Defines the maximum steps to use with deterministic lock step mode */
  33980. lockstepMaxSteps?: number;
  33981. /** Defines the seconds between each deterministic lock step */
  33982. timeStep?: number;
  33983. /**
  33984. * Defines that engine should ignore context lost events
  33985. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  33986. */
  33987. doNotHandleContextLost?: boolean;
  33988. /**
  33989. * Defines that engine should ignore modifying touch action attribute and style
  33990. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  33991. */
  33992. doNotHandleTouchAction?: boolean;
  33993. /**
  33994. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  33995. */
  33996. useHighPrecisionFloats?: boolean;
  33997. }
  33998. /**
  33999. * The base engine class (root of all engines)
  34000. */
  34001. export class ThinEngine {
  34002. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34003. static ExceptionList: ({
  34004. key: string;
  34005. capture: string;
  34006. captureConstraint: number;
  34007. targets: string[];
  34008. } | {
  34009. key: string;
  34010. capture: null;
  34011. captureConstraint: null;
  34012. targets: string[];
  34013. })[];
  34014. /** @hidden */
  34015. static _TextureLoaders: IInternalTextureLoader[];
  34016. /**
  34017. * Returns the current npm package of the sdk
  34018. */
  34019. static get NpmPackage(): string;
  34020. /**
  34021. * Returns the current version of the framework
  34022. */
  34023. static get Version(): string;
  34024. /**
  34025. * Returns a string describing the current engine
  34026. */
  34027. get description(): string;
  34028. /**
  34029. * Gets or sets the epsilon value used by collision engine
  34030. */
  34031. static CollisionsEpsilon: number;
  34032. /**
  34033. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34034. */
  34035. static get ShadersRepository(): string;
  34036. static set ShadersRepository(value: string);
  34037. /** @hidden */
  34038. _shaderProcessor: IShaderProcessor;
  34039. /**
  34040. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34041. */
  34042. forcePOTTextures: boolean;
  34043. /**
  34044. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34045. */
  34046. isFullscreen: boolean;
  34047. /**
  34048. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34049. */
  34050. cullBackFaces: boolean;
  34051. /**
  34052. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34053. */
  34054. renderEvenInBackground: boolean;
  34055. /**
  34056. * Gets or sets a boolean indicating that cache can be kept between frames
  34057. */
  34058. preventCacheWipeBetweenFrames: boolean;
  34059. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34060. validateShaderPrograms: boolean;
  34061. /**
  34062. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34063. * This can provide greater z depth for distant objects.
  34064. */
  34065. useReverseDepthBuffer: boolean;
  34066. /**
  34067. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34068. */
  34069. disableUniformBuffers: boolean;
  34070. /** @hidden */
  34071. _uniformBuffers: UniformBuffer[];
  34072. /**
  34073. * Gets a boolean indicating that the engine supports uniform buffers
  34074. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34075. */
  34076. get supportsUniformBuffers(): boolean;
  34077. /** @hidden */
  34078. _gl: WebGLRenderingContext;
  34079. /** @hidden */
  34080. _webGLVersion: number;
  34081. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34082. protected _windowIsBackground: boolean;
  34083. protected _creationOptions: EngineOptions;
  34084. protected _highPrecisionShadersAllowed: boolean;
  34085. /** @hidden */
  34086. get _shouldUseHighPrecisionShader(): boolean;
  34087. /**
  34088. * Gets a boolean indicating that only power of 2 textures are supported
  34089. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34090. */
  34091. get needPOTTextures(): boolean;
  34092. /** @hidden */
  34093. _badOS: boolean;
  34094. /** @hidden */
  34095. _badDesktopOS: boolean;
  34096. private _hardwareScalingLevel;
  34097. /** @hidden */
  34098. _caps: EngineCapabilities;
  34099. private _isStencilEnable;
  34100. private _glVersion;
  34101. private _glRenderer;
  34102. private _glVendor;
  34103. /** @hidden */
  34104. _videoTextureSupported: boolean;
  34105. protected _renderingQueueLaunched: boolean;
  34106. protected _activeRenderLoops: (() => void)[];
  34107. /**
  34108. * Observable signaled when a context lost event is raised
  34109. */
  34110. onContextLostObservable: Observable<ThinEngine>;
  34111. /**
  34112. * Observable signaled when a context restored event is raised
  34113. */
  34114. onContextRestoredObservable: Observable<ThinEngine>;
  34115. private _onContextLost;
  34116. private _onContextRestored;
  34117. protected _contextWasLost: boolean;
  34118. /** @hidden */
  34119. _doNotHandleContextLost: boolean;
  34120. /**
  34121. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34122. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34123. */
  34124. get doNotHandleContextLost(): boolean;
  34125. set doNotHandleContextLost(value: boolean);
  34126. /**
  34127. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34128. */
  34129. disableVertexArrayObjects: boolean;
  34130. /** @hidden */
  34131. protected _colorWrite: boolean;
  34132. /** @hidden */
  34133. protected _colorWriteChanged: boolean;
  34134. /** @hidden */
  34135. protected _depthCullingState: DepthCullingState;
  34136. /** @hidden */
  34137. protected _stencilState: StencilState;
  34138. /** @hidden */
  34139. _alphaState: AlphaState;
  34140. /** @hidden */
  34141. _alphaMode: number;
  34142. /** @hidden */
  34143. _alphaEquation: number;
  34144. /** @hidden */
  34145. _internalTexturesCache: InternalTexture[];
  34146. /** @hidden */
  34147. protected _activeChannel: number;
  34148. private _currentTextureChannel;
  34149. /** @hidden */
  34150. protected _boundTexturesCache: {
  34151. [key: string]: Nullable<InternalTexture>;
  34152. };
  34153. /** @hidden */
  34154. protected _currentEffect: Nullable<Effect>;
  34155. /** @hidden */
  34156. protected _currentProgram: Nullable<WebGLProgram>;
  34157. private _compiledEffects;
  34158. private _vertexAttribArraysEnabled;
  34159. /** @hidden */
  34160. protected _cachedViewport: Nullable<IViewportLike>;
  34161. private _cachedVertexArrayObject;
  34162. /** @hidden */
  34163. protected _cachedVertexBuffers: any;
  34164. /** @hidden */
  34165. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34166. /** @hidden */
  34167. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34168. /** @hidden */
  34169. _currentRenderTarget: Nullable<InternalTexture>;
  34170. private _uintIndicesCurrentlySet;
  34171. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34172. /** @hidden */
  34173. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34174. /** @hidden */
  34175. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34176. private _currentBufferPointers;
  34177. private _currentInstanceLocations;
  34178. private _currentInstanceBuffers;
  34179. private _textureUnits;
  34180. /** @hidden */
  34181. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34182. /** @hidden */
  34183. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34184. /** @hidden */
  34185. _boundRenderFunction: any;
  34186. private _vaoRecordInProgress;
  34187. private _mustWipeVertexAttributes;
  34188. private _emptyTexture;
  34189. private _emptyCubeTexture;
  34190. private _emptyTexture3D;
  34191. private _emptyTexture2DArray;
  34192. /** @hidden */
  34193. _frameHandler: number;
  34194. private _nextFreeTextureSlots;
  34195. private _maxSimultaneousTextures;
  34196. private _activeRequests;
  34197. /** @hidden */
  34198. _transformTextureUrl: Nullable<(url: string) => string>;
  34199. protected get _supportsHardwareTextureRescaling(): boolean;
  34200. private _framebufferDimensionsObject;
  34201. /**
  34202. * sets the object from which width and height will be taken from when getting render width and height
  34203. * Will fallback to the gl object
  34204. * @param dimensions the framebuffer width and height that will be used.
  34205. */
  34206. set framebufferDimensionsObject(dimensions: Nullable<{
  34207. framebufferWidth: number;
  34208. framebufferHeight: number;
  34209. }>);
  34210. /**
  34211. * Gets the current viewport
  34212. */
  34213. get currentViewport(): Nullable<IViewportLike>;
  34214. /**
  34215. * Gets the default empty texture
  34216. */
  34217. get emptyTexture(): InternalTexture;
  34218. /**
  34219. * Gets the default empty 3D texture
  34220. */
  34221. get emptyTexture3D(): InternalTexture;
  34222. /**
  34223. * Gets the default empty 2D array texture
  34224. */
  34225. get emptyTexture2DArray(): InternalTexture;
  34226. /**
  34227. * Gets the default empty cube texture
  34228. */
  34229. get emptyCubeTexture(): InternalTexture;
  34230. /**
  34231. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34232. */
  34233. readonly premultipliedAlpha: boolean;
  34234. /**
  34235. * Observable event triggered before each texture is initialized
  34236. */
  34237. onBeforeTextureInitObservable: Observable<Texture>;
  34238. /**
  34239. * Creates a new engine
  34240. * @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
  34241. * @param antialias defines enable antialiasing (default: false)
  34242. * @param options defines further options to be sent to the getContext() function
  34243. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34244. */
  34245. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34246. private _rebuildInternalTextures;
  34247. private _rebuildEffects;
  34248. /**
  34249. * Gets a boolean indicating if all created effects are ready
  34250. * @returns true if all effects are ready
  34251. */
  34252. areAllEffectsReady(): boolean;
  34253. protected _rebuildBuffers(): void;
  34254. protected _initGLContext(): void;
  34255. /**
  34256. * Gets version of the current webGL context
  34257. */
  34258. get webGLVersion(): number;
  34259. /**
  34260. * Gets a string idenfifying the name of the class
  34261. * @returns "Engine" string
  34262. */
  34263. getClassName(): string;
  34264. /**
  34265. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34266. */
  34267. get isStencilEnable(): boolean;
  34268. /** @hidden */
  34269. _prepareWorkingCanvas(): void;
  34270. /**
  34271. * Reset the texture cache to empty state
  34272. */
  34273. resetTextureCache(): void;
  34274. /**
  34275. * Gets an object containing information about the current webGL context
  34276. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34277. */
  34278. getGlInfo(): {
  34279. vendor: string;
  34280. renderer: string;
  34281. version: string;
  34282. };
  34283. /**
  34284. * Defines the hardware scaling level.
  34285. * By default the hardware scaling level is computed from the window device ratio.
  34286. * 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.
  34287. * @param level defines the level to use
  34288. */
  34289. setHardwareScalingLevel(level: number): void;
  34290. /**
  34291. * Gets the current hardware scaling level.
  34292. * By default the hardware scaling level is computed from the window device ratio.
  34293. * 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.
  34294. * @returns a number indicating the current hardware scaling level
  34295. */
  34296. getHardwareScalingLevel(): number;
  34297. /**
  34298. * Gets the list of loaded textures
  34299. * @returns an array containing all loaded textures
  34300. */
  34301. getLoadedTexturesCache(): InternalTexture[];
  34302. /**
  34303. * Gets the object containing all engine capabilities
  34304. * @returns the EngineCapabilities object
  34305. */
  34306. getCaps(): EngineCapabilities;
  34307. /**
  34308. * stop executing a render loop function and remove it from the execution array
  34309. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34310. */
  34311. stopRenderLoop(renderFunction?: () => void): void;
  34312. /** @hidden */
  34313. _renderLoop(): void;
  34314. /**
  34315. * Gets the HTML canvas attached with the current webGL context
  34316. * @returns a HTML canvas
  34317. */
  34318. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34319. /**
  34320. * Gets host window
  34321. * @returns the host window object
  34322. */
  34323. getHostWindow(): Nullable<Window>;
  34324. /**
  34325. * Gets the current render width
  34326. * @param useScreen defines if screen size must be used (or the current render target if any)
  34327. * @returns a number defining the current render width
  34328. */
  34329. getRenderWidth(useScreen?: boolean): number;
  34330. /**
  34331. * Gets the current render height
  34332. * @param useScreen defines if screen size must be used (or the current render target if any)
  34333. * @returns a number defining the current render height
  34334. */
  34335. getRenderHeight(useScreen?: boolean): number;
  34336. /**
  34337. * Can be used to override the current requestAnimationFrame requester.
  34338. * @hidden
  34339. */
  34340. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34341. /**
  34342. * Register and execute a render loop. The engine can have more than one render function
  34343. * @param renderFunction defines the function to continuously execute
  34344. */
  34345. runRenderLoop(renderFunction: () => void): void;
  34346. /**
  34347. * Clear the current render buffer or the current render target (if any is set up)
  34348. * @param color defines the color to use
  34349. * @param backBuffer defines if the back buffer must be cleared
  34350. * @param depth defines if the depth buffer must be cleared
  34351. * @param stencil defines if the stencil buffer must be cleared
  34352. */
  34353. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34354. private _viewportCached;
  34355. /** @hidden */
  34356. _viewport(x: number, y: number, width: number, height: number): void;
  34357. /**
  34358. * Set the WebGL's viewport
  34359. * @param viewport defines the viewport element to be used
  34360. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34361. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34362. */
  34363. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34364. /**
  34365. * Begin a new frame
  34366. */
  34367. beginFrame(): void;
  34368. /**
  34369. * Enf the current frame
  34370. */
  34371. endFrame(): void;
  34372. /**
  34373. * Resize the view according to the canvas' size
  34374. */
  34375. resize(): void;
  34376. /**
  34377. * Force a specific size of the canvas
  34378. * @param width defines the new canvas' width
  34379. * @param height defines the new canvas' height
  34380. */
  34381. setSize(width: number, height: number): void;
  34382. /**
  34383. * Binds the frame buffer to the specified texture.
  34384. * @param texture The texture to render to or null for the default canvas
  34385. * @param faceIndex The face of the texture to render to in case of cube texture
  34386. * @param requiredWidth The width of the target to render to
  34387. * @param requiredHeight The height of the target to render to
  34388. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34389. * @param lodLevel defines the lod level to bind to the frame buffer
  34390. * @param layer defines the 2d array index to bind to frame buffer to
  34391. */
  34392. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34393. /** @hidden */
  34394. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34395. /**
  34396. * Unbind the current render target texture from the webGL context
  34397. * @param texture defines the render target texture to unbind
  34398. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34399. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34400. */
  34401. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34402. /**
  34403. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34404. */
  34405. flushFramebuffer(): void;
  34406. /**
  34407. * Unbind the current render target and bind the default framebuffer
  34408. */
  34409. restoreDefaultFramebuffer(): void;
  34410. /** @hidden */
  34411. protected _resetVertexBufferBinding(): void;
  34412. /**
  34413. * Creates a vertex buffer
  34414. * @param data the data for the vertex buffer
  34415. * @returns the new WebGL static buffer
  34416. */
  34417. createVertexBuffer(data: DataArray): DataBuffer;
  34418. private _createVertexBuffer;
  34419. /**
  34420. * Creates a dynamic vertex buffer
  34421. * @param data the data for the dynamic vertex buffer
  34422. * @returns the new WebGL dynamic buffer
  34423. */
  34424. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34425. protected _resetIndexBufferBinding(): void;
  34426. /**
  34427. * Creates a new index buffer
  34428. * @param indices defines the content of the index buffer
  34429. * @param updatable defines if the index buffer must be updatable
  34430. * @returns a new webGL buffer
  34431. */
  34432. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34433. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34434. /**
  34435. * Bind a webGL buffer to the webGL context
  34436. * @param buffer defines the buffer to bind
  34437. */
  34438. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34439. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34440. private bindBuffer;
  34441. /**
  34442. * update the bound buffer with the given data
  34443. * @param data defines the data to update
  34444. */
  34445. updateArrayBuffer(data: Float32Array): void;
  34446. private _vertexAttribPointer;
  34447. /** @hidden */
  34448. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34449. private _bindVertexBuffersAttributes;
  34450. /**
  34451. * Records a vertex array object
  34452. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34453. * @param vertexBuffers defines the list of vertex buffers to store
  34454. * @param indexBuffer defines the index buffer to store
  34455. * @param effect defines the effect to store
  34456. * @returns the new vertex array object
  34457. */
  34458. recordVertexArrayObject(vertexBuffers: {
  34459. [key: string]: VertexBuffer;
  34460. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34461. /**
  34462. * Bind a specific vertex array object
  34463. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34464. * @param vertexArrayObject defines the vertex array object to bind
  34465. * @param indexBuffer defines the index buffer to bind
  34466. */
  34467. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34468. /**
  34469. * Bind webGl buffers directly to the webGL context
  34470. * @param vertexBuffer defines the vertex buffer to bind
  34471. * @param indexBuffer defines the index buffer to bind
  34472. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34473. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34474. * @param effect defines the effect associated with the vertex buffer
  34475. */
  34476. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34477. private _unbindVertexArrayObject;
  34478. /**
  34479. * Bind a list of vertex buffers to the webGL context
  34480. * @param vertexBuffers defines the list of vertex buffers to bind
  34481. * @param indexBuffer defines the index buffer to bind
  34482. * @param effect defines the effect associated with the vertex buffers
  34483. */
  34484. bindBuffers(vertexBuffers: {
  34485. [key: string]: Nullable<VertexBuffer>;
  34486. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34487. /**
  34488. * Unbind all instance attributes
  34489. */
  34490. unbindInstanceAttributes(): void;
  34491. /**
  34492. * Release and free the memory of a vertex array object
  34493. * @param vao defines the vertex array object to delete
  34494. */
  34495. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34496. /** @hidden */
  34497. _releaseBuffer(buffer: DataBuffer): boolean;
  34498. protected _deleteBuffer(buffer: DataBuffer): void;
  34499. /**
  34500. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34501. * @param instancesBuffer defines the webGL buffer to update and bind
  34502. * @param data defines the data to store in the buffer
  34503. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34504. */
  34505. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34506. /**
  34507. * Bind the content of a webGL buffer used with instantiation
  34508. * @param instancesBuffer defines the webGL buffer to bind
  34509. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34510. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34511. */
  34512. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34513. /**
  34514. * Disable the instance attribute corresponding to the name in parameter
  34515. * @param name defines the name of the attribute to disable
  34516. */
  34517. disableInstanceAttributeByName(name: string): void;
  34518. /**
  34519. * Disable the instance attribute corresponding to the location in parameter
  34520. * @param attributeLocation defines the attribute location of the attribute to disable
  34521. */
  34522. disableInstanceAttribute(attributeLocation: number): void;
  34523. /**
  34524. * Disable the attribute corresponding to the location in parameter
  34525. * @param attributeLocation defines the attribute location of the attribute to disable
  34526. */
  34527. disableAttributeByIndex(attributeLocation: number): void;
  34528. /**
  34529. * Send a draw order
  34530. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34531. * @param indexStart defines the starting index
  34532. * @param indexCount defines the number of index to draw
  34533. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34534. */
  34535. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34536. /**
  34537. * Draw a list of points
  34538. * @param verticesStart defines the index of first vertex to draw
  34539. * @param verticesCount defines the count of vertices to draw
  34540. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34541. */
  34542. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34543. /**
  34544. * Draw a list of unindexed primitives
  34545. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34546. * @param verticesStart defines the index of first vertex to draw
  34547. * @param verticesCount defines the count of vertices to draw
  34548. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34549. */
  34550. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34551. /**
  34552. * Draw a list of indexed primitives
  34553. * @param fillMode defines the primitive to use
  34554. * @param indexStart defines the starting index
  34555. * @param indexCount defines the number of index to draw
  34556. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34557. */
  34558. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34559. /**
  34560. * Draw a list of unindexed primitives
  34561. * @param fillMode defines the primitive to use
  34562. * @param verticesStart defines the index of first vertex to draw
  34563. * @param verticesCount defines the count of vertices to draw
  34564. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34565. */
  34566. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34567. private _drawMode;
  34568. /** @hidden */
  34569. protected _reportDrawCall(): void;
  34570. /** @hidden */
  34571. _releaseEffect(effect: Effect): void;
  34572. /** @hidden */
  34573. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34574. /**
  34575. * Create a new effect (used to store vertex/fragment shaders)
  34576. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34577. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34578. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34579. * @param samplers defines an array of string used to represent textures
  34580. * @param defines defines the string containing the defines to use to compile the shaders
  34581. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34582. * @param onCompiled defines a function to call when the effect creation is successful
  34583. * @param onError defines a function to call when the effect creation has failed
  34584. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34585. * @returns the new Effect
  34586. */
  34587. 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;
  34588. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34589. private _compileShader;
  34590. private _compileRawShader;
  34591. /** @hidden */
  34592. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34593. /**
  34594. * Directly creates a webGL program
  34595. * @param pipelineContext defines the pipeline context to attach to
  34596. * @param vertexCode defines the vertex shader code to use
  34597. * @param fragmentCode defines the fragment shader code to use
  34598. * @param context defines the webGL context to use (if not set, the current one will be used)
  34599. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34600. * @returns the new webGL program
  34601. */
  34602. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34603. /**
  34604. * Creates a webGL program
  34605. * @param pipelineContext defines the pipeline context to attach to
  34606. * @param vertexCode defines the vertex shader code to use
  34607. * @param fragmentCode defines the fragment shader code to use
  34608. * @param defines defines the string containing the defines to use to compile the shaders
  34609. * @param context defines the webGL context to use (if not set, the current one will be used)
  34610. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34611. * @returns the new webGL program
  34612. */
  34613. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34614. /**
  34615. * Creates a new pipeline context
  34616. * @returns the new pipeline
  34617. */
  34618. createPipelineContext(): IPipelineContext;
  34619. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34620. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34621. /** @hidden */
  34622. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34623. /** @hidden */
  34624. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34625. /** @hidden */
  34626. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34627. /**
  34628. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34629. * @param pipelineContext defines the pipeline context to use
  34630. * @param uniformsNames defines the list of uniform names
  34631. * @returns an array of webGL uniform locations
  34632. */
  34633. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34634. /**
  34635. * Gets the lsit of active attributes for a given webGL program
  34636. * @param pipelineContext defines the pipeline context to use
  34637. * @param attributesNames defines the list of attribute names to get
  34638. * @returns an array of indices indicating the offset of each attribute
  34639. */
  34640. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34641. /**
  34642. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34643. * @param effect defines the effect to activate
  34644. */
  34645. enableEffect(effect: Nullable<Effect>): void;
  34646. /**
  34647. * Set the value of an uniform to a number (int)
  34648. * @param uniform defines the webGL uniform location where to store the value
  34649. * @param value defines the int number to store
  34650. */
  34651. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34652. /**
  34653. * Set the value of an uniform to an array of int32
  34654. * @param uniform defines the webGL uniform location where to store the value
  34655. * @param array defines the array of int32 to store
  34656. */
  34657. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34658. /**
  34659. * Set the value of an uniform to an array of int32 (stored as vec2)
  34660. * @param uniform defines the webGL uniform location where to store the value
  34661. * @param array defines the array of int32 to store
  34662. */
  34663. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34664. /**
  34665. * Set the value of an uniform to an array of int32 (stored as vec3)
  34666. * @param uniform defines the webGL uniform location where to store the value
  34667. * @param array defines the array of int32 to store
  34668. */
  34669. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34670. /**
  34671. * Set the value of an uniform to an array of int32 (stored as vec4)
  34672. * @param uniform defines the webGL uniform location where to store the value
  34673. * @param array defines the array of int32 to store
  34674. */
  34675. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34676. /**
  34677. * Set the value of an uniform to an array of number
  34678. * @param uniform defines the webGL uniform location where to store the value
  34679. * @param array defines the array of number to store
  34680. */
  34681. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34682. /**
  34683. * Set the value of an uniform to an array of number (stored as vec2)
  34684. * @param uniform defines the webGL uniform location where to store the value
  34685. * @param array defines the array of number to store
  34686. */
  34687. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34688. /**
  34689. * Set the value of an uniform to an array of number (stored as vec3)
  34690. * @param uniform defines the webGL uniform location where to store the value
  34691. * @param array defines the array of number to store
  34692. */
  34693. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34694. /**
  34695. * Set the value of an uniform to an array of number (stored as vec4)
  34696. * @param uniform defines the webGL uniform location where to store the value
  34697. * @param array defines the array of number to store
  34698. */
  34699. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34700. /**
  34701. * Set the value of an uniform to an array of float32 (stored as matrices)
  34702. * @param uniform defines the webGL uniform location where to store the value
  34703. * @param matrices defines the array of float32 to store
  34704. */
  34705. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34706. /**
  34707. * Set the value of an uniform to a matrix (3x3)
  34708. * @param uniform defines the webGL uniform location where to store the value
  34709. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34710. */
  34711. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34712. /**
  34713. * Set the value of an uniform to a matrix (2x2)
  34714. * @param uniform defines the webGL uniform location where to store the value
  34715. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34716. */
  34717. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34718. /**
  34719. * Set the value of an uniform to a number (float)
  34720. * @param uniform defines the webGL uniform location where to store the value
  34721. * @param value defines the float number to store
  34722. */
  34723. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34724. /**
  34725. * Set the value of an uniform to a vec2
  34726. * @param uniform defines the webGL uniform location where to store the value
  34727. * @param x defines the 1st component of the value
  34728. * @param y defines the 2nd component of the value
  34729. */
  34730. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34731. /**
  34732. * Set the value of an uniform to a vec3
  34733. * @param uniform defines the webGL uniform location where to store the value
  34734. * @param x defines the 1st component of the value
  34735. * @param y defines the 2nd component of the value
  34736. * @param z defines the 3rd component of the value
  34737. */
  34738. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34739. /**
  34740. * Set the value of an uniform to a vec4
  34741. * @param uniform defines the webGL uniform location where to store the value
  34742. * @param x defines the 1st component of the value
  34743. * @param y defines the 2nd component of the value
  34744. * @param z defines the 3rd component of the value
  34745. * @param w defines the 4th component of the value
  34746. */
  34747. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34748. /**
  34749. * Apply all cached states (depth, culling, stencil and alpha)
  34750. */
  34751. applyStates(): void;
  34752. /**
  34753. * Enable or disable color writing
  34754. * @param enable defines the state to set
  34755. */
  34756. setColorWrite(enable: boolean): void;
  34757. /**
  34758. * Gets a boolean indicating if color writing is enabled
  34759. * @returns the current color writing state
  34760. */
  34761. getColorWrite(): boolean;
  34762. /**
  34763. * Gets the depth culling state manager
  34764. */
  34765. get depthCullingState(): DepthCullingState;
  34766. /**
  34767. * Gets the alpha state manager
  34768. */
  34769. get alphaState(): AlphaState;
  34770. /**
  34771. * Gets the stencil state manager
  34772. */
  34773. get stencilState(): StencilState;
  34774. /**
  34775. * Clears the list of texture accessible through engine.
  34776. * This can help preventing texture load conflict due to name collision.
  34777. */
  34778. clearInternalTexturesCache(): void;
  34779. /**
  34780. * Force the entire cache to be cleared
  34781. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  34782. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  34783. */
  34784. wipeCaches(bruteForce?: boolean): void;
  34785. /** @hidden */
  34786. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  34787. min: number;
  34788. mag: number;
  34789. };
  34790. /** @hidden */
  34791. _createTexture(): WebGLTexture;
  34792. /**
  34793. * Usually called from Texture.ts.
  34794. * Passed information to create a WebGLTexture
  34795. * @param url defines a value which contains one of the following:
  34796. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  34797. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  34798. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  34799. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  34800. * @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)
  34801. * @param scene needed for loading to the correct scene
  34802. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  34803. * @param onLoad optional callback to be called upon successful completion
  34804. * @param onError optional callback to be called upon failure
  34805. * @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
  34806. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  34807. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  34808. * @param forcedExtension defines the extension to use to pick the right loader
  34809. * @param mimeType defines an optional mime type
  34810. * @returns a InternalTexture for assignment back into BABYLON.Texture
  34811. */
  34812. 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;
  34813. /**
  34814. * Loads an image as an HTMLImageElement.
  34815. * @param input url string, ArrayBuffer, or Blob to load
  34816. * @param onLoad callback called when the image successfully loads
  34817. * @param onError callback called when the image fails to load
  34818. * @param offlineProvider offline provider for caching
  34819. * @param mimeType optional mime type
  34820. * @returns the HTMLImageElement of the loaded image
  34821. * @hidden
  34822. */
  34823. 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>;
  34824. /**
  34825. * @hidden
  34826. */
  34827. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34828. private _unpackFlipYCached;
  34829. /**
  34830. * In case you are sharing the context with other applications, it might
  34831. * be interested to not cache the unpack flip y state to ensure a consistent
  34832. * value would be set.
  34833. */
  34834. enableUnpackFlipYCached: boolean;
  34835. /** @hidden */
  34836. _unpackFlipY(value: boolean): void;
  34837. /** @hidden */
  34838. _getUnpackAlignement(): number;
  34839. private _getTextureTarget;
  34840. /**
  34841. * Update the sampling mode of a given texture
  34842. * @param samplingMode defines the required sampling mode
  34843. * @param texture defines the texture to update
  34844. * @param generateMipMaps defines whether to generate mipmaps for the texture
  34845. */
  34846. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  34847. /**
  34848. * Update the sampling mode of a given texture
  34849. * @param texture defines the texture to update
  34850. * @param wrapU defines the texture wrap mode of the u coordinates
  34851. * @param wrapV defines the texture wrap mode of the v coordinates
  34852. * @param wrapR defines the texture wrap mode of the r coordinates
  34853. */
  34854. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  34855. /** @hidden */
  34856. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  34857. width: number;
  34858. height: number;
  34859. layers?: number;
  34860. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  34861. /** @hidden */
  34862. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34863. /** @hidden */
  34864. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  34865. /**
  34866. * Update a portion of an internal texture
  34867. * @param texture defines the texture to update
  34868. * @param imageData defines the data to store into the texture
  34869. * @param xOffset defines the x coordinates of the update rectangle
  34870. * @param yOffset defines the y coordinates of the update rectangle
  34871. * @param width defines the width of the update rectangle
  34872. * @param height defines the height of the update rectangle
  34873. * @param faceIndex defines the face index if texture is a cube (0 by default)
  34874. * @param lod defines the lod level to update (0 by default)
  34875. */
  34876. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  34877. /** @hidden */
  34878. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34879. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  34880. private _prepareWebGLTexture;
  34881. /** @hidden */
  34882. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  34883. private _getDepthStencilBuffer;
  34884. /** @hidden */
  34885. _releaseFramebufferObjects(texture: InternalTexture): void;
  34886. /** @hidden */
  34887. _releaseTexture(texture: InternalTexture): void;
  34888. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  34889. protected _setProgram(program: WebGLProgram): void;
  34890. protected _boundUniforms: {
  34891. [key: number]: WebGLUniformLocation;
  34892. };
  34893. /**
  34894. * Binds an effect to the webGL context
  34895. * @param effect defines the effect to bind
  34896. */
  34897. bindSamplers(effect: Effect): void;
  34898. private _activateCurrentTexture;
  34899. /** @hidden */
  34900. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  34901. /** @hidden */
  34902. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  34903. /**
  34904. * Unbind all textures from the webGL context
  34905. */
  34906. unbindAllTextures(): void;
  34907. /**
  34908. * Sets a texture to the according uniform.
  34909. * @param channel The texture channel
  34910. * @param uniform The uniform to set
  34911. * @param texture The texture to apply
  34912. */
  34913. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  34914. private _bindSamplerUniformToChannel;
  34915. private _getTextureWrapMode;
  34916. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  34917. /**
  34918. * Sets an array of texture to the webGL context
  34919. * @param channel defines the channel where the texture array must be set
  34920. * @param uniform defines the associated uniform location
  34921. * @param textures defines the array of textures to bind
  34922. */
  34923. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  34924. /** @hidden */
  34925. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  34926. private _setTextureParameterFloat;
  34927. private _setTextureParameterInteger;
  34928. /**
  34929. * Unbind all vertex attributes from the webGL context
  34930. */
  34931. unbindAllAttributes(): void;
  34932. /**
  34933. * 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
  34934. */
  34935. releaseEffects(): void;
  34936. /**
  34937. * Dispose and release all associated resources
  34938. */
  34939. dispose(): void;
  34940. /**
  34941. * Attach a new callback raised when context lost event is fired
  34942. * @param callback defines the callback to call
  34943. */
  34944. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  34945. /**
  34946. * Attach a new callback raised when context restored event is fired
  34947. * @param callback defines the callback to call
  34948. */
  34949. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  34950. /**
  34951. * Get the current error code of the webGL context
  34952. * @returns the error code
  34953. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34954. */
  34955. getError(): number;
  34956. private _canRenderToFloatFramebuffer;
  34957. private _canRenderToHalfFloatFramebuffer;
  34958. private _canRenderToFramebuffer;
  34959. /** @hidden */
  34960. _getWebGLTextureType(type: number): number;
  34961. /** @hidden */
  34962. _getInternalFormat(format: number): number;
  34963. /** @hidden */
  34964. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  34965. /** @hidden */
  34966. _getRGBAMultiSampleBufferFormat(type: number): number;
  34967. /** @hidden */
  34968. _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;
  34969. /**
  34970. * Loads a file from a url
  34971. * @param url url to load
  34972. * @param onSuccess callback called when the file successfully loads
  34973. * @param onProgress callback called while file is loading (if the server supports this mode)
  34974. * @param offlineProvider defines the offline provider for caching
  34975. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34976. * @param onError callback called when the file fails to load
  34977. * @returns a file request object
  34978. * @hidden
  34979. */
  34980. 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;
  34981. /**
  34982. * Reads pixels from the current frame buffer. Please note that this function can be slow
  34983. * @param x defines the x coordinate of the rectangle where pixels must be read
  34984. * @param y defines the y coordinate of the rectangle where pixels must be read
  34985. * @param width defines the width of the rectangle where pixels must be read
  34986. * @param height defines the height of the rectangle where pixels must be read
  34987. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  34988. * @returns a Uint8Array containing RGBA colors
  34989. */
  34990. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  34991. private static _isSupported;
  34992. /**
  34993. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  34994. * @returns true if the engine can be created
  34995. * @ignorenaming
  34996. */
  34997. static isSupported(): boolean;
  34998. /**
  34999. * Find the next highest power of two.
  35000. * @param x Number to start search from.
  35001. * @return Next highest power of two.
  35002. */
  35003. static CeilingPOT(x: number): number;
  35004. /**
  35005. * Find the next lowest power of two.
  35006. * @param x Number to start search from.
  35007. * @return Next lowest power of two.
  35008. */
  35009. static FloorPOT(x: number): number;
  35010. /**
  35011. * Find the nearest power of two.
  35012. * @param x Number to start search from.
  35013. * @return Next nearest power of two.
  35014. */
  35015. static NearestPOT(x: number): number;
  35016. /**
  35017. * Get the closest exponent of two
  35018. * @param value defines the value to approximate
  35019. * @param max defines the maximum value to return
  35020. * @param mode defines how to define the closest value
  35021. * @returns closest exponent of two of the given value
  35022. */
  35023. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35024. /**
  35025. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35026. * @param func - the function to be called
  35027. * @param requester - the object that will request the next frame. Falls back to window.
  35028. * @returns frame number
  35029. */
  35030. static QueueNewFrame(func: () => void, requester?: any): number;
  35031. /**
  35032. * Gets host document
  35033. * @returns the host document object
  35034. */
  35035. getHostDocument(): Nullable<Document>;
  35036. }
  35037. }
  35038. declare module BABYLON {
  35039. /**
  35040. * Class representing spherical harmonics coefficients to the 3rd degree
  35041. */
  35042. export class SphericalHarmonics {
  35043. /**
  35044. * Defines whether or not the harmonics have been prescaled for rendering.
  35045. */
  35046. preScaled: boolean;
  35047. /**
  35048. * The l0,0 coefficients of the spherical harmonics
  35049. */
  35050. l00: Vector3;
  35051. /**
  35052. * The l1,-1 coefficients of the spherical harmonics
  35053. */
  35054. l1_1: Vector3;
  35055. /**
  35056. * The l1,0 coefficients of the spherical harmonics
  35057. */
  35058. l10: Vector3;
  35059. /**
  35060. * The l1,1 coefficients of the spherical harmonics
  35061. */
  35062. l11: Vector3;
  35063. /**
  35064. * The l2,-2 coefficients of the spherical harmonics
  35065. */
  35066. l2_2: Vector3;
  35067. /**
  35068. * The l2,-1 coefficients of the spherical harmonics
  35069. */
  35070. l2_1: Vector3;
  35071. /**
  35072. * The l2,0 coefficients of the spherical harmonics
  35073. */
  35074. l20: Vector3;
  35075. /**
  35076. * The l2,1 coefficients of the spherical harmonics
  35077. */
  35078. l21: Vector3;
  35079. /**
  35080. * The l2,2 coefficients of the spherical harmonics
  35081. */
  35082. l22: Vector3;
  35083. /**
  35084. * Adds a light to the spherical harmonics
  35085. * @param direction the direction of the light
  35086. * @param color the color of the light
  35087. * @param deltaSolidAngle the delta solid angle of the light
  35088. */
  35089. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35090. /**
  35091. * Scales the spherical harmonics by the given amount
  35092. * @param scale the amount to scale
  35093. */
  35094. scaleInPlace(scale: number): void;
  35095. /**
  35096. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35097. *
  35098. * ```
  35099. * E_lm = A_l * L_lm
  35100. * ```
  35101. *
  35102. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35103. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35104. * the scaling factors are given in equation 9.
  35105. */
  35106. convertIncidentRadianceToIrradiance(): void;
  35107. /**
  35108. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35109. *
  35110. * ```
  35111. * L = (1/pi) * E * rho
  35112. * ```
  35113. *
  35114. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35115. */
  35116. convertIrradianceToLambertianRadiance(): void;
  35117. /**
  35118. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35119. * required operations at run time.
  35120. *
  35121. * This is simply done by scaling back the SH with Ylm constants parameter.
  35122. * The trigonometric part being applied by the shader at run time.
  35123. */
  35124. preScaleForRendering(): void;
  35125. /**
  35126. * Constructs a spherical harmonics from an array.
  35127. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35128. * @returns the spherical harmonics
  35129. */
  35130. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35131. /**
  35132. * Gets the spherical harmonics from polynomial
  35133. * @param polynomial the spherical polynomial
  35134. * @returns the spherical harmonics
  35135. */
  35136. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35137. }
  35138. /**
  35139. * Class representing spherical polynomial coefficients to the 3rd degree
  35140. */
  35141. export class SphericalPolynomial {
  35142. private _harmonics;
  35143. /**
  35144. * The spherical harmonics used to create the polynomials.
  35145. */
  35146. get preScaledHarmonics(): SphericalHarmonics;
  35147. /**
  35148. * The x coefficients of the spherical polynomial
  35149. */
  35150. x: Vector3;
  35151. /**
  35152. * The y coefficients of the spherical polynomial
  35153. */
  35154. y: Vector3;
  35155. /**
  35156. * The z coefficients of the spherical polynomial
  35157. */
  35158. z: Vector3;
  35159. /**
  35160. * The xx coefficients of the spherical polynomial
  35161. */
  35162. xx: Vector3;
  35163. /**
  35164. * The yy coefficients of the spherical polynomial
  35165. */
  35166. yy: Vector3;
  35167. /**
  35168. * The zz coefficients of the spherical polynomial
  35169. */
  35170. zz: Vector3;
  35171. /**
  35172. * The xy coefficients of the spherical polynomial
  35173. */
  35174. xy: Vector3;
  35175. /**
  35176. * The yz coefficients of the spherical polynomial
  35177. */
  35178. yz: Vector3;
  35179. /**
  35180. * The zx coefficients of the spherical polynomial
  35181. */
  35182. zx: Vector3;
  35183. /**
  35184. * Adds an ambient color to the spherical polynomial
  35185. * @param color the color to add
  35186. */
  35187. addAmbient(color: Color3): void;
  35188. /**
  35189. * Scales the spherical polynomial by the given amount
  35190. * @param scale the amount to scale
  35191. */
  35192. scaleInPlace(scale: number): void;
  35193. /**
  35194. * Gets the spherical polynomial from harmonics
  35195. * @param harmonics the spherical harmonics
  35196. * @returns the spherical polynomial
  35197. */
  35198. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35199. /**
  35200. * Constructs a spherical polynomial from an array.
  35201. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35202. * @returns the spherical polynomial
  35203. */
  35204. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35205. }
  35206. }
  35207. declare module BABYLON {
  35208. /**
  35209. * Defines the source of the internal texture
  35210. */
  35211. export enum InternalTextureSource {
  35212. /**
  35213. * The source of the texture data is unknown
  35214. */
  35215. Unknown = 0,
  35216. /**
  35217. * Texture data comes from an URL
  35218. */
  35219. Url = 1,
  35220. /**
  35221. * Texture data is only used for temporary storage
  35222. */
  35223. Temp = 2,
  35224. /**
  35225. * Texture data comes from raw data (ArrayBuffer)
  35226. */
  35227. Raw = 3,
  35228. /**
  35229. * Texture content is dynamic (video or dynamic texture)
  35230. */
  35231. Dynamic = 4,
  35232. /**
  35233. * Texture content is generated by rendering to it
  35234. */
  35235. RenderTarget = 5,
  35236. /**
  35237. * Texture content is part of a multi render target process
  35238. */
  35239. MultiRenderTarget = 6,
  35240. /**
  35241. * Texture data comes from a cube data file
  35242. */
  35243. Cube = 7,
  35244. /**
  35245. * Texture data comes from a raw cube data
  35246. */
  35247. CubeRaw = 8,
  35248. /**
  35249. * Texture data come from a prefiltered cube data file
  35250. */
  35251. CubePrefiltered = 9,
  35252. /**
  35253. * Texture content is raw 3D data
  35254. */
  35255. Raw3D = 10,
  35256. /**
  35257. * Texture content is raw 2D array data
  35258. */
  35259. Raw2DArray = 11,
  35260. /**
  35261. * Texture content is a depth texture
  35262. */
  35263. Depth = 12,
  35264. /**
  35265. * Texture data comes from a raw cube data encoded with RGBD
  35266. */
  35267. CubeRawRGBD = 13
  35268. }
  35269. /**
  35270. * Class used to store data associated with WebGL texture data for the engine
  35271. * This class should not be used directly
  35272. */
  35273. export class InternalTexture {
  35274. /** @hidden */
  35275. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35276. /**
  35277. * Defines if the texture is ready
  35278. */
  35279. isReady: boolean;
  35280. /**
  35281. * Defines if the texture is a cube texture
  35282. */
  35283. isCube: boolean;
  35284. /**
  35285. * Defines if the texture contains 3D data
  35286. */
  35287. is3D: boolean;
  35288. /**
  35289. * Defines if the texture contains 2D array data
  35290. */
  35291. is2DArray: boolean;
  35292. /**
  35293. * Defines if the texture contains multiview data
  35294. */
  35295. isMultiview: boolean;
  35296. /**
  35297. * Gets the URL used to load this texture
  35298. */
  35299. url: string;
  35300. /**
  35301. * Gets the sampling mode of the texture
  35302. */
  35303. samplingMode: number;
  35304. /**
  35305. * Gets a boolean indicating if the texture needs mipmaps generation
  35306. */
  35307. generateMipMaps: boolean;
  35308. /**
  35309. * Gets the number of samples used by the texture (WebGL2+ only)
  35310. */
  35311. samples: number;
  35312. /**
  35313. * Gets the type of the texture (int, float...)
  35314. */
  35315. type: number;
  35316. /**
  35317. * Gets the format of the texture (RGB, RGBA...)
  35318. */
  35319. format: number;
  35320. /**
  35321. * Observable called when the texture is loaded
  35322. */
  35323. onLoadedObservable: Observable<InternalTexture>;
  35324. /**
  35325. * Gets the width of the texture
  35326. */
  35327. width: number;
  35328. /**
  35329. * Gets the height of the texture
  35330. */
  35331. height: number;
  35332. /**
  35333. * Gets the depth of the texture
  35334. */
  35335. depth: number;
  35336. /**
  35337. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35338. */
  35339. baseWidth: number;
  35340. /**
  35341. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35342. */
  35343. baseHeight: number;
  35344. /**
  35345. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35346. */
  35347. baseDepth: number;
  35348. /**
  35349. * Gets a boolean indicating if the texture is inverted on Y axis
  35350. */
  35351. invertY: boolean;
  35352. /** @hidden */
  35353. _invertVScale: boolean;
  35354. /** @hidden */
  35355. _associatedChannel: number;
  35356. /** @hidden */
  35357. _source: InternalTextureSource;
  35358. /** @hidden */
  35359. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35360. /** @hidden */
  35361. _bufferView: Nullable<ArrayBufferView>;
  35362. /** @hidden */
  35363. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35364. /** @hidden */
  35365. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35366. /** @hidden */
  35367. _size: number;
  35368. /** @hidden */
  35369. _extension: string;
  35370. /** @hidden */
  35371. _files: Nullable<string[]>;
  35372. /** @hidden */
  35373. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35374. /** @hidden */
  35375. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35376. /** @hidden */
  35377. _framebuffer: Nullable<WebGLFramebuffer>;
  35378. /** @hidden */
  35379. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35380. /** @hidden */
  35381. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35382. /** @hidden */
  35383. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35384. /** @hidden */
  35385. _attachments: Nullable<number[]>;
  35386. /** @hidden */
  35387. _cachedCoordinatesMode: Nullable<number>;
  35388. /** @hidden */
  35389. _cachedWrapU: Nullable<number>;
  35390. /** @hidden */
  35391. _cachedWrapV: Nullable<number>;
  35392. /** @hidden */
  35393. _cachedWrapR: Nullable<number>;
  35394. /** @hidden */
  35395. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35396. /** @hidden */
  35397. _isDisabled: boolean;
  35398. /** @hidden */
  35399. _compression: Nullable<string>;
  35400. /** @hidden */
  35401. _generateStencilBuffer: boolean;
  35402. /** @hidden */
  35403. _generateDepthBuffer: boolean;
  35404. /** @hidden */
  35405. _comparisonFunction: number;
  35406. /** @hidden */
  35407. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35408. /** @hidden */
  35409. _lodGenerationScale: number;
  35410. /** @hidden */
  35411. _lodGenerationOffset: number;
  35412. /** @hidden */
  35413. _depthStencilTexture: Nullable<InternalTexture>;
  35414. /** @hidden */
  35415. _colorTextureArray: Nullable<WebGLTexture>;
  35416. /** @hidden */
  35417. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35418. /** @hidden */
  35419. _lodTextureHigh: Nullable<BaseTexture>;
  35420. /** @hidden */
  35421. _lodTextureMid: Nullable<BaseTexture>;
  35422. /** @hidden */
  35423. _lodTextureLow: Nullable<BaseTexture>;
  35424. /** @hidden */
  35425. _isRGBD: boolean;
  35426. /** @hidden */
  35427. _linearSpecularLOD: boolean;
  35428. /** @hidden */
  35429. _irradianceTexture: Nullable<BaseTexture>;
  35430. /** @hidden */
  35431. _webGLTexture: Nullable<WebGLTexture>;
  35432. /** @hidden */
  35433. _references: number;
  35434. private _engine;
  35435. /**
  35436. * Gets the Engine the texture belongs to.
  35437. * @returns The babylon engine
  35438. */
  35439. getEngine(): ThinEngine;
  35440. /**
  35441. * Gets the data source type of the texture
  35442. */
  35443. get source(): InternalTextureSource;
  35444. /**
  35445. * Creates a new InternalTexture
  35446. * @param engine defines the engine to use
  35447. * @param source defines the type of data that will be used
  35448. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35449. */
  35450. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35451. /**
  35452. * Increments the number of references (ie. the number of Texture that point to it)
  35453. */
  35454. incrementReferences(): void;
  35455. /**
  35456. * Change the size of the texture (not the size of the content)
  35457. * @param width defines the new width
  35458. * @param height defines the new height
  35459. * @param depth defines the new depth (1 by default)
  35460. */
  35461. updateSize(width: int, height: int, depth?: int): void;
  35462. /** @hidden */
  35463. _rebuild(): void;
  35464. /** @hidden */
  35465. _swapAndDie(target: InternalTexture): void;
  35466. /**
  35467. * Dispose the current allocated resources
  35468. */
  35469. dispose(): void;
  35470. }
  35471. }
  35472. declare module BABYLON {
  35473. /**
  35474. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35476. */
  35477. export class Analyser {
  35478. /**
  35479. * Gets or sets the smoothing
  35480. * @ignorenaming
  35481. */
  35482. SMOOTHING: number;
  35483. /**
  35484. * Gets or sets the FFT table size
  35485. * @ignorenaming
  35486. */
  35487. FFT_SIZE: number;
  35488. /**
  35489. * Gets or sets the bar graph amplitude
  35490. * @ignorenaming
  35491. */
  35492. BARGRAPHAMPLITUDE: number;
  35493. /**
  35494. * Gets or sets the position of the debug canvas
  35495. * @ignorenaming
  35496. */
  35497. DEBUGCANVASPOS: {
  35498. x: number;
  35499. y: number;
  35500. };
  35501. /**
  35502. * Gets or sets the debug canvas size
  35503. * @ignorenaming
  35504. */
  35505. DEBUGCANVASSIZE: {
  35506. width: number;
  35507. height: number;
  35508. };
  35509. private _byteFreqs;
  35510. private _byteTime;
  35511. private _floatFreqs;
  35512. private _webAudioAnalyser;
  35513. private _debugCanvas;
  35514. private _debugCanvasContext;
  35515. private _scene;
  35516. private _registerFunc;
  35517. private _audioEngine;
  35518. /**
  35519. * Creates a new analyser
  35520. * @param scene defines hosting scene
  35521. */
  35522. constructor(scene: Scene);
  35523. /**
  35524. * Get the number of data values you will have to play with for the visualization
  35525. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35526. * @returns a number
  35527. */
  35528. getFrequencyBinCount(): number;
  35529. /**
  35530. * Gets the current frequency data as a byte array
  35531. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35532. * @returns a Uint8Array
  35533. */
  35534. getByteFrequencyData(): Uint8Array;
  35535. /**
  35536. * Gets the current waveform as a byte array
  35537. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35538. * @returns a Uint8Array
  35539. */
  35540. getByteTimeDomainData(): Uint8Array;
  35541. /**
  35542. * Gets the current frequency data as a float array
  35543. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35544. * @returns a Float32Array
  35545. */
  35546. getFloatFrequencyData(): Float32Array;
  35547. /**
  35548. * Renders the debug canvas
  35549. */
  35550. drawDebugCanvas(): void;
  35551. /**
  35552. * Stops rendering the debug canvas and removes it
  35553. */
  35554. stopDebugCanvas(): void;
  35555. /**
  35556. * Connects two audio nodes
  35557. * @param inputAudioNode defines first node to connect
  35558. * @param outputAudioNode defines second node to connect
  35559. */
  35560. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35561. /**
  35562. * Releases all associated resources
  35563. */
  35564. dispose(): void;
  35565. }
  35566. }
  35567. declare module BABYLON {
  35568. /**
  35569. * This represents an audio engine and it is responsible
  35570. * to play, synchronize and analyse sounds throughout the application.
  35571. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35572. */
  35573. export interface IAudioEngine extends IDisposable {
  35574. /**
  35575. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35576. */
  35577. readonly canUseWebAudio: boolean;
  35578. /**
  35579. * Gets the current AudioContext if available.
  35580. */
  35581. readonly audioContext: Nullable<AudioContext>;
  35582. /**
  35583. * The master gain node defines the global audio volume of your audio engine.
  35584. */
  35585. readonly masterGain: GainNode;
  35586. /**
  35587. * Gets whether or not mp3 are supported by your browser.
  35588. */
  35589. readonly isMP3supported: boolean;
  35590. /**
  35591. * Gets whether or not ogg are supported by your browser.
  35592. */
  35593. readonly isOGGsupported: boolean;
  35594. /**
  35595. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35596. * @ignoreNaming
  35597. */
  35598. WarnedWebAudioUnsupported: boolean;
  35599. /**
  35600. * Defines if the audio engine relies on a custom unlocked button.
  35601. * In this case, the embedded button will not be displayed.
  35602. */
  35603. useCustomUnlockedButton: boolean;
  35604. /**
  35605. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35606. */
  35607. readonly unlocked: boolean;
  35608. /**
  35609. * Event raised when audio has been unlocked on the browser.
  35610. */
  35611. onAudioUnlockedObservable: Observable<AudioEngine>;
  35612. /**
  35613. * Event raised when audio has been locked on the browser.
  35614. */
  35615. onAudioLockedObservable: Observable<AudioEngine>;
  35616. /**
  35617. * Flags the audio engine in Locked state.
  35618. * This happens due to new browser policies preventing audio to autoplay.
  35619. */
  35620. lock(): void;
  35621. /**
  35622. * Unlocks the audio engine once a user action has been done on the dom.
  35623. * This is helpful to resume play once browser policies have been satisfied.
  35624. */
  35625. unlock(): void;
  35626. /**
  35627. * Gets the global volume sets on the master gain.
  35628. * @returns the global volume if set or -1 otherwise
  35629. */
  35630. getGlobalVolume(): number;
  35631. /**
  35632. * Sets the global volume of your experience (sets on the master gain).
  35633. * @param newVolume Defines the new global volume of the application
  35634. */
  35635. setGlobalVolume(newVolume: number): void;
  35636. /**
  35637. * Connect the audio engine to an audio analyser allowing some amazing
  35638. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35640. * @param analyser The analyser to connect to the engine
  35641. */
  35642. connectToAnalyser(analyser: Analyser): void;
  35643. }
  35644. /**
  35645. * This represents the default audio engine used in babylon.
  35646. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35648. */
  35649. export class AudioEngine implements IAudioEngine {
  35650. private _audioContext;
  35651. private _audioContextInitialized;
  35652. private _muteButton;
  35653. private _hostElement;
  35654. /**
  35655. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35656. */
  35657. canUseWebAudio: boolean;
  35658. /**
  35659. * The master gain node defines the global audio volume of your audio engine.
  35660. */
  35661. masterGain: GainNode;
  35662. /**
  35663. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35664. * @ignoreNaming
  35665. */
  35666. WarnedWebAudioUnsupported: boolean;
  35667. /**
  35668. * Gets whether or not mp3 are supported by your browser.
  35669. */
  35670. isMP3supported: boolean;
  35671. /**
  35672. * Gets whether or not ogg are supported by your browser.
  35673. */
  35674. isOGGsupported: boolean;
  35675. /**
  35676. * Gets whether audio has been unlocked on the device.
  35677. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35678. * a user interaction has happened.
  35679. */
  35680. unlocked: boolean;
  35681. /**
  35682. * Defines if the audio engine relies on a custom unlocked button.
  35683. * In this case, the embedded button will not be displayed.
  35684. */
  35685. useCustomUnlockedButton: boolean;
  35686. /**
  35687. * Event raised when audio has been unlocked on the browser.
  35688. */
  35689. onAudioUnlockedObservable: Observable<AudioEngine>;
  35690. /**
  35691. * Event raised when audio has been locked on the browser.
  35692. */
  35693. onAudioLockedObservable: Observable<AudioEngine>;
  35694. /**
  35695. * Gets the current AudioContext if available.
  35696. */
  35697. get audioContext(): Nullable<AudioContext>;
  35698. private _connectedAnalyser;
  35699. /**
  35700. * Instantiates a new audio engine.
  35701. *
  35702. * There should be only one per page as some browsers restrict the number
  35703. * of audio contexts you can create.
  35704. * @param hostElement defines the host element where to display the mute icon if necessary
  35705. */
  35706. constructor(hostElement?: Nullable<HTMLElement>);
  35707. /**
  35708. * Flags the audio engine in Locked state.
  35709. * This happens due to new browser policies preventing audio to autoplay.
  35710. */
  35711. lock(): void;
  35712. /**
  35713. * Unlocks the audio engine once a user action has been done on the dom.
  35714. * This is helpful to resume play once browser policies have been satisfied.
  35715. */
  35716. unlock(): void;
  35717. private _resumeAudioContext;
  35718. private _initializeAudioContext;
  35719. private _tryToRun;
  35720. private _triggerRunningState;
  35721. private _triggerSuspendedState;
  35722. private _displayMuteButton;
  35723. private _moveButtonToTopLeft;
  35724. private _onResize;
  35725. private _hideMuteButton;
  35726. /**
  35727. * Destroy and release the resources associated with the audio ccontext.
  35728. */
  35729. dispose(): void;
  35730. /**
  35731. * Gets the global volume sets on the master gain.
  35732. * @returns the global volume if set or -1 otherwise
  35733. */
  35734. getGlobalVolume(): number;
  35735. /**
  35736. * Sets the global volume of your experience (sets on the master gain).
  35737. * @param newVolume Defines the new global volume of the application
  35738. */
  35739. setGlobalVolume(newVolume: number): void;
  35740. /**
  35741. * Connect the audio engine to an audio analyser allowing some amazing
  35742. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35744. * @param analyser The analyser to connect to the engine
  35745. */
  35746. connectToAnalyser(analyser: Analyser): void;
  35747. }
  35748. }
  35749. declare module BABYLON {
  35750. /**
  35751. * Interface used to present a loading screen while loading a scene
  35752. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35753. */
  35754. export interface ILoadingScreen {
  35755. /**
  35756. * Function called to display the loading screen
  35757. */
  35758. displayLoadingUI: () => void;
  35759. /**
  35760. * Function called to hide the loading screen
  35761. */
  35762. hideLoadingUI: () => void;
  35763. /**
  35764. * Gets or sets the color to use for the background
  35765. */
  35766. loadingUIBackgroundColor: string;
  35767. /**
  35768. * Gets or sets the text to display while loading
  35769. */
  35770. loadingUIText: string;
  35771. }
  35772. /**
  35773. * Class used for the default loading screen
  35774. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35775. */
  35776. export class DefaultLoadingScreen implements ILoadingScreen {
  35777. private _renderingCanvas;
  35778. private _loadingText;
  35779. private _loadingDivBackgroundColor;
  35780. private _loadingDiv;
  35781. private _loadingTextDiv;
  35782. /** Gets or sets the logo url to use for the default loading screen */
  35783. static DefaultLogoUrl: string;
  35784. /** Gets or sets the spinner url to use for the default loading screen */
  35785. static DefaultSpinnerUrl: string;
  35786. /**
  35787. * Creates a new default loading screen
  35788. * @param _renderingCanvas defines the canvas used to render the scene
  35789. * @param _loadingText defines the default text to display
  35790. * @param _loadingDivBackgroundColor defines the default background color
  35791. */
  35792. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  35793. /**
  35794. * Function called to display the loading screen
  35795. */
  35796. displayLoadingUI(): void;
  35797. /**
  35798. * Function called to hide the loading screen
  35799. */
  35800. hideLoadingUI(): void;
  35801. /**
  35802. * Gets or sets the text to display while loading
  35803. */
  35804. set loadingUIText(text: string);
  35805. get loadingUIText(): string;
  35806. /**
  35807. * Gets or sets the color to use for the background
  35808. */
  35809. get loadingUIBackgroundColor(): string;
  35810. set loadingUIBackgroundColor(color: string);
  35811. private _resizeLoadingUI;
  35812. }
  35813. }
  35814. declare module BABYLON {
  35815. /**
  35816. * Interface for any object that can request an animation frame
  35817. */
  35818. export interface ICustomAnimationFrameRequester {
  35819. /**
  35820. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  35821. */
  35822. renderFunction?: Function;
  35823. /**
  35824. * Called to request the next frame to render to
  35825. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  35826. */
  35827. requestAnimationFrame: Function;
  35828. /**
  35829. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  35830. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  35831. */
  35832. requestID?: number;
  35833. }
  35834. }
  35835. declare module BABYLON {
  35836. /**
  35837. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  35838. */
  35839. export class PerformanceMonitor {
  35840. private _enabled;
  35841. private _rollingFrameTime;
  35842. private _lastFrameTimeMs;
  35843. /**
  35844. * constructor
  35845. * @param frameSampleSize The number of samples required to saturate the sliding window
  35846. */
  35847. constructor(frameSampleSize?: number);
  35848. /**
  35849. * Samples current frame
  35850. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  35851. */
  35852. sampleFrame(timeMs?: number): void;
  35853. /**
  35854. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35855. */
  35856. get averageFrameTime(): number;
  35857. /**
  35858. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35859. */
  35860. get averageFrameTimeVariance(): number;
  35861. /**
  35862. * Returns the frame time of the most recent frame
  35863. */
  35864. get instantaneousFrameTime(): number;
  35865. /**
  35866. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  35867. */
  35868. get averageFPS(): number;
  35869. /**
  35870. * Returns the average framerate in frames per second using the most recent frame time
  35871. */
  35872. get instantaneousFPS(): number;
  35873. /**
  35874. * Returns true if enough samples have been taken to completely fill the sliding window
  35875. */
  35876. get isSaturated(): boolean;
  35877. /**
  35878. * Enables contributions to the sliding window sample set
  35879. */
  35880. enable(): void;
  35881. /**
  35882. * Disables contributions to the sliding window sample set
  35883. * Samples will not be interpolated over the disabled period
  35884. */
  35885. disable(): void;
  35886. /**
  35887. * Returns true if sampling is enabled
  35888. */
  35889. get isEnabled(): boolean;
  35890. /**
  35891. * Resets performance monitor
  35892. */
  35893. reset(): void;
  35894. }
  35895. /**
  35896. * RollingAverage
  35897. *
  35898. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  35899. */
  35900. export class RollingAverage {
  35901. /**
  35902. * Current average
  35903. */
  35904. average: number;
  35905. /**
  35906. * Current variance
  35907. */
  35908. variance: number;
  35909. protected _samples: Array<number>;
  35910. protected _sampleCount: number;
  35911. protected _pos: number;
  35912. protected _m2: number;
  35913. /**
  35914. * constructor
  35915. * @param length The number of samples required to saturate the sliding window
  35916. */
  35917. constructor(length: number);
  35918. /**
  35919. * Adds a sample to the sample set
  35920. * @param v The sample value
  35921. */
  35922. add(v: number): void;
  35923. /**
  35924. * Returns previously added values or null if outside of history or outside the sliding window domain
  35925. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  35926. * @return Value previously recorded with add() or null if outside of range
  35927. */
  35928. history(i: number): number;
  35929. /**
  35930. * Returns true if enough samples have been taken to completely fill the sliding window
  35931. * @return true if sample-set saturated
  35932. */
  35933. isSaturated(): boolean;
  35934. /**
  35935. * Resets the rolling average (equivalent to 0 samples taken so far)
  35936. */
  35937. reset(): void;
  35938. /**
  35939. * Wraps a value around the sample range boundaries
  35940. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  35941. * @return Wrapped position in sample range
  35942. */
  35943. protected _wrapPosition(i: number): number;
  35944. }
  35945. }
  35946. declare module BABYLON {
  35947. /**
  35948. * This class is used to track a performance counter which is number based.
  35949. * The user has access to many properties which give statistics of different nature.
  35950. *
  35951. * The implementer can track two kinds of Performance Counter: time and count.
  35952. * 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.
  35953. * 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.
  35954. */
  35955. export class PerfCounter {
  35956. /**
  35957. * Gets or sets a global boolean to turn on and off all the counters
  35958. */
  35959. static Enabled: boolean;
  35960. /**
  35961. * Returns the smallest value ever
  35962. */
  35963. get min(): number;
  35964. /**
  35965. * Returns the biggest value ever
  35966. */
  35967. get max(): number;
  35968. /**
  35969. * Returns the average value since the performance counter is running
  35970. */
  35971. get average(): number;
  35972. /**
  35973. * Returns the average value of the last second the counter was monitored
  35974. */
  35975. get lastSecAverage(): number;
  35976. /**
  35977. * Returns the current value
  35978. */
  35979. get current(): number;
  35980. /**
  35981. * Gets the accumulated total
  35982. */
  35983. get total(): number;
  35984. /**
  35985. * Gets the total value count
  35986. */
  35987. get count(): number;
  35988. /**
  35989. * Creates a new counter
  35990. */
  35991. constructor();
  35992. /**
  35993. * Call this method to start monitoring a new frame.
  35994. * 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.
  35995. */
  35996. fetchNewFrame(): void;
  35997. /**
  35998. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  35999. * @param newCount the count value to add to the monitored count
  36000. * @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.
  36001. */
  36002. addCount(newCount: number, fetchResult: boolean): void;
  36003. /**
  36004. * Start monitoring this performance counter
  36005. */
  36006. beginMonitoring(): void;
  36007. /**
  36008. * Compute the time lapsed since the previous beginMonitoring() call.
  36009. * @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
  36010. */
  36011. endMonitoring(newFrame?: boolean): void;
  36012. private _fetchResult;
  36013. private _startMonitoringTime;
  36014. private _min;
  36015. private _max;
  36016. private _average;
  36017. private _current;
  36018. private _totalValueCount;
  36019. private _totalAccumulated;
  36020. private _lastSecAverage;
  36021. private _lastSecAccumulated;
  36022. private _lastSecTime;
  36023. private _lastSecValueCount;
  36024. }
  36025. }
  36026. declare module BABYLON {
  36027. interface ThinEngine {
  36028. /**
  36029. * Sets alpha constants used by some alpha blending modes
  36030. * @param r defines the red component
  36031. * @param g defines the green component
  36032. * @param b defines the blue component
  36033. * @param a defines the alpha component
  36034. */
  36035. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36036. /**
  36037. * Sets the current alpha mode
  36038. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36039. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36040. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36041. */
  36042. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36043. /**
  36044. * Gets the current alpha mode
  36045. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36046. * @returns the current alpha mode
  36047. */
  36048. getAlphaMode(): number;
  36049. /**
  36050. * Sets the current alpha equation
  36051. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36052. */
  36053. setAlphaEquation(equation: number): void;
  36054. /**
  36055. * Gets the current alpha equation.
  36056. * @returns the current alpha equation
  36057. */
  36058. getAlphaEquation(): number;
  36059. }
  36060. }
  36061. declare module BABYLON {
  36062. interface ThinEngine {
  36063. /** @hidden */
  36064. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36065. }
  36066. }
  36067. declare module BABYLON {
  36068. /**
  36069. * Defines the interface used by display changed events
  36070. */
  36071. export interface IDisplayChangedEventArgs {
  36072. /** Gets the vrDisplay object (if any) */
  36073. vrDisplay: Nullable<any>;
  36074. /** Gets a boolean indicating if webVR is supported */
  36075. vrSupported: boolean;
  36076. }
  36077. /**
  36078. * Defines the interface used by objects containing a viewport (like a camera)
  36079. */
  36080. interface IViewportOwnerLike {
  36081. /**
  36082. * Gets or sets the viewport
  36083. */
  36084. viewport: IViewportLike;
  36085. }
  36086. /**
  36087. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36088. */
  36089. export class Engine extends ThinEngine {
  36090. /** Defines that alpha blending is disabled */
  36091. static readonly ALPHA_DISABLE: number;
  36092. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36093. static readonly ALPHA_ADD: number;
  36094. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36095. static readonly ALPHA_COMBINE: number;
  36096. /** Defines that alpha blending to DEST - SRC * DEST */
  36097. static readonly ALPHA_SUBTRACT: number;
  36098. /** Defines that alpha blending to SRC * DEST */
  36099. static readonly ALPHA_MULTIPLY: number;
  36100. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36101. static readonly ALPHA_MAXIMIZED: number;
  36102. /** Defines that alpha blending to SRC + DEST */
  36103. static readonly ALPHA_ONEONE: number;
  36104. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36105. static readonly ALPHA_PREMULTIPLIED: number;
  36106. /**
  36107. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36108. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36109. */
  36110. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36111. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36112. static readonly ALPHA_INTERPOLATE: number;
  36113. /**
  36114. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36115. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36116. */
  36117. static readonly ALPHA_SCREENMODE: number;
  36118. /** Defines that the ressource is not delayed*/
  36119. static readonly DELAYLOADSTATE_NONE: number;
  36120. /** Defines that the ressource was successfully delay loaded */
  36121. static readonly DELAYLOADSTATE_LOADED: number;
  36122. /** Defines that the ressource is currently delay loading */
  36123. static readonly DELAYLOADSTATE_LOADING: number;
  36124. /** Defines that the ressource is delayed and has not started loading */
  36125. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36126. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36127. static readonly NEVER: number;
  36128. /** 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 */
  36129. static readonly ALWAYS: number;
  36130. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36131. static readonly LESS: number;
  36132. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36133. static readonly EQUAL: number;
  36134. /** 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 */
  36135. static readonly LEQUAL: number;
  36136. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36137. static readonly GREATER: number;
  36138. /** 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 */
  36139. static readonly GEQUAL: number;
  36140. /** 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 */
  36141. static readonly NOTEQUAL: number;
  36142. /** Passed to stencilOperation to specify that stencil value must be kept */
  36143. static readonly KEEP: number;
  36144. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36145. static readonly REPLACE: number;
  36146. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36147. static readonly INCR: number;
  36148. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36149. static readonly DECR: number;
  36150. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36151. static readonly INVERT: number;
  36152. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36153. static readonly INCR_WRAP: number;
  36154. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36155. static readonly DECR_WRAP: number;
  36156. /** Texture is not repeating outside of 0..1 UVs */
  36157. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36158. /** Texture is repeating outside of 0..1 UVs */
  36159. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36160. /** Texture is repeating and mirrored */
  36161. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36162. /** ALPHA */
  36163. static readonly TEXTUREFORMAT_ALPHA: number;
  36164. /** LUMINANCE */
  36165. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36166. /** LUMINANCE_ALPHA */
  36167. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36168. /** RGB */
  36169. static readonly TEXTUREFORMAT_RGB: number;
  36170. /** RGBA */
  36171. static readonly TEXTUREFORMAT_RGBA: number;
  36172. /** RED */
  36173. static readonly TEXTUREFORMAT_RED: number;
  36174. /** RED (2nd reference) */
  36175. static readonly TEXTUREFORMAT_R: number;
  36176. /** RG */
  36177. static readonly TEXTUREFORMAT_RG: number;
  36178. /** RED_INTEGER */
  36179. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36180. /** RED_INTEGER (2nd reference) */
  36181. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36182. /** RG_INTEGER */
  36183. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36184. /** RGB_INTEGER */
  36185. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36186. /** RGBA_INTEGER */
  36187. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36188. /** UNSIGNED_BYTE */
  36189. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36190. /** UNSIGNED_BYTE (2nd reference) */
  36191. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36192. /** FLOAT */
  36193. static readonly TEXTURETYPE_FLOAT: number;
  36194. /** HALF_FLOAT */
  36195. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36196. /** BYTE */
  36197. static readonly TEXTURETYPE_BYTE: number;
  36198. /** SHORT */
  36199. static readonly TEXTURETYPE_SHORT: number;
  36200. /** UNSIGNED_SHORT */
  36201. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36202. /** INT */
  36203. static readonly TEXTURETYPE_INT: number;
  36204. /** UNSIGNED_INT */
  36205. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36206. /** UNSIGNED_SHORT_4_4_4_4 */
  36207. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36208. /** UNSIGNED_SHORT_5_5_5_1 */
  36209. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36210. /** UNSIGNED_SHORT_5_6_5 */
  36211. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36212. /** UNSIGNED_INT_2_10_10_10_REV */
  36213. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36214. /** UNSIGNED_INT_24_8 */
  36215. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36216. /** UNSIGNED_INT_10F_11F_11F_REV */
  36217. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36218. /** UNSIGNED_INT_5_9_9_9_REV */
  36219. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36220. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36221. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36222. /** nearest is mag = nearest and min = nearest and mip = linear */
  36223. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36224. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36225. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36226. /** Trilinear is mag = linear and min = linear and mip = linear */
  36227. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36228. /** nearest is mag = nearest and min = nearest and mip = linear */
  36229. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36230. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36231. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36232. /** Trilinear is mag = linear and min = linear and mip = linear */
  36233. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36234. /** mag = nearest and min = nearest and mip = nearest */
  36235. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36236. /** mag = nearest and min = linear and mip = nearest */
  36237. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36238. /** mag = nearest and min = linear and mip = linear */
  36239. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36240. /** mag = nearest and min = linear and mip = none */
  36241. static readonly TEXTURE_NEAREST_LINEAR: number;
  36242. /** mag = nearest and min = nearest and mip = none */
  36243. static readonly TEXTURE_NEAREST_NEAREST: number;
  36244. /** mag = linear and min = nearest and mip = nearest */
  36245. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36246. /** mag = linear and min = nearest and mip = linear */
  36247. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36248. /** mag = linear and min = linear and mip = none */
  36249. static readonly TEXTURE_LINEAR_LINEAR: number;
  36250. /** mag = linear and min = nearest and mip = none */
  36251. static readonly TEXTURE_LINEAR_NEAREST: number;
  36252. /** Explicit coordinates mode */
  36253. static readonly TEXTURE_EXPLICIT_MODE: number;
  36254. /** Spherical coordinates mode */
  36255. static readonly TEXTURE_SPHERICAL_MODE: number;
  36256. /** Planar coordinates mode */
  36257. static readonly TEXTURE_PLANAR_MODE: number;
  36258. /** Cubic coordinates mode */
  36259. static readonly TEXTURE_CUBIC_MODE: number;
  36260. /** Projection coordinates mode */
  36261. static readonly TEXTURE_PROJECTION_MODE: number;
  36262. /** Skybox coordinates mode */
  36263. static readonly TEXTURE_SKYBOX_MODE: number;
  36264. /** Inverse Cubic coordinates mode */
  36265. static readonly TEXTURE_INVCUBIC_MODE: number;
  36266. /** Equirectangular coordinates mode */
  36267. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36268. /** Equirectangular Fixed coordinates mode */
  36269. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36270. /** Equirectangular Fixed Mirrored coordinates mode */
  36271. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36272. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36273. static readonly SCALEMODE_FLOOR: number;
  36274. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36275. static readonly SCALEMODE_NEAREST: number;
  36276. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36277. static readonly SCALEMODE_CEILING: number;
  36278. /**
  36279. * Returns the current npm package of the sdk
  36280. */
  36281. static get NpmPackage(): string;
  36282. /**
  36283. * Returns the current version of the framework
  36284. */
  36285. static get Version(): string;
  36286. /** Gets the list of created engines */
  36287. static get Instances(): Engine[];
  36288. /**
  36289. * Gets the latest created engine
  36290. */
  36291. static get LastCreatedEngine(): Nullable<Engine>;
  36292. /**
  36293. * Gets the latest created scene
  36294. */
  36295. static get LastCreatedScene(): Nullable<Scene>;
  36296. /**
  36297. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36298. * @param flag defines which part of the materials must be marked as dirty
  36299. * @param predicate defines a predicate used to filter which materials should be affected
  36300. */
  36301. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36302. /**
  36303. * Method called to create the default loading screen.
  36304. * This can be overriden in your own app.
  36305. * @param canvas The rendering canvas element
  36306. * @returns The loading screen
  36307. */
  36308. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36309. /**
  36310. * Method called to create the default rescale post process on each engine.
  36311. */
  36312. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36313. /**
  36314. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36315. **/
  36316. enableOfflineSupport: boolean;
  36317. /**
  36318. * 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)
  36319. **/
  36320. disableManifestCheck: boolean;
  36321. /**
  36322. * Gets the list of created scenes
  36323. */
  36324. scenes: Scene[];
  36325. /**
  36326. * Event raised when a new scene is created
  36327. */
  36328. onNewSceneAddedObservable: Observable<Scene>;
  36329. /**
  36330. * Gets the list of created postprocesses
  36331. */
  36332. postProcesses: PostProcess[];
  36333. /**
  36334. * Gets a boolean indicating if the pointer is currently locked
  36335. */
  36336. isPointerLock: boolean;
  36337. /**
  36338. * Observable event triggered each time the rendering canvas is resized
  36339. */
  36340. onResizeObservable: Observable<Engine>;
  36341. /**
  36342. * Observable event triggered each time the canvas loses focus
  36343. */
  36344. onCanvasBlurObservable: Observable<Engine>;
  36345. /**
  36346. * Observable event triggered each time the canvas gains focus
  36347. */
  36348. onCanvasFocusObservable: Observable<Engine>;
  36349. /**
  36350. * Observable event triggered each time the canvas receives pointerout event
  36351. */
  36352. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36353. /**
  36354. * Observable raised when the engine begins a new frame
  36355. */
  36356. onBeginFrameObservable: Observable<Engine>;
  36357. /**
  36358. * If set, will be used to request the next animation frame for the render loop
  36359. */
  36360. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36361. /**
  36362. * Observable raised when the engine ends the current frame
  36363. */
  36364. onEndFrameObservable: Observable<Engine>;
  36365. /**
  36366. * Observable raised when the engine is about to compile a shader
  36367. */
  36368. onBeforeShaderCompilationObservable: Observable<Engine>;
  36369. /**
  36370. * Observable raised when the engine has jsut compiled a shader
  36371. */
  36372. onAfterShaderCompilationObservable: Observable<Engine>;
  36373. /**
  36374. * Gets the audio engine
  36375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36376. * @ignorenaming
  36377. */
  36378. static audioEngine: IAudioEngine;
  36379. /**
  36380. * Default AudioEngine factory responsible of creating the Audio Engine.
  36381. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36382. */
  36383. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36384. /**
  36385. * Default offline support factory responsible of creating a tool used to store data locally.
  36386. * By default, this will create a Database object if the workload has been embedded.
  36387. */
  36388. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36389. private _loadingScreen;
  36390. private _pointerLockRequested;
  36391. private _rescalePostProcess;
  36392. private _deterministicLockstep;
  36393. private _lockstepMaxSteps;
  36394. private _timeStep;
  36395. protected get _supportsHardwareTextureRescaling(): boolean;
  36396. private _fps;
  36397. private _deltaTime;
  36398. /** @hidden */
  36399. _drawCalls: PerfCounter;
  36400. /** 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 */
  36401. canvasTabIndex: number;
  36402. /**
  36403. * Turn this value on if you want to pause FPS computation when in background
  36404. */
  36405. disablePerformanceMonitorInBackground: boolean;
  36406. private _performanceMonitor;
  36407. /**
  36408. * Gets the performance monitor attached to this engine
  36409. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36410. */
  36411. get performanceMonitor(): PerformanceMonitor;
  36412. private _onFocus;
  36413. private _onBlur;
  36414. private _onCanvasPointerOut;
  36415. private _onCanvasBlur;
  36416. private _onCanvasFocus;
  36417. private _onFullscreenChange;
  36418. private _onPointerLockChange;
  36419. /**
  36420. * Gets the HTML element used to attach event listeners
  36421. * @returns a HTML element
  36422. */
  36423. getInputElement(): Nullable<HTMLElement>;
  36424. /**
  36425. * Creates a new engine
  36426. * @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
  36427. * @param antialias defines enable antialiasing (default: false)
  36428. * @param options defines further options to be sent to the getContext() function
  36429. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36430. */
  36431. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36432. /**
  36433. * Gets current aspect ratio
  36434. * @param viewportOwner defines the camera to use to get the aspect ratio
  36435. * @param useScreen defines if screen size must be used (or the current render target if any)
  36436. * @returns a number defining the aspect ratio
  36437. */
  36438. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36439. /**
  36440. * Gets current screen aspect ratio
  36441. * @returns a number defining the aspect ratio
  36442. */
  36443. getScreenAspectRatio(): number;
  36444. /**
  36445. * Gets the client rect of the HTML canvas attached with the current webGL context
  36446. * @returns a client rectanglee
  36447. */
  36448. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36449. /**
  36450. * Gets the client rect of the HTML element used for events
  36451. * @returns a client rectanglee
  36452. */
  36453. getInputElementClientRect(): Nullable<ClientRect>;
  36454. /**
  36455. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36456. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36457. * @returns true if engine is in deterministic lock step mode
  36458. */
  36459. isDeterministicLockStep(): boolean;
  36460. /**
  36461. * Gets the max steps when engine is running in deterministic lock step
  36462. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36463. * @returns the max steps
  36464. */
  36465. getLockstepMaxSteps(): number;
  36466. /**
  36467. * Returns the time in ms between steps when using deterministic lock step.
  36468. * @returns time step in (ms)
  36469. */
  36470. getTimeStep(): number;
  36471. /**
  36472. * Force the mipmap generation for the given render target texture
  36473. * @param texture defines the render target texture to use
  36474. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36475. */
  36476. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36477. /** States */
  36478. /**
  36479. * Set various states to the webGL context
  36480. * @param culling defines backface culling state
  36481. * @param zOffset defines the value to apply to zOffset (0 by default)
  36482. * @param force defines if states must be applied even if cache is up to date
  36483. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36484. */
  36485. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36486. /**
  36487. * Set the z offset to apply to current rendering
  36488. * @param value defines the offset to apply
  36489. */
  36490. setZOffset(value: number): void;
  36491. /**
  36492. * Gets the current value of the zOffset
  36493. * @returns the current zOffset state
  36494. */
  36495. getZOffset(): number;
  36496. /**
  36497. * Enable or disable depth buffering
  36498. * @param enable defines the state to set
  36499. */
  36500. setDepthBuffer(enable: boolean): void;
  36501. /**
  36502. * Gets a boolean indicating if depth writing is enabled
  36503. * @returns the current depth writing state
  36504. */
  36505. getDepthWrite(): boolean;
  36506. /**
  36507. * Enable or disable depth writing
  36508. * @param enable defines the state to set
  36509. */
  36510. setDepthWrite(enable: boolean): void;
  36511. /**
  36512. * Gets a boolean indicating if stencil buffer is enabled
  36513. * @returns the current stencil buffer state
  36514. */
  36515. getStencilBuffer(): boolean;
  36516. /**
  36517. * Enable or disable the stencil buffer
  36518. * @param enable defines if the stencil buffer must be enabled or disabled
  36519. */
  36520. setStencilBuffer(enable: boolean): void;
  36521. /**
  36522. * Gets the current stencil mask
  36523. * @returns a number defining the new stencil mask to use
  36524. */
  36525. getStencilMask(): number;
  36526. /**
  36527. * Sets the current stencil mask
  36528. * @param mask defines the new stencil mask to use
  36529. */
  36530. setStencilMask(mask: number): void;
  36531. /**
  36532. * Gets the current stencil function
  36533. * @returns a number defining the stencil function to use
  36534. */
  36535. getStencilFunction(): number;
  36536. /**
  36537. * Gets the current stencil reference value
  36538. * @returns a number defining the stencil reference value to use
  36539. */
  36540. getStencilFunctionReference(): number;
  36541. /**
  36542. * Gets the current stencil mask
  36543. * @returns a number defining the stencil mask to use
  36544. */
  36545. getStencilFunctionMask(): number;
  36546. /**
  36547. * Sets the current stencil function
  36548. * @param stencilFunc defines the new stencil function to use
  36549. */
  36550. setStencilFunction(stencilFunc: number): void;
  36551. /**
  36552. * Sets the current stencil reference
  36553. * @param reference defines the new stencil reference to use
  36554. */
  36555. setStencilFunctionReference(reference: number): void;
  36556. /**
  36557. * Sets the current stencil mask
  36558. * @param mask defines the new stencil mask to use
  36559. */
  36560. setStencilFunctionMask(mask: number): void;
  36561. /**
  36562. * Gets the current stencil operation when stencil fails
  36563. * @returns a number defining stencil operation to use when stencil fails
  36564. */
  36565. getStencilOperationFail(): number;
  36566. /**
  36567. * Gets the current stencil operation when depth fails
  36568. * @returns a number defining stencil operation to use when depth fails
  36569. */
  36570. getStencilOperationDepthFail(): number;
  36571. /**
  36572. * Gets the current stencil operation when stencil passes
  36573. * @returns a number defining stencil operation to use when stencil passes
  36574. */
  36575. getStencilOperationPass(): number;
  36576. /**
  36577. * Sets the stencil operation to use when stencil fails
  36578. * @param operation defines the stencil operation to use when stencil fails
  36579. */
  36580. setStencilOperationFail(operation: number): void;
  36581. /**
  36582. * Sets the stencil operation to use when depth fails
  36583. * @param operation defines the stencil operation to use when depth fails
  36584. */
  36585. setStencilOperationDepthFail(operation: number): void;
  36586. /**
  36587. * Sets the stencil operation to use when stencil passes
  36588. * @param operation defines the stencil operation to use when stencil passes
  36589. */
  36590. setStencilOperationPass(operation: number): void;
  36591. /**
  36592. * Sets a boolean indicating if the dithering state is enabled or disabled
  36593. * @param value defines the dithering state
  36594. */
  36595. setDitheringState(value: boolean): void;
  36596. /**
  36597. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36598. * @param value defines the rasterizer state
  36599. */
  36600. setRasterizerState(value: boolean): void;
  36601. /**
  36602. * Gets the current depth function
  36603. * @returns a number defining the depth function
  36604. */
  36605. getDepthFunction(): Nullable<number>;
  36606. /**
  36607. * Sets the current depth function
  36608. * @param depthFunc defines the function to use
  36609. */
  36610. setDepthFunction(depthFunc: number): void;
  36611. /**
  36612. * Sets the current depth function to GREATER
  36613. */
  36614. setDepthFunctionToGreater(): void;
  36615. /**
  36616. * Sets the current depth function to GEQUAL
  36617. */
  36618. setDepthFunctionToGreaterOrEqual(): void;
  36619. /**
  36620. * Sets the current depth function to LESS
  36621. */
  36622. setDepthFunctionToLess(): void;
  36623. /**
  36624. * Sets the current depth function to LEQUAL
  36625. */
  36626. setDepthFunctionToLessOrEqual(): void;
  36627. private _cachedStencilBuffer;
  36628. private _cachedStencilFunction;
  36629. private _cachedStencilMask;
  36630. private _cachedStencilOperationPass;
  36631. private _cachedStencilOperationFail;
  36632. private _cachedStencilOperationDepthFail;
  36633. private _cachedStencilReference;
  36634. /**
  36635. * Caches the the state of the stencil buffer
  36636. */
  36637. cacheStencilState(): void;
  36638. /**
  36639. * Restores the state of the stencil buffer
  36640. */
  36641. restoreStencilState(): void;
  36642. /**
  36643. * Directly set the WebGL Viewport
  36644. * @param x defines the x coordinate of the viewport (in screen space)
  36645. * @param y defines the y coordinate of the viewport (in screen space)
  36646. * @param width defines the width of the viewport (in screen space)
  36647. * @param height defines the height of the viewport (in screen space)
  36648. * @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
  36649. */
  36650. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36651. /**
  36652. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36653. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36654. * @param y defines the y-coordinate of the corner of the clear rectangle
  36655. * @param width defines the width of the clear rectangle
  36656. * @param height defines the height of the clear rectangle
  36657. * @param clearColor defines the clear color
  36658. */
  36659. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36660. /**
  36661. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36662. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36663. * @param y defines the y-coordinate of the corner of the clear rectangle
  36664. * @param width defines the width of the clear rectangle
  36665. * @param height defines the height of the clear rectangle
  36666. */
  36667. enableScissor(x: number, y: number, width: number, height: number): void;
  36668. /**
  36669. * Disable previously set scissor test rectangle
  36670. */
  36671. disableScissor(): void;
  36672. protected _reportDrawCall(): void;
  36673. /**
  36674. * Initializes a webVR display and starts listening to display change events
  36675. * The onVRDisplayChangedObservable will be notified upon these changes
  36676. * @returns The onVRDisplayChangedObservable
  36677. */
  36678. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36679. /** @hidden */
  36680. _prepareVRComponent(): void;
  36681. /** @hidden */
  36682. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36683. /** @hidden */
  36684. _submitVRFrame(): void;
  36685. /**
  36686. * Call this function to leave webVR mode
  36687. * Will do nothing if webVR is not supported or if there is no webVR device
  36688. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36689. */
  36690. disableVR(): void;
  36691. /**
  36692. * Gets a boolean indicating that the system is in VR mode and is presenting
  36693. * @returns true if VR mode is engaged
  36694. */
  36695. isVRPresenting(): boolean;
  36696. /** @hidden */
  36697. _requestVRFrame(): void;
  36698. /** @hidden */
  36699. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36700. /**
  36701. * Gets the source code of the vertex shader associated with a specific webGL program
  36702. * @param program defines the program to use
  36703. * @returns a string containing the source code of the vertex shader associated with the program
  36704. */
  36705. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36706. /**
  36707. * Gets the source code of the fragment shader associated with a specific webGL program
  36708. * @param program defines the program to use
  36709. * @returns a string containing the source code of the fragment shader associated with the program
  36710. */
  36711. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36712. /**
  36713. * Sets a depth stencil texture from a render target to the according uniform.
  36714. * @param channel The texture channel
  36715. * @param uniform The uniform to set
  36716. * @param texture The render target texture containing the depth stencil texture to apply
  36717. */
  36718. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36719. /**
  36720. * Sets a texture to the webGL context from a postprocess
  36721. * @param channel defines the channel to use
  36722. * @param postProcess defines the source postprocess
  36723. */
  36724. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36725. /**
  36726. * Binds the output of the passed in post process to the texture channel specified
  36727. * @param channel The channel the texture should be bound to
  36728. * @param postProcess The post process which's output should be bound
  36729. */
  36730. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36731. protected _rebuildBuffers(): void;
  36732. /** @hidden */
  36733. _renderFrame(): void;
  36734. _renderLoop(): void;
  36735. /** @hidden */
  36736. _renderViews(): boolean;
  36737. /**
  36738. * Toggle full screen mode
  36739. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36740. */
  36741. switchFullscreen(requestPointerLock: boolean): void;
  36742. /**
  36743. * Enters full screen mode
  36744. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36745. */
  36746. enterFullscreen(requestPointerLock: boolean): void;
  36747. /**
  36748. * Exits full screen mode
  36749. */
  36750. exitFullscreen(): void;
  36751. /**
  36752. * Enters Pointerlock mode
  36753. */
  36754. enterPointerlock(): void;
  36755. /**
  36756. * Exits Pointerlock mode
  36757. */
  36758. exitPointerlock(): void;
  36759. /**
  36760. * Begin a new frame
  36761. */
  36762. beginFrame(): void;
  36763. /**
  36764. * Enf the current frame
  36765. */
  36766. endFrame(): void;
  36767. resize(): void;
  36768. /**
  36769. * Force a specific size of the canvas
  36770. * @param width defines the new canvas' width
  36771. * @param height defines the new canvas' height
  36772. */
  36773. setSize(width: number, height: number): void;
  36774. /**
  36775. * Updates a dynamic vertex buffer.
  36776. * @param vertexBuffer the vertex buffer to update
  36777. * @param data the data used to update the vertex buffer
  36778. * @param byteOffset the byte offset of the data
  36779. * @param byteLength the byte length of the data
  36780. */
  36781. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  36782. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36783. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36784. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36785. _releaseTexture(texture: InternalTexture): void;
  36786. /**
  36787. * @hidden
  36788. * Rescales a texture
  36789. * @param source input texutre
  36790. * @param destination destination texture
  36791. * @param scene scene to use to render the resize
  36792. * @param internalFormat format to use when resizing
  36793. * @param onComplete callback to be called when resize has completed
  36794. */
  36795. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36796. /**
  36797. * Gets the current framerate
  36798. * @returns a number representing the framerate
  36799. */
  36800. getFps(): number;
  36801. /**
  36802. * Gets the time spent between current and previous frame
  36803. * @returns a number representing the delta time in ms
  36804. */
  36805. getDeltaTime(): number;
  36806. private _measureFps;
  36807. /** @hidden */
  36808. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  36809. /**
  36810. * Update a dynamic index buffer
  36811. * @param indexBuffer defines the target index buffer
  36812. * @param indices defines the data to update
  36813. * @param offset defines the offset in the target index buffer where update should start
  36814. */
  36815. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  36816. /**
  36817. * Updates the sample count of a render target texture
  36818. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  36819. * @param texture defines the texture to update
  36820. * @param samples defines the sample count to set
  36821. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  36822. */
  36823. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  36824. /**
  36825. * Updates a depth texture Comparison Mode and Function.
  36826. * If the comparison Function is equal to 0, the mode will be set to none.
  36827. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  36828. * @param texture The texture to set the comparison function for
  36829. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  36830. */
  36831. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  36832. /**
  36833. * Creates a webGL buffer to use with instanciation
  36834. * @param capacity defines the size of the buffer
  36835. * @returns the webGL buffer
  36836. */
  36837. createInstancesBuffer(capacity: number): DataBuffer;
  36838. /**
  36839. * Delete a webGL buffer used with instanciation
  36840. * @param buffer defines the webGL buffer to delete
  36841. */
  36842. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  36843. private _clientWaitAsync;
  36844. /** @hidden */
  36845. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  36846. dispose(): void;
  36847. private _disableTouchAction;
  36848. /**
  36849. * Display the loading screen
  36850. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36851. */
  36852. displayLoadingUI(): void;
  36853. /**
  36854. * Hide the loading screen
  36855. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36856. */
  36857. hideLoadingUI(): void;
  36858. /**
  36859. * Gets the current loading screen object
  36860. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36861. */
  36862. get loadingScreen(): ILoadingScreen;
  36863. /**
  36864. * Sets the current loading screen object
  36865. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36866. */
  36867. set loadingScreen(loadingScreen: ILoadingScreen);
  36868. /**
  36869. * Sets the current loading screen text
  36870. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36871. */
  36872. set loadingUIText(text: string);
  36873. /**
  36874. * Sets the current loading screen background color
  36875. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36876. */
  36877. set loadingUIBackgroundColor(color: string);
  36878. /** Pointerlock and fullscreen */
  36879. /**
  36880. * Ask the browser to promote the current element to pointerlock mode
  36881. * @param element defines the DOM element to promote
  36882. */
  36883. static _RequestPointerlock(element: HTMLElement): void;
  36884. /**
  36885. * Asks the browser to exit pointerlock mode
  36886. */
  36887. static _ExitPointerlock(): void;
  36888. /**
  36889. * Ask the browser to promote the current element to fullscreen rendering mode
  36890. * @param element defines the DOM element to promote
  36891. */
  36892. static _RequestFullscreen(element: HTMLElement): void;
  36893. /**
  36894. * Asks the browser to exit fullscreen mode
  36895. */
  36896. static _ExitFullscreen(): void;
  36897. }
  36898. }
  36899. declare module BABYLON {
  36900. /**
  36901. * The engine store class is responsible to hold all the instances of Engine and Scene created
  36902. * during the life time of the application.
  36903. */
  36904. export class EngineStore {
  36905. /** Gets the list of created engines */
  36906. static Instances: Engine[];
  36907. /** @hidden */
  36908. static _LastCreatedScene: Nullable<Scene>;
  36909. /**
  36910. * Gets the latest created engine
  36911. */
  36912. static get LastCreatedEngine(): Nullable<Engine>;
  36913. /**
  36914. * Gets the latest created scene
  36915. */
  36916. static get LastCreatedScene(): Nullable<Scene>;
  36917. /**
  36918. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  36919. * @ignorenaming
  36920. */
  36921. static UseFallbackTexture: boolean;
  36922. /**
  36923. * Texture content used if a texture cannot loaded
  36924. * @ignorenaming
  36925. */
  36926. static FallbackTexture: string;
  36927. }
  36928. }
  36929. declare module BABYLON {
  36930. /**
  36931. * Helper class that provides a small promise polyfill
  36932. */
  36933. export class PromisePolyfill {
  36934. /**
  36935. * Static function used to check if the polyfill is required
  36936. * If this is the case then the function will inject the polyfill to window.Promise
  36937. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  36938. */
  36939. static Apply(force?: boolean): void;
  36940. }
  36941. }
  36942. declare module BABYLON {
  36943. /**
  36944. * Interface for screenshot methods with describe argument called `size` as object with options
  36945. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  36946. */
  36947. export interface IScreenshotSize {
  36948. /**
  36949. * number in pixels for canvas height
  36950. */
  36951. height?: number;
  36952. /**
  36953. * multiplier allowing render at a higher or lower resolution
  36954. * If value is defined then height and width will be ignored and taken from camera
  36955. */
  36956. precision?: number;
  36957. /**
  36958. * number in pixels for canvas width
  36959. */
  36960. width?: number;
  36961. }
  36962. }
  36963. declare module BABYLON {
  36964. interface IColor4Like {
  36965. r: float;
  36966. g: float;
  36967. b: float;
  36968. a: float;
  36969. }
  36970. /**
  36971. * Class containing a set of static utilities functions
  36972. */
  36973. export class Tools {
  36974. /**
  36975. * Gets or sets the base URL to use to load assets
  36976. */
  36977. static get BaseUrl(): string;
  36978. static set BaseUrl(value: string);
  36979. /**
  36980. * Enable/Disable Custom HTTP Request Headers globally.
  36981. * default = false
  36982. * @see CustomRequestHeaders
  36983. */
  36984. static UseCustomRequestHeaders: boolean;
  36985. /**
  36986. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  36987. * i.e. when loading files, where the server/service expects an Authorization header
  36988. */
  36989. static CustomRequestHeaders: {
  36990. [key: string]: string;
  36991. };
  36992. /**
  36993. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  36994. */
  36995. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  36996. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  36997. /**
  36998. * Default behaviour for cors in the application.
  36999. * It can be a string if the expected behavior is identical in the entire app.
  37000. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37001. */
  37002. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37003. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37004. /**
  37005. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37006. * @ignorenaming
  37007. */
  37008. static get UseFallbackTexture(): boolean;
  37009. static set UseFallbackTexture(value: boolean);
  37010. /**
  37011. * Use this object to register external classes like custom textures or material
  37012. * to allow the laoders to instantiate them
  37013. */
  37014. static get RegisteredExternalClasses(): {
  37015. [key: string]: Object;
  37016. };
  37017. static set RegisteredExternalClasses(classes: {
  37018. [key: string]: Object;
  37019. });
  37020. /**
  37021. * Texture content used if a texture cannot loaded
  37022. * @ignorenaming
  37023. */
  37024. static get fallbackTexture(): string;
  37025. static set fallbackTexture(value: string);
  37026. /**
  37027. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37028. * @param u defines the coordinate on X axis
  37029. * @param v defines the coordinate on Y axis
  37030. * @param width defines the width of the source data
  37031. * @param height defines the height of the source data
  37032. * @param pixels defines the source byte array
  37033. * @param color defines the output color
  37034. */
  37035. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37036. /**
  37037. * Interpolates between a and b via alpha
  37038. * @param a The lower value (returned when alpha = 0)
  37039. * @param b The upper value (returned when alpha = 1)
  37040. * @param alpha The interpolation-factor
  37041. * @return The mixed value
  37042. */
  37043. static Mix(a: number, b: number, alpha: number): number;
  37044. /**
  37045. * Tries to instantiate a new object from a given class name
  37046. * @param className defines the class name to instantiate
  37047. * @returns the new object or null if the system was not able to do the instantiation
  37048. */
  37049. static Instantiate(className: string): any;
  37050. /**
  37051. * Provides a slice function that will work even on IE
  37052. * @param data defines the array to slice
  37053. * @param start defines the start of the data (optional)
  37054. * @param end defines the end of the data (optional)
  37055. * @returns the new sliced array
  37056. */
  37057. static Slice<T>(data: T, start?: number, end?: number): T;
  37058. /**
  37059. * Polyfill for setImmediate
  37060. * @param action defines the action to execute after the current execution block
  37061. */
  37062. static SetImmediate(action: () => void): void;
  37063. /**
  37064. * Function indicating if a number is an exponent of 2
  37065. * @param value defines the value to test
  37066. * @returns true if the value is an exponent of 2
  37067. */
  37068. static IsExponentOfTwo(value: number): boolean;
  37069. private static _tmpFloatArray;
  37070. /**
  37071. * Returns the nearest 32-bit single precision float representation of a Number
  37072. * @param value A Number. If the parameter is of a different type, it will get converted
  37073. * to a number or to NaN if it cannot be converted
  37074. * @returns number
  37075. */
  37076. static FloatRound(value: number): number;
  37077. /**
  37078. * Extracts the filename from a path
  37079. * @param path defines the path to use
  37080. * @returns the filename
  37081. */
  37082. static GetFilename(path: string): string;
  37083. /**
  37084. * Extracts the "folder" part of a path (everything before the filename).
  37085. * @param uri The URI to extract the info from
  37086. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37087. * @returns The "folder" part of the path
  37088. */
  37089. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37090. /**
  37091. * Extracts text content from a DOM element hierarchy
  37092. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37093. */
  37094. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37095. /**
  37096. * Convert an angle in radians to degrees
  37097. * @param angle defines the angle to convert
  37098. * @returns the angle in degrees
  37099. */
  37100. static ToDegrees(angle: number): number;
  37101. /**
  37102. * Convert an angle in degrees to radians
  37103. * @param angle defines the angle to convert
  37104. * @returns the angle in radians
  37105. */
  37106. static ToRadians(angle: number): number;
  37107. /**
  37108. * Returns an array if obj is not an array
  37109. * @param obj defines the object to evaluate as an array
  37110. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37111. * @returns either obj directly if obj is an array or a new array containing obj
  37112. */
  37113. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37114. /**
  37115. * Gets the pointer prefix to use
  37116. * @param engine defines the engine we are finding the prefix for
  37117. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37118. */
  37119. static GetPointerPrefix(engine: Engine): string;
  37120. /**
  37121. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37122. * @param url define the url we are trying
  37123. * @param element define the dom element where to configure the cors policy
  37124. */
  37125. static SetCorsBehavior(url: string | string[], element: {
  37126. crossOrigin: string | null;
  37127. }): void;
  37128. /**
  37129. * Removes unwanted characters from an url
  37130. * @param url defines the url to clean
  37131. * @returns the cleaned url
  37132. */
  37133. static CleanUrl(url: string): string;
  37134. /**
  37135. * Gets or sets a function used to pre-process url before using them to load assets
  37136. */
  37137. static get PreprocessUrl(): (url: string) => string;
  37138. static set PreprocessUrl(processor: (url: string) => string);
  37139. /**
  37140. * Loads an image as an HTMLImageElement.
  37141. * @param input url string, ArrayBuffer, or Blob to load
  37142. * @param onLoad callback called when the image successfully loads
  37143. * @param onError callback called when the image fails to load
  37144. * @param offlineProvider offline provider for caching
  37145. * @param mimeType optional mime type
  37146. * @returns the HTMLImageElement of the loaded image
  37147. */
  37148. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37149. /**
  37150. * Loads a file from a url
  37151. * @param url url string, ArrayBuffer, or Blob to load
  37152. * @param onSuccess callback called when the file successfully loads
  37153. * @param onProgress callback called while file is loading (if the server supports this mode)
  37154. * @param offlineProvider defines the offline provider for caching
  37155. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37156. * @param onError callback called when the file fails to load
  37157. * @returns a file request object
  37158. */
  37159. 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;
  37160. /**
  37161. * Loads a file from a url
  37162. * @param url the file url to load
  37163. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37164. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37165. */
  37166. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37167. /**
  37168. * Load a script (identified by an url). When the url returns, the
  37169. * content of this file is added into a new script element, attached to the DOM (body element)
  37170. * @param scriptUrl defines the url of the script to laod
  37171. * @param onSuccess defines the callback called when the script is loaded
  37172. * @param onError defines the callback to call if an error occurs
  37173. * @param scriptId defines the id of the script element
  37174. */
  37175. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37176. /**
  37177. * Load an asynchronous script (identified by an url). When the url returns, the
  37178. * content of this file is added into a new script element, attached to the DOM (body element)
  37179. * @param scriptUrl defines the url of the script to laod
  37180. * @param scriptId defines the id of the script element
  37181. * @returns a promise request object
  37182. */
  37183. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37184. /**
  37185. * Loads a file from a blob
  37186. * @param fileToLoad defines the blob to use
  37187. * @param callback defines the callback to call when data is loaded
  37188. * @param progressCallback defines the callback to call during loading process
  37189. * @returns a file request object
  37190. */
  37191. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37192. /**
  37193. * Reads a file from a File object
  37194. * @param file defines the file to load
  37195. * @param onSuccess defines the callback to call when data is loaded
  37196. * @param onProgress defines the callback to call during loading process
  37197. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37198. * @param onError defines the callback to call when an error occurs
  37199. * @returns a file request object
  37200. */
  37201. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37202. /**
  37203. * Creates a data url from a given string content
  37204. * @param content defines the content to convert
  37205. * @returns the new data url link
  37206. */
  37207. static FileAsURL(content: string): string;
  37208. /**
  37209. * Format the given number to a specific decimal format
  37210. * @param value defines the number to format
  37211. * @param decimals defines the number of decimals to use
  37212. * @returns the formatted string
  37213. */
  37214. static Format(value: number, decimals?: number): string;
  37215. /**
  37216. * Tries to copy an object by duplicating every property
  37217. * @param source defines the source object
  37218. * @param destination defines the target object
  37219. * @param doNotCopyList defines a list of properties to avoid
  37220. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37221. */
  37222. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37223. /**
  37224. * Gets a boolean indicating if the given object has no own property
  37225. * @param obj defines the object to test
  37226. * @returns true if object has no own property
  37227. */
  37228. static IsEmpty(obj: any): boolean;
  37229. /**
  37230. * Function used to register events at window level
  37231. * @param windowElement defines the Window object to use
  37232. * @param events defines the events to register
  37233. */
  37234. static RegisterTopRootEvents(windowElement: Window, events: {
  37235. name: string;
  37236. handler: Nullable<(e: FocusEvent) => any>;
  37237. }[]): void;
  37238. /**
  37239. * Function used to unregister events from window level
  37240. * @param windowElement defines the Window object to use
  37241. * @param events defines the events to unregister
  37242. */
  37243. static UnregisterTopRootEvents(windowElement: Window, events: {
  37244. name: string;
  37245. handler: Nullable<(e: FocusEvent) => any>;
  37246. }[]): void;
  37247. /**
  37248. * @ignore
  37249. */
  37250. static _ScreenshotCanvas: HTMLCanvasElement;
  37251. /**
  37252. * Dumps the current bound framebuffer
  37253. * @param width defines the rendering width
  37254. * @param height defines the rendering height
  37255. * @param engine defines the hosting engine
  37256. * @param successCallback defines the callback triggered once the data are available
  37257. * @param mimeType defines the mime type of the result
  37258. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37259. */
  37260. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37261. /**
  37262. * Converts the canvas data to blob.
  37263. * This acts as a polyfill for browsers not supporting the to blob function.
  37264. * @param canvas Defines the canvas to extract the data from
  37265. * @param successCallback Defines the callback triggered once the data are available
  37266. * @param mimeType Defines the mime type of the result
  37267. */
  37268. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37269. /**
  37270. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37271. * @param successCallback defines the callback triggered once the data are available
  37272. * @param mimeType defines the mime type of the result
  37273. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37274. */
  37275. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37276. /**
  37277. * Downloads a blob in the browser
  37278. * @param blob defines the blob to download
  37279. * @param fileName defines the name of the downloaded file
  37280. */
  37281. static Download(blob: Blob, fileName: string): void;
  37282. /**
  37283. * Captures a screenshot of the current rendering
  37284. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37285. * @param engine defines the rendering engine
  37286. * @param camera defines the source camera
  37287. * @param size This parameter can be set to a single number or to an object with the
  37288. * following (optional) properties: precision, width, height. If a single number is passed,
  37289. * it will be used for both width and height. If an object is passed, the screenshot size
  37290. * will be derived from the parameters. The precision property is a multiplier allowing
  37291. * rendering at a higher or lower resolution
  37292. * @param successCallback defines the callback receives a single parameter which contains the
  37293. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37294. * src parameter of an <img> to display it
  37295. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37296. * Check your browser for supported MIME types
  37297. */
  37298. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37299. /**
  37300. * Captures a screenshot of the current rendering
  37301. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37302. * @param engine defines the rendering engine
  37303. * @param camera defines the source camera
  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 defines the MIME type of the screenshot image (default: image/png).
  37310. * Check your browser for supported MIME types
  37311. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37312. * to the src parameter of an <img> to display it
  37313. */
  37314. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37315. /**
  37316. * Generates an image screenshot from the specified camera.
  37317. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37318. * @param engine The engine to use for rendering
  37319. * @param camera The camera to use for rendering
  37320. * @param size This parameter can be set to a single number or to an object with the
  37321. * following (optional) properties: precision, width, height. If a single number is passed,
  37322. * it will be used for both width and height. If an object is passed, the screenshot size
  37323. * will be derived from the parameters. The precision property is a multiplier allowing
  37324. * rendering at a higher or lower resolution
  37325. * @param successCallback The callback receives a single parameter which contains the
  37326. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37327. * src parameter of an <img> to display it
  37328. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37329. * Check your browser for supported MIME types
  37330. * @param samples Texture samples (default: 1)
  37331. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37332. * @param fileName A name for for the downloaded file.
  37333. */
  37334. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37335. /**
  37336. * Generates an image screenshot from the specified camera.
  37337. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37338. * @param engine The engine to use for rendering
  37339. * @param camera The camera to use for rendering
  37340. * @param size This parameter can be set to a single number or to an object with the
  37341. * following (optional) properties: precision, width, height. If a single number is passed,
  37342. * it will be used for both width and height. If an object is passed, the screenshot size
  37343. * will be derived from the parameters. The precision property is a multiplier allowing
  37344. * rendering at a higher or lower resolution
  37345. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37346. * Check your browser for supported MIME types
  37347. * @param samples Texture samples (default: 1)
  37348. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37349. * @param fileName A name for for the downloaded file.
  37350. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37351. * to the src parameter of an <img> to display it
  37352. */
  37353. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37354. /**
  37355. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37356. * Be aware Math.random() could cause collisions, but:
  37357. * "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"
  37358. * @returns a pseudo random id
  37359. */
  37360. static RandomId(): string;
  37361. /**
  37362. * Test if the given uri is a base64 string
  37363. * @param uri The uri to test
  37364. * @return True if the uri is a base64 string or false otherwise
  37365. */
  37366. static IsBase64(uri: string): boolean;
  37367. /**
  37368. * Decode the given base64 uri.
  37369. * @param uri The uri to decode
  37370. * @return The decoded base64 data.
  37371. */
  37372. static DecodeBase64(uri: string): ArrayBuffer;
  37373. /**
  37374. * Gets the absolute url.
  37375. * @param url the input url
  37376. * @return the absolute url
  37377. */
  37378. static GetAbsoluteUrl(url: string): string;
  37379. /**
  37380. * No log
  37381. */
  37382. static readonly NoneLogLevel: number;
  37383. /**
  37384. * Only message logs
  37385. */
  37386. static readonly MessageLogLevel: number;
  37387. /**
  37388. * Only warning logs
  37389. */
  37390. static readonly WarningLogLevel: number;
  37391. /**
  37392. * Only error logs
  37393. */
  37394. static readonly ErrorLogLevel: number;
  37395. /**
  37396. * All logs
  37397. */
  37398. static readonly AllLogLevel: number;
  37399. /**
  37400. * Gets a value indicating the number of loading errors
  37401. * @ignorenaming
  37402. */
  37403. static get errorsCount(): number;
  37404. /**
  37405. * Callback called when a new log is added
  37406. */
  37407. static OnNewCacheEntry: (entry: string) => void;
  37408. /**
  37409. * Log a message to the console
  37410. * @param message defines the message to log
  37411. */
  37412. static Log(message: string): void;
  37413. /**
  37414. * Write a warning message to the console
  37415. * @param message defines the message to log
  37416. */
  37417. static Warn(message: string): void;
  37418. /**
  37419. * Write an error message to the console
  37420. * @param message defines the message to log
  37421. */
  37422. static Error(message: string): void;
  37423. /**
  37424. * Gets current log cache (list of logs)
  37425. */
  37426. static get LogCache(): string;
  37427. /**
  37428. * Clears the log cache
  37429. */
  37430. static ClearLogCache(): void;
  37431. /**
  37432. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37433. */
  37434. static set LogLevels(level: number);
  37435. /**
  37436. * Checks if the window object exists
  37437. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37438. */
  37439. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37440. /**
  37441. * No performance log
  37442. */
  37443. static readonly PerformanceNoneLogLevel: number;
  37444. /**
  37445. * Use user marks to log performance
  37446. */
  37447. static readonly PerformanceUserMarkLogLevel: number;
  37448. /**
  37449. * Log performance to the console
  37450. */
  37451. static readonly PerformanceConsoleLogLevel: number;
  37452. private static _performance;
  37453. /**
  37454. * Sets the current performance log level
  37455. */
  37456. static set PerformanceLogLevel(level: number);
  37457. private static _StartPerformanceCounterDisabled;
  37458. private static _EndPerformanceCounterDisabled;
  37459. private static _StartUserMark;
  37460. private static _EndUserMark;
  37461. private static _StartPerformanceConsole;
  37462. private static _EndPerformanceConsole;
  37463. /**
  37464. * Starts a performance counter
  37465. */
  37466. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37467. /**
  37468. * Ends a specific performance coutner
  37469. */
  37470. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37471. /**
  37472. * Gets either window.performance.now() if supported or Date.now() else
  37473. */
  37474. static get Now(): number;
  37475. /**
  37476. * This method will return the name of the class used to create the instance of the given object.
  37477. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37478. * @param object the object to get the class name from
  37479. * @param isType defines if the object is actually a type
  37480. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37481. */
  37482. static GetClassName(object: any, isType?: boolean): string;
  37483. /**
  37484. * Gets the first element of an array satisfying a given predicate
  37485. * @param array defines the array to browse
  37486. * @param predicate defines the predicate to use
  37487. * @returns null if not found or the element
  37488. */
  37489. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37490. /**
  37491. * This method will return the name of the full name of the class, including its owning module (if any).
  37492. * 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).
  37493. * @param object the object to get the class name from
  37494. * @param isType defines if the object is actually a type
  37495. * @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.
  37496. * @ignorenaming
  37497. */
  37498. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37499. /**
  37500. * Returns a promise that resolves after the given amount of time.
  37501. * @param delay Number of milliseconds to delay
  37502. * @returns Promise that resolves after the given amount of time
  37503. */
  37504. static DelayAsync(delay: number): Promise<void>;
  37505. /**
  37506. * Utility function to detect if the current user agent is Safari
  37507. * @returns whether or not the current user agent is safari
  37508. */
  37509. static IsSafari(): boolean;
  37510. }
  37511. /**
  37512. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37513. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37514. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37515. * @param name The name of the class, case should be preserved
  37516. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37517. */
  37518. export function className(name: string, module?: string): (target: Object) => void;
  37519. /**
  37520. * An implementation of a loop for asynchronous functions.
  37521. */
  37522. export class AsyncLoop {
  37523. /**
  37524. * Defines the number of iterations for the loop
  37525. */
  37526. iterations: number;
  37527. /**
  37528. * Defines the current index of the loop.
  37529. */
  37530. index: number;
  37531. private _done;
  37532. private _fn;
  37533. private _successCallback;
  37534. /**
  37535. * Constructor.
  37536. * @param iterations the number of iterations.
  37537. * @param func the function to run each iteration
  37538. * @param successCallback the callback that will be called upon succesful execution
  37539. * @param offset starting offset.
  37540. */
  37541. constructor(
  37542. /**
  37543. * Defines the number of iterations for the loop
  37544. */
  37545. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37546. /**
  37547. * Execute the next iteration. Must be called after the last iteration was finished.
  37548. */
  37549. executeNext(): void;
  37550. /**
  37551. * Break the loop and run the success callback.
  37552. */
  37553. breakLoop(): void;
  37554. /**
  37555. * Create and run an async loop.
  37556. * @param iterations the number of iterations.
  37557. * @param fn the function to run each iteration
  37558. * @param successCallback the callback that will be called upon succesful execution
  37559. * @param offset starting offset.
  37560. * @returns the created async loop object
  37561. */
  37562. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37563. /**
  37564. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37565. * @param iterations total number of iterations
  37566. * @param syncedIterations number of synchronous iterations in each async iteration.
  37567. * @param fn the function to call each iteration.
  37568. * @param callback a success call back that will be called when iterating stops.
  37569. * @param breakFunction a break condition (optional)
  37570. * @param timeout timeout settings for the setTimeout function. default - 0.
  37571. * @returns the created async loop object
  37572. */
  37573. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37574. }
  37575. }
  37576. declare module BABYLON {
  37577. /**
  37578. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37579. * The underlying implementation relies on an associative array to ensure the best performances.
  37580. * The value can be anything including 'null' but except 'undefined'
  37581. */
  37582. export class StringDictionary<T> {
  37583. /**
  37584. * This will clear this dictionary and copy the content from the 'source' one.
  37585. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37586. * @param source the dictionary to take the content from and copy to this dictionary
  37587. */
  37588. copyFrom(source: StringDictionary<T>): void;
  37589. /**
  37590. * Get a value based from its key
  37591. * @param key the given key to get the matching value from
  37592. * @return the value if found, otherwise undefined is returned
  37593. */
  37594. get(key: string): T | undefined;
  37595. /**
  37596. * Get a value from its key or add it if it doesn't exist.
  37597. * This method will ensure you that a given key/data will be present in the dictionary.
  37598. * @param key the given key to get the matching value from
  37599. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37600. * The factory will only be invoked if there's no data for the given key.
  37601. * @return the value corresponding to the key.
  37602. */
  37603. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37604. /**
  37605. * Get a value from its key if present in the dictionary otherwise add it
  37606. * @param key the key to get the value from
  37607. * @param val if there's no such key/value pair in the dictionary add it with this value
  37608. * @return the value corresponding to the key
  37609. */
  37610. getOrAdd(key: string, val: T): T;
  37611. /**
  37612. * Check if there's a given key in the dictionary
  37613. * @param key the key to check for
  37614. * @return true if the key is present, false otherwise
  37615. */
  37616. contains(key: string): boolean;
  37617. /**
  37618. * Add a new key and its corresponding value
  37619. * @param key the key to add
  37620. * @param value the value corresponding to the key
  37621. * @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
  37622. */
  37623. add(key: string, value: T): boolean;
  37624. /**
  37625. * Update a specific value associated to a key
  37626. * @param key defines the key to use
  37627. * @param value defines the value to store
  37628. * @returns true if the value was updated (or false if the key was not found)
  37629. */
  37630. set(key: string, value: T): boolean;
  37631. /**
  37632. * Get the element of the given key and remove it from the dictionary
  37633. * @param key defines the key to search
  37634. * @returns the value associated with the key or null if not found
  37635. */
  37636. getAndRemove(key: string): Nullable<T>;
  37637. /**
  37638. * Remove a key/value from the dictionary.
  37639. * @param key the key to remove
  37640. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37641. */
  37642. remove(key: string): boolean;
  37643. /**
  37644. * Clear the whole content of the dictionary
  37645. */
  37646. clear(): void;
  37647. /**
  37648. * Gets the current count
  37649. */
  37650. get count(): number;
  37651. /**
  37652. * Execute a callback on each key/val of the dictionary.
  37653. * Note that you can remove any element in this dictionary in the callback implementation
  37654. * @param callback the callback to execute on a given key/value pair
  37655. */
  37656. forEach(callback: (key: string, val: T) => void): void;
  37657. /**
  37658. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37659. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37660. * Note that you can remove any element in this dictionary in the callback implementation
  37661. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37662. * @returns the first item
  37663. */
  37664. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37665. private _count;
  37666. private _data;
  37667. }
  37668. }
  37669. declare module BABYLON {
  37670. /** @hidden */
  37671. export interface ICollisionCoordinator {
  37672. createCollider(): Collider;
  37673. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37674. init(scene: Scene): void;
  37675. }
  37676. /** @hidden */
  37677. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37678. private _scene;
  37679. private _scaledPosition;
  37680. private _scaledVelocity;
  37681. private _finalPosition;
  37682. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37683. createCollider(): Collider;
  37684. init(scene: Scene): void;
  37685. private _collideWithWorld;
  37686. }
  37687. }
  37688. declare module BABYLON {
  37689. /**
  37690. * Class used to manage all inputs for the scene.
  37691. */
  37692. export class InputManager {
  37693. /** The distance in pixel that you have to move to prevent some events */
  37694. static DragMovementThreshold: number;
  37695. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37696. static LongPressDelay: number;
  37697. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37698. static DoubleClickDelay: number;
  37699. /** If you need to check double click without raising a single click at first click, enable this flag */
  37700. static ExclusiveDoubleClickMode: boolean;
  37701. private _wheelEventName;
  37702. private _onPointerMove;
  37703. private _onPointerDown;
  37704. private _onPointerUp;
  37705. private _initClickEvent;
  37706. private _initActionManager;
  37707. private _delayedSimpleClick;
  37708. private _delayedSimpleClickTimeout;
  37709. private _previousDelayedSimpleClickTimeout;
  37710. private _meshPickProceed;
  37711. private _previousButtonPressed;
  37712. private _currentPickResult;
  37713. private _previousPickResult;
  37714. private _totalPointersPressed;
  37715. private _doubleClickOccured;
  37716. private _pointerOverMesh;
  37717. private _pickedDownMesh;
  37718. private _pickedUpMesh;
  37719. private _pointerX;
  37720. private _pointerY;
  37721. private _unTranslatedPointerX;
  37722. private _unTranslatedPointerY;
  37723. private _startingPointerPosition;
  37724. private _previousStartingPointerPosition;
  37725. private _startingPointerTime;
  37726. private _previousStartingPointerTime;
  37727. private _pointerCaptures;
  37728. private _onKeyDown;
  37729. private _onKeyUp;
  37730. private _onCanvasFocusObserver;
  37731. private _onCanvasBlurObserver;
  37732. private _scene;
  37733. /**
  37734. * Creates a new InputManager
  37735. * @param scene defines the hosting scene
  37736. */
  37737. constructor(scene: Scene);
  37738. /**
  37739. * Gets the mesh that is currently under the pointer
  37740. */
  37741. get meshUnderPointer(): Nullable<AbstractMesh>;
  37742. /**
  37743. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37744. */
  37745. get unTranslatedPointer(): Vector2;
  37746. /**
  37747. * Gets or sets the current on-screen X position of the pointer
  37748. */
  37749. get pointerX(): number;
  37750. set pointerX(value: number);
  37751. /**
  37752. * Gets or sets the current on-screen Y position of the pointer
  37753. */
  37754. get pointerY(): number;
  37755. set pointerY(value: number);
  37756. private _updatePointerPosition;
  37757. private _processPointerMove;
  37758. private _setRayOnPointerInfo;
  37759. private _checkPrePointerObservable;
  37760. /**
  37761. * Use this method to simulate a pointer move on a mesh
  37762. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37763. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37764. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37765. */
  37766. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37767. /**
  37768. * Use this method to simulate a pointer down on a mesh
  37769. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37770. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37771. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37772. */
  37773. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37774. private _processPointerDown;
  37775. /** @hidden */
  37776. _isPointerSwiping(): boolean;
  37777. /**
  37778. * Use this method to simulate a pointer up on a mesh
  37779. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37780. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37781. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37782. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37783. */
  37784. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  37785. private _processPointerUp;
  37786. /**
  37787. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37788. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37789. * @returns true if the pointer was captured
  37790. */
  37791. isPointerCaptured(pointerId?: number): boolean;
  37792. /**
  37793. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37794. * @param attachUp defines if you want to attach events to pointerup
  37795. * @param attachDown defines if you want to attach events to pointerdown
  37796. * @param attachMove defines if you want to attach events to pointermove
  37797. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  37798. */
  37799. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  37800. /**
  37801. * Detaches all event handlers
  37802. */
  37803. detachControl(): void;
  37804. /**
  37805. * Force the value of meshUnderPointer
  37806. * @param mesh defines the mesh to use
  37807. */
  37808. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37809. /**
  37810. * Gets the mesh under the pointer
  37811. * @returns a Mesh or null if no mesh is under the pointer
  37812. */
  37813. getPointerOverMesh(): Nullable<AbstractMesh>;
  37814. }
  37815. }
  37816. declare module BABYLON {
  37817. /**
  37818. * This class defines the direct association between an animation and a target
  37819. */
  37820. export class TargetedAnimation {
  37821. /**
  37822. * Animation to perform
  37823. */
  37824. animation: Animation;
  37825. /**
  37826. * Target to animate
  37827. */
  37828. target: any;
  37829. /**
  37830. * Serialize the object
  37831. * @returns the JSON object representing the current entity
  37832. */
  37833. serialize(): any;
  37834. }
  37835. /**
  37836. * Use this class to create coordinated animations on multiple targets
  37837. */
  37838. export class AnimationGroup implements IDisposable {
  37839. /** The name of the animation group */
  37840. name: string;
  37841. private _scene;
  37842. private _targetedAnimations;
  37843. private _animatables;
  37844. private _from;
  37845. private _to;
  37846. private _isStarted;
  37847. private _isPaused;
  37848. private _speedRatio;
  37849. private _loopAnimation;
  37850. private _isAdditive;
  37851. /**
  37852. * Gets or sets the unique id of the node
  37853. */
  37854. uniqueId: number;
  37855. /**
  37856. * This observable will notify when one animation have ended
  37857. */
  37858. onAnimationEndObservable: Observable<TargetedAnimation>;
  37859. /**
  37860. * Observer raised when one animation loops
  37861. */
  37862. onAnimationLoopObservable: Observable<TargetedAnimation>;
  37863. /**
  37864. * Observer raised when all animations have looped
  37865. */
  37866. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  37867. /**
  37868. * This observable will notify when all animations have ended.
  37869. */
  37870. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  37871. /**
  37872. * This observable will notify when all animations have paused.
  37873. */
  37874. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  37875. /**
  37876. * This observable will notify when all animations are playing.
  37877. */
  37878. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  37879. /**
  37880. * Gets the first frame
  37881. */
  37882. get from(): number;
  37883. /**
  37884. * Gets the last frame
  37885. */
  37886. get to(): number;
  37887. /**
  37888. * Define if the animations are started
  37889. */
  37890. get isStarted(): boolean;
  37891. /**
  37892. * Gets a value indicating that the current group is playing
  37893. */
  37894. get isPlaying(): boolean;
  37895. /**
  37896. * Gets or sets the speed ratio to use for all animations
  37897. */
  37898. get speedRatio(): number;
  37899. /**
  37900. * Gets or sets the speed ratio to use for all animations
  37901. */
  37902. set speedRatio(value: number);
  37903. /**
  37904. * Gets or sets if all animations should loop or not
  37905. */
  37906. get loopAnimation(): boolean;
  37907. set loopAnimation(value: boolean);
  37908. /**
  37909. * Gets or sets if all animations should be evaluated additively
  37910. */
  37911. get isAdditive(): boolean;
  37912. set isAdditive(value: boolean);
  37913. /**
  37914. * Gets the targeted animations for this animation group
  37915. */
  37916. get targetedAnimations(): Array<TargetedAnimation>;
  37917. /**
  37918. * returning the list of animatables controlled by this animation group.
  37919. */
  37920. get animatables(): Array<Animatable>;
  37921. /**
  37922. * Instantiates a new Animation Group.
  37923. * This helps managing several animations at once.
  37924. * @see http://doc.babylonjs.com/how_to/group
  37925. * @param name Defines the name of the group
  37926. * @param scene Defines the scene the group belongs to
  37927. */
  37928. constructor(
  37929. /** The name of the animation group */
  37930. name: string, scene?: Nullable<Scene>);
  37931. /**
  37932. * Add an animation (with its target) in the group
  37933. * @param animation defines the animation we want to add
  37934. * @param target defines the target of the animation
  37935. * @returns the TargetedAnimation object
  37936. */
  37937. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  37938. /**
  37939. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  37940. * It can add constant keys at begin or end
  37941. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  37942. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  37943. * @returns the animation group
  37944. */
  37945. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  37946. private _animationLoopCount;
  37947. private _animationLoopFlags;
  37948. private _processLoop;
  37949. /**
  37950. * Start all animations on given targets
  37951. * @param loop defines if animations must loop
  37952. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  37953. * @param from defines the from key (optional)
  37954. * @param to defines the to key (optional)
  37955. * @param isAdditive defines the additive state for the resulting animatables (optional)
  37956. * @returns the current animation group
  37957. */
  37958. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  37959. /**
  37960. * Pause all animations
  37961. * @returns the animation group
  37962. */
  37963. pause(): AnimationGroup;
  37964. /**
  37965. * Play all animations to initial state
  37966. * This function will start() the animations if they were not started or will restart() them if they were paused
  37967. * @param loop defines if animations must loop
  37968. * @returns the animation group
  37969. */
  37970. play(loop?: boolean): AnimationGroup;
  37971. /**
  37972. * Reset all animations to initial state
  37973. * @returns the animation group
  37974. */
  37975. reset(): AnimationGroup;
  37976. /**
  37977. * Restart animations from key 0
  37978. * @returns the animation group
  37979. */
  37980. restart(): AnimationGroup;
  37981. /**
  37982. * Stop all animations
  37983. * @returns the animation group
  37984. */
  37985. stop(): AnimationGroup;
  37986. /**
  37987. * Set animation weight for all animatables
  37988. * @param weight defines the weight to use
  37989. * @return the animationGroup
  37990. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  37991. */
  37992. setWeightForAllAnimatables(weight: number): AnimationGroup;
  37993. /**
  37994. * Synchronize and normalize all animatables with a source animatable
  37995. * @param root defines the root animatable to synchronize with
  37996. * @return the animationGroup
  37997. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  37998. */
  37999. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38000. /**
  38001. * Goes to a specific frame in this animation group
  38002. * @param frame the frame number to go to
  38003. * @return the animationGroup
  38004. */
  38005. goToFrame(frame: number): AnimationGroup;
  38006. /**
  38007. * Dispose all associated resources
  38008. */
  38009. dispose(): void;
  38010. private _checkAnimationGroupEnded;
  38011. /**
  38012. * Clone the current animation group and returns a copy
  38013. * @param newName defines the name of the new group
  38014. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38015. * @returns the new aniamtion group
  38016. */
  38017. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38018. /**
  38019. * Serializes the animationGroup to an object
  38020. * @returns Serialized object
  38021. */
  38022. serialize(): any;
  38023. /**
  38024. * Returns a new AnimationGroup object parsed from the source provided.
  38025. * @param parsedAnimationGroup defines the source
  38026. * @param scene defines the scene that will receive the animationGroup
  38027. * @returns a new AnimationGroup
  38028. */
  38029. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38030. /**
  38031. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38032. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38033. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38034. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38035. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38036. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38037. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38038. */
  38039. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38040. /**
  38041. * Returns the string "AnimationGroup"
  38042. * @returns "AnimationGroup"
  38043. */
  38044. getClassName(): string;
  38045. /**
  38046. * Creates a detailled string about the object
  38047. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38048. * @returns a string representing the object
  38049. */
  38050. toString(fullDetails?: boolean): string;
  38051. }
  38052. }
  38053. declare module BABYLON {
  38054. /**
  38055. * Define an interface for all classes that will hold resources
  38056. */
  38057. export interface IDisposable {
  38058. /**
  38059. * Releases all held resources
  38060. */
  38061. dispose(): void;
  38062. }
  38063. /** Interface defining initialization parameters for Scene class */
  38064. export interface SceneOptions {
  38065. /**
  38066. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38067. * It will improve performance when the number of geometries becomes important.
  38068. */
  38069. useGeometryUniqueIdsMap?: boolean;
  38070. /**
  38071. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38072. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38073. */
  38074. useMaterialMeshMap?: boolean;
  38075. /**
  38076. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38077. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38078. */
  38079. useClonedMeshMap?: boolean;
  38080. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38081. virtual?: boolean;
  38082. }
  38083. /**
  38084. * Represents a scene to be rendered by the engine.
  38085. * @see http://doc.babylonjs.com/features/scene
  38086. */
  38087. export class Scene extends AbstractScene implements IAnimatable {
  38088. /** The fog is deactivated */
  38089. static readonly FOGMODE_NONE: number;
  38090. /** The fog density is following an exponential function */
  38091. static readonly FOGMODE_EXP: number;
  38092. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38093. static readonly FOGMODE_EXP2: number;
  38094. /** The fog density is following a linear function. */
  38095. static readonly FOGMODE_LINEAR: number;
  38096. /**
  38097. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38098. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38099. */
  38100. static MinDeltaTime: number;
  38101. /**
  38102. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38103. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38104. */
  38105. static MaxDeltaTime: number;
  38106. /**
  38107. * Factory used to create the default material.
  38108. * @param name The name of the material to create
  38109. * @param scene The scene to create the material for
  38110. * @returns The default material
  38111. */
  38112. static DefaultMaterialFactory(scene: Scene): Material;
  38113. /**
  38114. * Factory used to create the a collision coordinator.
  38115. * @returns The collision coordinator
  38116. */
  38117. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38118. /** @hidden */
  38119. _inputManager: InputManager;
  38120. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38121. cameraToUseForPointers: Nullable<Camera>;
  38122. /** @hidden */
  38123. readonly _isScene: boolean;
  38124. /** @hidden */
  38125. _blockEntityCollection: boolean;
  38126. /**
  38127. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38128. */
  38129. autoClear: boolean;
  38130. /**
  38131. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38132. */
  38133. autoClearDepthAndStencil: boolean;
  38134. /**
  38135. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38136. */
  38137. clearColor: Color4;
  38138. /**
  38139. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38140. */
  38141. ambientColor: Color3;
  38142. /**
  38143. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38144. * It should only be one of the following (if not the default embedded one):
  38145. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38146. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38147. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38148. * The material properties need to be setup according to the type of texture in use.
  38149. */
  38150. environmentBRDFTexture: BaseTexture;
  38151. /** @hidden */
  38152. protected _environmentTexture: Nullable<BaseTexture>;
  38153. /**
  38154. * Texture used in all pbr material as the reflection texture.
  38155. * As in the majority of the scene they are the same (exception for multi room and so on),
  38156. * this is easier to reference from here than from all the materials.
  38157. */
  38158. get environmentTexture(): Nullable<BaseTexture>;
  38159. /**
  38160. * Texture used in all pbr material as the reflection texture.
  38161. * As in the majority of the scene they are the same (exception for multi room and so on),
  38162. * this is easier to set here than in all the materials.
  38163. */
  38164. set environmentTexture(value: Nullable<BaseTexture>);
  38165. /** @hidden */
  38166. protected _environmentIntensity: number;
  38167. /**
  38168. * Intensity of the environment in all pbr material.
  38169. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38170. * As in the majority of the scene they are the same (exception for multi room and so on),
  38171. * this is easier to reference from here than from all the materials.
  38172. */
  38173. get environmentIntensity(): number;
  38174. /**
  38175. * Intensity of the environment in all pbr material.
  38176. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38177. * As in the majority of the scene they are the same (exception for multi room and so on),
  38178. * this is easier to set here than in all the materials.
  38179. */
  38180. set environmentIntensity(value: number);
  38181. /** @hidden */
  38182. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38183. /**
  38184. * Default image processing configuration used either in the rendering
  38185. * Forward main pass or through the imageProcessingPostProcess if present.
  38186. * As in the majority of the scene they are the same (exception for multi camera),
  38187. * this is easier to reference from here than from all the materials and post process.
  38188. *
  38189. * No setter as we it is a shared configuration, you can set the values instead.
  38190. */
  38191. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38192. private _forceWireframe;
  38193. /**
  38194. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38195. */
  38196. set forceWireframe(value: boolean);
  38197. get forceWireframe(): boolean;
  38198. private _skipFrustumClipping;
  38199. /**
  38200. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38201. */
  38202. set skipFrustumClipping(value: boolean);
  38203. get skipFrustumClipping(): boolean;
  38204. private _forcePointsCloud;
  38205. /**
  38206. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38207. */
  38208. set forcePointsCloud(value: boolean);
  38209. get forcePointsCloud(): boolean;
  38210. /**
  38211. * Gets or sets the active clipplane 1
  38212. */
  38213. clipPlane: Nullable<Plane>;
  38214. /**
  38215. * Gets or sets the active clipplane 2
  38216. */
  38217. clipPlane2: Nullable<Plane>;
  38218. /**
  38219. * Gets or sets the active clipplane 3
  38220. */
  38221. clipPlane3: Nullable<Plane>;
  38222. /**
  38223. * Gets or sets the active clipplane 4
  38224. */
  38225. clipPlane4: Nullable<Plane>;
  38226. /**
  38227. * Gets or sets the active clipplane 5
  38228. */
  38229. clipPlane5: Nullable<Plane>;
  38230. /**
  38231. * Gets or sets the active clipplane 6
  38232. */
  38233. clipPlane6: Nullable<Plane>;
  38234. /**
  38235. * Gets or sets a boolean indicating if animations are enabled
  38236. */
  38237. animationsEnabled: boolean;
  38238. private _animationPropertiesOverride;
  38239. /**
  38240. * Gets or sets the animation properties override
  38241. */
  38242. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38243. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38244. /**
  38245. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38246. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38247. */
  38248. useConstantAnimationDeltaTime: boolean;
  38249. /**
  38250. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38251. * Please note that it requires to run a ray cast through the scene on every frame
  38252. */
  38253. constantlyUpdateMeshUnderPointer: boolean;
  38254. /**
  38255. * Defines the HTML cursor to use when hovering over interactive elements
  38256. */
  38257. hoverCursor: string;
  38258. /**
  38259. * Defines the HTML default cursor to use (empty by default)
  38260. */
  38261. defaultCursor: string;
  38262. /**
  38263. * Defines whether cursors are handled by the scene.
  38264. */
  38265. doNotHandleCursors: boolean;
  38266. /**
  38267. * This is used to call preventDefault() on pointer down
  38268. * in order to block unwanted artifacts like system double clicks
  38269. */
  38270. preventDefaultOnPointerDown: boolean;
  38271. /**
  38272. * This is used to call preventDefault() on pointer up
  38273. * in order to block unwanted artifacts like system double clicks
  38274. */
  38275. preventDefaultOnPointerUp: boolean;
  38276. /**
  38277. * Gets or sets user defined metadata
  38278. */
  38279. metadata: any;
  38280. /**
  38281. * For internal use only. Please do not use.
  38282. */
  38283. reservedDataStore: any;
  38284. /**
  38285. * Gets the name of the plugin used to load this scene (null by default)
  38286. */
  38287. loadingPluginName: string;
  38288. /**
  38289. * Use this array to add regular expressions used to disable offline support for specific urls
  38290. */
  38291. disableOfflineSupportExceptionRules: RegExp[];
  38292. /**
  38293. * An event triggered when the scene is disposed.
  38294. */
  38295. onDisposeObservable: Observable<Scene>;
  38296. private _onDisposeObserver;
  38297. /** Sets a function to be executed when this scene is disposed. */
  38298. set onDispose(callback: () => void);
  38299. /**
  38300. * An event triggered before rendering the scene (right after animations and physics)
  38301. */
  38302. onBeforeRenderObservable: Observable<Scene>;
  38303. private _onBeforeRenderObserver;
  38304. /** Sets a function to be executed before rendering this scene */
  38305. set beforeRender(callback: Nullable<() => void>);
  38306. /**
  38307. * An event triggered after rendering the scene
  38308. */
  38309. onAfterRenderObservable: Observable<Scene>;
  38310. /**
  38311. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38312. */
  38313. onAfterRenderCameraObservable: Observable<Camera>;
  38314. private _onAfterRenderObserver;
  38315. /** Sets a function to be executed after rendering this scene */
  38316. set afterRender(callback: Nullable<() => void>);
  38317. /**
  38318. * An event triggered before animating the scene
  38319. */
  38320. onBeforeAnimationsObservable: Observable<Scene>;
  38321. /**
  38322. * An event triggered after animations processing
  38323. */
  38324. onAfterAnimationsObservable: Observable<Scene>;
  38325. /**
  38326. * An event triggered before draw calls are ready to be sent
  38327. */
  38328. onBeforeDrawPhaseObservable: Observable<Scene>;
  38329. /**
  38330. * An event triggered after draw calls have been sent
  38331. */
  38332. onAfterDrawPhaseObservable: Observable<Scene>;
  38333. /**
  38334. * An event triggered when the scene is ready
  38335. */
  38336. onReadyObservable: Observable<Scene>;
  38337. /**
  38338. * An event triggered before rendering a camera
  38339. */
  38340. onBeforeCameraRenderObservable: Observable<Camera>;
  38341. private _onBeforeCameraRenderObserver;
  38342. /** Sets a function to be executed before rendering a camera*/
  38343. set beforeCameraRender(callback: () => void);
  38344. /**
  38345. * An event triggered after rendering a camera
  38346. */
  38347. onAfterCameraRenderObservable: Observable<Camera>;
  38348. private _onAfterCameraRenderObserver;
  38349. /** Sets a function to be executed after rendering a camera*/
  38350. set afterCameraRender(callback: () => void);
  38351. /**
  38352. * An event triggered when active meshes evaluation is about to start
  38353. */
  38354. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38355. /**
  38356. * An event triggered when active meshes evaluation is done
  38357. */
  38358. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38359. /**
  38360. * An event triggered when particles rendering is about to start
  38361. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38362. */
  38363. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38364. /**
  38365. * An event triggered when particles rendering is done
  38366. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38367. */
  38368. onAfterParticlesRenderingObservable: Observable<Scene>;
  38369. /**
  38370. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38371. */
  38372. onDataLoadedObservable: Observable<Scene>;
  38373. /**
  38374. * An event triggered when a camera is created
  38375. */
  38376. onNewCameraAddedObservable: Observable<Camera>;
  38377. /**
  38378. * An event triggered when a camera is removed
  38379. */
  38380. onCameraRemovedObservable: Observable<Camera>;
  38381. /**
  38382. * An event triggered when a light is created
  38383. */
  38384. onNewLightAddedObservable: Observable<Light>;
  38385. /**
  38386. * An event triggered when a light is removed
  38387. */
  38388. onLightRemovedObservable: Observable<Light>;
  38389. /**
  38390. * An event triggered when a geometry is created
  38391. */
  38392. onNewGeometryAddedObservable: Observable<Geometry>;
  38393. /**
  38394. * An event triggered when a geometry is removed
  38395. */
  38396. onGeometryRemovedObservable: Observable<Geometry>;
  38397. /**
  38398. * An event triggered when a transform node is created
  38399. */
  38400. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38401. /**
  38402. * An event triggered when a transform node is removed
  38403. */
  38404. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38405. /**
  38406. * An event triggered when a mesh is created
  38407. */
  38408. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38409. /**
  38410. * An event triggered when a mesh is removed
  38411. */
  38412. onMeshRemovedObservable: Observable<AbstractMesh>;
  38413. /**
  38414. * An event triggered when a skeleton is created
  38415. */
  38416. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38417. /**
  38418. * An event triggered when a skeleton is removed
  38419. */
  38420. onSkeletonRemovedObservable: Observable<Skeleton>;
  38421. /**
  38422. * An event triggered when a material is created
  38423. */
  38424. onNewMaterialAddedObservable: Observable<Material>;
  38425. /**
  38426. * An event triggered when a material is removed
  38427. */
  38428. onMaterialRemovedObservable: Observable<Material>;
  38429. /**
  38430. * An event triggered when a texture is created
  38431. */
  38432. onNewTextureAddedObservable: Observable<BaseTexture>;
  38433. /**
  38434. * An event triggered when a texture is removed
  38435. */
  38436. onTextureRemovedObservable: Observable<BaseTexture>;
  38437. /**
  38438. * An event triggered when render targets are about to be rendered
  38439. * Can happen multiple times per frame.
  38440. */
  38441. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38442. /**
  38443. * An event triggered when render targets were rendered.
  38444. * Can happen multiple times per frame.
  38445. */
  38446. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38447. /**
  38448. * An event triggered before calculating deterministic simulation step
  38449. */
  38450. onBeforeStepObservable: Observable<Scene>;
  38451. /**
  38452. * An event triggered after calculating deterministic simulation step
  38453. */
  38454. onAfterStepObservable: Observable<Scene>;
  38455. /**
  38456. * An event triggered when the activeCamera property is updated
  38457. */
  38458. onActiveCameraChanged: Observable<Scene>;
  38459. /**
  38460. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38461. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38462. * 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)
  38463. */
  38464. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38465. /**
  38466. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38467. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38468. * 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)
  38469. */
  38470. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38471. /**
  38472. * This Observable will when a mesh has been imported into the scene.
  38473. */
  38474. onMeshImportedObservable: Observable<AbstractMesh>;
  38475. /**
  38476. * This Observable will when an animation file has been imported into the scene.
  38477. */
  38478. onAnimationFileImportedObservable: Observable<Scene>;
  38479. /**
  38480. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38481. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38482. */
  38483. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38484. /** @hidden */
  38485. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38486. /**
  38487. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38488. */
  38489. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38490. /**
  38491. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38492. */
  38493. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38494. /**
  38495. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38496. */
  38497. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38498. /** Callback called when a pointer move is detected */
  38499. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38500. /** Callback called when a pointer down is detected */
  38501. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38502. /** Callback called when a pointer up is detected */
  38503. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38504. /** Callback called when a pointer pick is detected */
  38505. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38506. /**
  38507. * 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).
  38508. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38509. */
  38510. onPrePointerObservable: Observable<PointerInfoPre>;
  38511. /**
  38512. * Observable event triggered each time an input event is received from the rendering canvas
  38513. */
  38514. onPointerObservable: Observable<PointerInfo>;
  38515. /**
  38516. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38517. */
  38518. get unTranslatedPointer(): Vector2;
  38519. /**
  38520. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38521. */
  38522. static get DragMovementThreshold(): number;
  38523. static set DragMovementThreshold(value: number);
  38524. /**
  38525. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38526. */
  38527. static get LongPressDelay(): number;
  38528. static set LongPressDelay(value: number);
  38529. /**
  38530. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38531. */
  38532. static get DoubleClickDelay(): number;
  38533. static set DoubleClickDelay(value: number);
  38534. /** If you need to check double click without raising a single click at first click, enable this flag */
  38535. static get ExclusiveDoubleClickMode(): boolean;
  38536. static set ExclusiveDoubleClickMode(value: boolean);
  38537. /** @hidden */
  38538. _mirroredCameraPosition: Nullable<Vector3>;
  38539. /**
  38540. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38541. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38542. */
  38543. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38544. /**
  38545. * Observable event triggered each time an keyboard event is received from the hosting window
  38546. */
  38547. onKeyboardObservable: Observable<KeyboardInfo>;
  38548. private _useRightHandedSystem;
  38549. /**
  38550. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38551. */
  38552. set useRightHandedSystem(value: boolean);
  38553. get useRightHandedSystem(): boolean;
  38554. private _timeAccumulator;
  38555. private _currentStepId;
  38556. private _currentInternalStep;
  38557. /**
  38558. * Sets the step Id used by deterministic lock step
  38559. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38560. * @param newStepId defines the step Id
  38561. */
  38562. setStepId(newStepId: number): void;
  38563. /**
  38564. * Gets the step Id used by deterministic lock step
  38565. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38566. * @returns the step Id
  38567. */
  38568. getStepId(): number;
  38569. /**
  38570. * Gets the internal step used by deterministic lock step
  38571. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38572. * @returns the internal step
  38573. */
  38574. getInternalStep(): number;
  38575. private _fogEnabled;
  38576. /**
  38577. * Gets or sets a boolean indicating if fog is enabled on this scene
  38578. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38579. * (Default is true)
  38580. */
  38581. set fogEnabled(value: boolean);
  38582. get fogEnabled(): boolean;
  38583. private _fogMode;
  38584. /**
  38585. * Gets or sets the fog mode to use
  38586. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38587. * | mode | value |
  38588. * | --- | --- |
  38589. * | FOGMODE_NONE | 0 |
  38590. * | FOGMODE_EXP | 1 |
  38591. * | FOGMODE_EXP2 | 2 |
  38592. * | FOGMODE_LINEAR | 3 |
  38593. */
  38594. set fogMode(value: number);
  38595. get fogMode(): number;
  38596. /**
  38597. * Gets or sets the fog color to use
  38598. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38599. * (Default is Color3(0.2, 0.2, 0.3))
  38600. */
  38601. fogColor: Color3;
  38602. /**
  38603. * Gets or sets the fog density to use
  38604. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38605. * (Default is 0.1)
  38606. */
  38607. fogDensity: number;
  38608. /**
  38609. * Gets or sets the fog start distance to use
  38610. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38611. * (Default is 0)
  38612. */
  38613. fogStart: number;
  38614. /**
  38615. * Gets or sets the fog end distance to use
  38616. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38617. * (Default is 1000)
  38618. */
  38619. fogEnd: number;
  38620. private _shadowsEnabled;
  38621. /**
  38622. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38623. */
  38624. set shadowsEnabled(value: boolean);
  38625. get shadowsEnabled(): boolean;
  38626. private _lightsEnabled;
  38627. /**
  38628. * Gets or sets a boolean indicating if lights are enabled on this scene
  38629. */
  38630. set lightsEnabled(value: boolean);
  38631. get lightsEnabled(): boolean;
  38632. /** All of the active cameras added to this scene. */
  38633. activeCameras: Camera[];
  38634. /** @hidden */
  38635. _activeCamera: Nullable<Camera>;
  38636. /** Gets or sets the current active camera */
  38637. get activeCamera(): Nullable<Camera>;
  38638. set activeCamera(value: Nullable<Camera>);
  38639. private _defaultMaterial;
  38640. /** The default material used on meshes when no material is affected */
  38641. get defaultMaterial(): Material;
  38642. /** The default material used on meshes when no material is affected */
  38643. set defaultMaterial(value: Material);
  38644. private _texturesEnabled;
  38645. /**
  38646. * Gets or sets a boolean indicating if textures are enabled on this scene
  38647. */
  38648. set texturesEnabled(value: boolean);
  38649. get texturesEnabled(): boolean;
  38650. /**
  38651. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38652. */
  38653. physicsEnabled: boolean;
  38654. /**
  38655. * Gets or sets a boolean indicating if particles are enabled on this scene
  38656. */
  38657. particlesEnabled: boolean;
  38658. /**
  38659. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38660. */
  38661. spritesEnabled: boolean;
  38662. private _skeletonsEnabled;
  38663. /**
  38664. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38665. */
  38666. set skeletonsEnabled(value: boolean);
  38667. get skeletonsEnabled(): boolean;
  38668. /**
  38669. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38670. */
  38671. lensFlaresEnabled: boolean;
  38672. /**
  38673. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38674. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38675. */
  38676. collisionsEnabled: boolean;
  38677. private _collisionCoordinator;
  38678. /** @hidden */
  38679. get collisionCoordinator(): ICollisionCoordinator;
  38680. /**
  38681. * Defines the gravity applied to this scene (used only for collisions)
  38682. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38683. */
  38684. gravity: Vector3;
  38685. /**
  38686. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38687. */
  38688. postProcessesEnabled: boolean;
  38689. /**
  38690. * The list of postprocesses added to the scene
  38691. */
  38692. postProcesses: PostProcess[];
  38693. /**
  38694. * Gets the current postprocess manager
  38695. */
  38696. postProcessManager: PostProcessManager;
  38697. /**
  38698. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38699. */
  38700. renderTargetsEnabled: boolean;
  38701. /**
  38702. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38703. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38704. */
  38705. dumpNextRenderTargets: boolean;
  38706. /**
  38707. * The list of user defined render targets added to the scene
  38708. */
  38709. customRenderTargets: RenderTargetTexture[];
  38710. /**
  38711. * Defines if texture loading must be delayed
  38712. * If true, textures will only be loaded when they need to be rendered
  38713. */
  38714. useDelayedTextureLoading: boolean;
  38715. /**
  38716. * Gets the list of meshes imported to the scene through SceneLoader
  38717. */
  38718. importedMeshesFiles: String[];
  38719. /**
  38720. * Gets or sets a boolean indicating if probes are enabled on this scene
  38721. */
  38722. probesEnabled: boolean;
  38723. /**
  38724. * Gets or sets the current offline provider to use to store scene data
  38725. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38726. */
  38727. offlineProvider: IOfflineProvider;
  38728. /**
  38729. * Gets or sets the action manager associated with the scene
  38730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38731. */
  38732. actionManager: AbstractActionManager;
  38733. private _meshesForIntersections;
  38734. /**
  38735. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38736. */
  38737. proceduralTexturesEnabled: boolean;
  38738. private _engine;
  38739. private _totalVertices;
  38740. /** @hidden */
  38741. _activeIndices: PerfCounter;
  38742. /** @hidden */
  38743. _activeParticles: PerfCounter;
  38744. /** @hidden */
  38745. _activeBones: PerfCounter;
  38746. private _animationRatio;
  38747. /** @hidden */
  38748. _animationTimeLast: number;
  38749. /** @hidden */
  38750. _animationTime: number;
  38751. /**
  38752. * Gets or sets a general scale for animation speed
  38753. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38754. */
  38755. animationTimeScale: number;
  38756. /** @hidden */
  38757. _cachedMaterial: Nullable<Material>;
  38758. /** @hidden */
  38759. _cachedEffect: Nullable<Effect>;
  38760. /** @hidden */
  38761. _cachedVisibility: Nullable<number>;
  38762. private _renderId;
  38763. private _frameId;
  38764. private _executeWhenReadyTimeoutId;
  38765. private _intermediateRendering;
  38766. private _viewUpdateFlag;
  38767. private _projectionUpdateFlag;
  38768. /** @hidden */
  38769. _toBeDisposed: Nullable<IDisposable>[];
  38770. private _activeRequests;
  38771. /** @hidden */
  38772. _pendingData: any[];
  38773. private _isDisposed;
  38774. /**
  38775. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  38776. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  38777. */
  38778. dispatchAllSubMeshesOfActiveMeshes: boolean;
  38779. private _activeMeshes;
  38780. private _processedMaterials;
  38781. private _renderTargets;
  38782. /** @hidden */
  38783. _activeParticleSystems: SmartArray<IParticleSystem>;
  38784. private _activeSkeletons;
  38785. private _softwareSkinnedMeshes;
  38786. private _renderingManager;
  38787. /** @hidden */
  38788. _activeAnimatables: Animatable[];
  38789. private _transformMatrix;
  38790. private _sceneUbo;
  38791. /** @hidden */
  38792. _viewMatrix: Matrix;
  38793. private _projectionMatrix;
  38794. /** @hidden */
  38795. _forcedViewPosition: Nullable<Vector3>;
  38796. /** @hidden */
  38797. _frustumPlanes: Plane[];
  38798. /**
  38799. * Gets the list of frustum planes (built from the active camera)
  38800. */
  38801. get frustumPlanes(): Plane[];
  38802. /**
  38803. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  38804. * This is useful if there are more lights that the maximum simulteanous authorized
  38805. */
  38806. requireLightSorting: boolean;
  38807. /** @hidden */
  38808. readonly useMaterialMeshMap: boolean;
  38809. /** @hidden */
  38810. readonly useClonedMeshMap: boolean;
  38811. private _externalData;
  38812. private _uid;
  38813. /**
  38814. * @hidden
  38815. * Backing store of defined scene components.
  38816. */
  38817. _components: ISceneComponent[];
  38818. /**
  38819. * @hidden
  38820. * Backing store of defined scene components.
  38821. */
  38822. _serializableComponents: ISceneSerializableComponent[];
  38823. /**
  38824. * List of components to register on the next registration step.
  38825. */
  38826. private _transientComponents;
  38827. /**
  38828. * Registers the transient components if needed.
  38829. */
  38830. private _registerTransientComponents;
  38831. /**
  38832. * @hidden
  38833. * Add a component to the scene.
  38834. * Note that the ccomponent could be registered on th next frame if this is called after
  38835. * the register component stage.
  38836. * @param component Defines the component to add to the scene
  38837. */
  38838. _addComponent(component: ISceneComponent): void;
  38839. /**
  38840. * @hidden
  38841. * Gets a component from the scene.
  38842. * @param name defines the name of the component to retrieve
  38843. * @returns the component or null if not present
  38844. */
  38845. _getComponent(name: string): Nullable<ISceneComponent>;
  38846. /**
  38847. * @hidden
  38848. * Defines the actions happening before camera updates.
  38849. */
  38850. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  38851. /**
  38852. * @hidden
  38853. * Defines the actions happening before clear the canvas.
  38854. */
  38855. _beforeClearStage: Stage<SimpleStageAction>;
  38856. /**
  38857. * @hidden
  38858. * Defines the actions when collecting render targets for the frame.
  38859. */
  38860. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38861. /**
  38862. * @hidden
  38863. * Defines the actions happening for one camera in the frame.
  38864. */
  38865. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38866. /**
  38867. * @hidden
  38868. * Defines the actions happening during the per mesh ready checks.
  38869. */
  38870. _isReadyForMeshStage: Stage<MeshStageAction>;
  38871. /**
  38872. * @hidden
  38873. * Defines the actions happening before evaluate active mesh checks.
  38874. */
  38875. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  38876. /**
  38877. * @hidden
  38878. * Defines the actions happening during the evaluate sub mesh checks.
  38879. */
  38880. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  38881. /**
  38882. * @hidden
  38883. * Defines the actions happening during the active mesh stage.
  38884. */
  38885. _activeMeshStage: Stage<ActiveMeshStageAction>;
  38886. /**
  38887. * @hidden
  38888. * Defines the actions happening during the per camera render target step.
  38889. */
  38890. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  38891. /**
  38892. * @hidden
  38893. * Defines the actions happening just before the active camera is drawing.
  38894. */
  38895. _beforeCameraDrawStage: Stage<CameraStageAction>;
  38896. /**
  38897. * @hidden
  38898. * Defines the actions happening just before a render target is drawing.
  38899. */
  38900. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38901. /**
  38902. * @hidden
  38903. * Defines the actions happening just before a rendering group is drawing.
  38904. */
  38905. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38906. /**
  38907. * @hidden
  38908. * Defines the actions happening just before a mesh is drawing.
  38909. */
  38910. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38911. /**
  38912. * @hidden
  38913. * Defines the actions happening just after a mesh has been drawn.
  38914. */
  38915. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38916. /**
  38917. * @hidden
  38918. * Defines the actions happening just after a rendering group has been drawn.
  38919. */
  38920. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38921. /**
  38922. * @hidden
  38923. * Defines the actions happening just after the active camera has been drawn.
  38924. */
  38925. _afterCameraDrawStage: Stage<CameraStageAction>;
  38926. /**
  38927. * @hidden
  38928. * Defines the actions happening just after a render target has been drawn.
  38929. */
  38930. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38931. /**
  38932. * @hidden
  38933. * Defines the actions happening just after rendering all cameras and computing intersections.
  38934. */
  38935. _afterRenderStage: Stage<SimpleStageAction>;
  38936. /**
  38937. * @hidden
  38938. * Defines the actions happening when a pointer move event happens.
  38939. */
  38940. _pointerMoveStage: Stage<PointerMoveStageAction>;
  38941. /**
  38942. * @hidden
  38943. * Defines the actions happening when a pointer down event happens.
  38944. */
  38945. _pointerDownStage: Stage<PointerUpDownStageAction>;
  38946. /**
  38947. * @hidden
  38948. * Defines the actions happening when a pointer up event happens.
  38949. */
  38950. _pointerUpStage: Stage<PointerUpDownStageAction>;
  38951. /**
  38952. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  38953. */
  38954. private geometriesByUniqueId;
  38955. /**
  38956. * Creates a new Scene
  38957. * @param engine defines the engine to use to render this scene
  38958. * @param options defines the scene options
  38959. */
  38960. constructor(engine: Engine, options?: SceneOptions);
  38961. /**
  38962. * Gets a string idenfifying the name of the class
  38963. * @returns "Scene" string
  38964. */
  38965. getClassName(): string;
  38966. private _defaultMeshCandidates;
  38967. /**
  38968. * @hidden
  38969. */
  38970. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  38971. private _defaultSubMeshCandidates;
  38972. /**
  38973. * @hidden
  38974. */
  38975. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  38976. /**
  38977. * Sets the default candidate providers for the scene.
  38978. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  38979. * and getCollidingSubMeshCandidates to their default function
  38980. */
  38981. setDefaultCandidateProviders(): void;
  38982. /**
  38983. * Gets the mesh that is currently under the pointer
  38984. */
  38985. get meshUnderPointer(): Nullable<AbstractMesh>;
  38986. /**
  38987. * Gets or sets the current on-screen X position of the pointer
  38988. */
  38989. get pointerX(): number;
  38990. set pointerX(value: number);
  38991. /**
  38992. * Gets or sets the current on-screen Y position of the pointer
  38993. */
  38994. get pointerY(): number;
  38995. set pointerY(value: number);
  38996. /**
  38997. * Gets the cached material (ie. the latest rendered one)
  38998. * @returns the cached material
  38999. */
  39000. getCachedMaterial(): Nullable<Material>;
  39001. /**
  39002. * Gets the cached effect (ie. the latest rendered one)
  39003. * @returns the cached effect
  39004. */
  39005. getCachedEffect(): Nullable<Effect>;
  39006. /**
  39007. * Gets the cached visibility state (ie. the latest rendered one)
  39008. * @returns the cached visibility state
  39009. */
  39010. getCachedVisibility(): Nullable<number>;
  39011. /**
  39012. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39013. * @param material defines the current material
  39014. * @param effect defines the current effect
  39015. * @param visibility defines the current visibility state
  39016. * @returns true if one parameter is not cached
  39017. */
  39018. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39019. /**
  39020. * Gets the engine associated with the scene
  39021. * @returns an Engine
  39022. */
  39023. getEngine(): Engine;
  39024. /**
  39025. * Gets the total number of vertices rendered per frame
  39026. * @returns the total number of vertices rendered per frame
  39027. */
  39028. getTotalVertices(): number;
  39029. /**
  39030. * Gets the performance counter for total vertices
  39031. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39032. */
  39033. get totalVerticesPerfCounter(): PerfCounter;
  39034. /**
  39035. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39036. * @returns the total number of active indices rendered per frame
  39037. */
  39038. getActiveIndices(): number;
  39039. /**
  39040. * Gets the performance counter for active indices
  39041. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39042. */
  39043. get totalActiveIndicesPerfCounter(): PerfCounter;
  39044. /**
  39045. * Gets the total number of active particles rendered per frame
  39046. * @returns the total number of active particles rendered per frame
  39047. */
  39048. getActiveParticles(): number;
  39049. /**
  39050. * Gets the performance counter for active particles
  39051. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39052. */
  39053. get activeParticlesPerfCounter(): PerfCounter;
  39054. /**
  39055. * Gets the total number of active bones rendered per frame
  39056. * @returns the total number of active bones rendered per frame
  39057. */
  39058. getActiveBones(): number;
  39059. /**
  39060. * Gets the performance counter for active bones
  39061. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39062. */
  39063. get activeBonesPerfCounter(): PerfCounter;
  39064. /**
  39065. * Gets the array of active meshes
  39066. * @returns an array of AbstractMesh
  39067. */
  39068. getActiveMeshes(): SmartArray<AbstractMesh>;
  39069. /**
  39070. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39071. * @returns a number
  39072. */
  39073. getAnimationRatio(): number;
  39074. /**
  39075. * Gets an unique Id for the current render phase
  39076. * @returns a number
  39077. */
  39078. getRenderId(): number;
  39079. /**
  39080. * Gets an unique Id for the current frame
  39081. * @returns a number
  39082. */
  39083. getFrameId(): number;
  39084. /** Call this function if you want to manually increment the render Id*/
  39085. incrementRenderId(): void;
  39086. private _createUbo;
  39087. /**
  39088. * Use this method to simulate a pointer move on a mesh
  39089. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39090. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39091. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39092. * @returns the current scene
  39093. */
  39094. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39095. /**
  39096. * Use this method to simulate a pointer down on a mesh
  39097. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39098. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39099. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39100. * @returns the current scene
  39101. */
  39102. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39103. /**
  39104. * Use this method to simulate a pointer up on a mesh
  39105. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39106. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39107. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39108. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39109. * @returns the current scene
  39110. */
  39111. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39112. /**
  39113. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39114. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39115. * @returns true if the pointer was captured
  39116. */
  39117. isPointerCaptured(pointerId?: number): boolean;
  39118. /**
  39119. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39120. * @param attachUp defines if you want to attach events to pointerup
  39121. * @param attachDown defines if you want to attach events to pointerdown
  39122. * @param attachMove defines if you want to attach events to pointermove
  39123. */
  39124. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39125. /** Detaches all event handlers*/
  39126. detachControl(): void;
  39127. /**
  39128. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39129. * Delay loaded resources are not taking in account
  39130. * @return true if all required resources are ready
  39131. */
  39132. isReady(): boolean;
  39133. /** Resets all cached information relative to material (including effect and visibility) */
  39134. resetCachedMaterial(): void;
  39135. /**
  39136. * Registers a function to be called before every frame render
  39137. * @param func defines the function to register
  39138. */
  39139. registerBeforeRender(func: () => void): void;
  39140. /**
  39141. * Unregisters a function called before every frame render
  39142. * @param func defines the function to unregister
  39143. */
  39144. unregisterBeforeRender(func: () => void): void;
  39145. /**
  39146. * Registers a function to be called after every frame render
  39147. * @param func defines the function to register
  39148. */
  39149. registerAfterRender(func: () => void): void;
  39150. /**
  39151. * Unregisters a function called after every frame render
  39152. * @param func defines the function to unregister
  39153. */
  39154. unregisterAfterRender(func: () => void): void;
  39155. private _executeOnceBeforeRender;
  39156. /**
  39157. * The provided function will run before render once and will be disposed afterwards.
  39158. * A timeout delay can be provided so that the function will be executed in N ms.
  39159. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39160. * @param func The function to be executed.
  39161. * @param timeout optional delay in ms
  39162. */
  39163. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39164. /** @hidden */
  39165. _addPendingData(data: any): void;
  39166. /** @hidden */
  39167. _removePendingData(data: any): void;
  39168. /**
  39169. * Returns the number of items waiting to be loaded
  39170. * @returns the number of items waiting to be loaded
  39171. */
  39172. getWaitingItemsCount(): number;
  39173. /**
  39174. * Returns a boolean indicating if the scene is still loading data
  39175. */
  39176. get isLoading(): boolean;
  39177. /**
  39178. * Registers a function to be executed when the scene is ready
  39179. * @param {Function} func - the function to be executed
  39180. */
  39181. executeWhenReady(func: () => void): void;
  39182. /**
  39183. * Returns a promise that resolves when the scene is ready
  39184. * @returns A promise that resolves when the scene is ready
  39185. */
  39186. whenReadyAsync(): Promise<void>;
  39187. /** @hidden */
  39188. _checkIsReady(): void;
  39189. /**
  39190. * Gets all animatable attached to the scene
  39191. */
  39192. get animatables(): Animatable[];
  39193. /**
  39194. * Resets the last animation time frame.
  39195. * Useful to override when animations start running when loading a scene for the first time.
  39196. */
  39197. resetLastAnimationTimeFrame(): void;
  39198. /**
  39199. * Gets the current view matrix
  39200. * @returns a Matrix
  39201. */
  39202. getViewMatrix(): Matrix;
  39203. /**
  39204. * Gets the current projection matrix
  39205. * @returns a Matrix
  39206. */
  39207. getProjectionMatrix(): Matrix;
  39208. /**
  39209. * Gets the current transform matrix
  39210. * @returns a Matrix made of View * Projection
  39211. */
  39212. getTransformMatrix(): Matrix;
  39213. /**
  39214. * Sets the current transform matrix
  39215. * @param viewL defines the View matrix to use
  39216. * @param projectionL defines the Projection matrix to use
  39217. * @param viewR defines the right View matrix to use (if provided)
  39218. * @param projectionR defines the right Projection matrix to use (if provided)
  39219. */
  39220. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39221. /**
  39222. * Gets the uniform buffer used to store scene data
  39223. * @returns a UniformBuffer
  39224. */
  39225. getSceneUniformBuffer(): UniformBuffer;
  39226. /**
  39227. * Gets an unique (relatively to the current scene) Id
  39228. * @returns an unique number for the scene
  39229. */
  39230. getUniqueId(): number;
  39231. /**
  39232. * Add a mesh to the list of scene's meshes
  39233. * @param newMesh defines the mesh to add
  39234. * @param recursive if all child meshes should also be added to the scene
  39235. */
  39236. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39237. /**
  39238. * Remove a mesh for the list of scene's meshes
  39239. * @param toRemove defines the mesh to remove
  39240. * @param recursive if all child meshes should also be removed from the scene
  39241. * @returns the index where the mesh was in the mesh list
  39242. */
  39243. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39244. /**
  39245. * Add a transform node to the list of scene's transform nodes
  39246. * @param newTransformNode defines the transform node to add
  39247. */
  39248. addTransformNode(newTransformNode: TransformNode): void;
  39249. /**
  39250. * Remove a transform node for the list of scene's transform nodes
  39251. * @param toRemove defines the transform node to remove
  39252. * @returns the index where the transform node was in the transform node list
  39253. */
  39254. removeTransformNode(toRemove: TransformNode): number;
  39255. /**
  39256. * Remove a skeleton for the list of scene's skeletons
  39257. * @param toRemove defines the skeleton to remove
  39258. * @returns the index where the skeleton was in the skeleton list
  39259. */
  39260. removeSkeleton(toRemove: Skeleton): number;
  39261. /**
  39262. * Remove a morph target for the list of scene's morph targets
  39263. * @param toRemove defines the morph target to remove
  39264. * @returns the index where the morph target was in the morph target list
  39265. */
  39266. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39267. /**
  39268. * Remove a light for the list of scene's lights
  39269. * @param toRemove defines the light to remove
  39270. * @returns the index where the light was in the light list
  39271. */
  39272. removeLight(toRemove: Light): number;
  39273. /**
  39274. * Remove a camera for the list of scene's cameras
  39275. * @param toRemove defines the camera to remove
  39276. * @returns the index where the camera was in the camera list
  39277. */
  39278. removeCamera(toRemove: Camera): number;
  39279. /**
  39280. * Remove a particle system for the list of scene's particle systems
  39281. * @param toRemove defines the particle system to remove
  39282. * @returns the index where the particle system was in the particle system list
  39283. */
  39284. removeParticleSystem(toRemove: IParticleSystem): number;
  39285. /**
  39286. * Remove a animation for the list of scene's animations
  39287. * @param toRemove defines the animation to remove
  39288. * @returns the index where the animation was in the animation list
  39289. */
  39290. removeAnimation(toRemove: Animation): number;
  39291. /**
  39292. * Will stop the animation of the given target
  39293. * @param target - the target
  39294. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39295. * @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)
  39296. */
  39297. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39298. /**
  39299. * Removes the given animation group from this scene.
  39300. * @param toRemove The animation group to remove
  39301. * @returns The index of the removed animation group
  39302. */
  39303. removeAnimationGroup(toRemove: AnimationGroup): number;
  39304. /**
  39305. * Removes the given multi-material from this scene.
  39306. * @param toRemove The multi-material to remove
  39307. * @returns The index of the removed multi-material
  39308. */
  39309. removeMultiMaterial(toRemove: MultiMaterial): number;
  39310. /**
  39311. * Removes the given material from this scene.
  39312. * @param toRemove The material to remove
  39313. * @returns The index of the removed material
  39314. */
  39315. removeMaterial(toRemove: Material): number;
  39316. /**
  39317. * Removes the given action manager from this scene.
  39318. * @param toRemove The action manager to remove
  39319. * @returns The index of the removed action manager
  39320. */
  39321. removeActionManager(toRemove: AbstractActionManager): number;
  39322. /**
  39323. * Removes the given texture from this scene.
  39324. * @param toRemove The texture to remove
  39325. * @returns The index of the removed texture
  39326. */
  39327. removeTexture(toRemove: BaseTexture): number;
  39328. /**
  39329. * Adds the given light to this scene
  39330. * @param newLight The light to add
  39331. */
  39332. addLight(newLight: Light): void;
  39333. /**
  39334. * Sorts the list list based on light priorities
  39335. */
  39336. sortLightsByPriority(): void;
  39337. /**
  39338. * Adds the given camera to this scene
  39339. * @param newCamera The camera to add
  39340. */
  39341. addCamera(newCamera: Camera): void;
  39342. /**
  39343. * Adds the given skeleton to this scene
  39344. * @param newSkeleton The skeleton to add
  39345. */
  39346. addSkeleton(newSkeleton: Skeleton): void;
  39347. /**
  39348. * Adds the given particle system to this scene
  39349. * @param newParticleSystem The particle system to add
  39350. */
  39351. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39352. /**
  39353. * Adds the given animation to this scene
  39354. * @param newAnimation The animation to add
  39355. */
  39356. addAnimation(newAnimation: Animation): void;
  39357. /**
  39358. * Adds the given animation group to this scene.
  39359. * @param newAnimationGroup The animation group to add
  39360. */
  39361. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39362. /**
  39363. * Adds the given multi-material to this scene
  39364. * @param newMultiMaterial The multi-material to add
  39365. */
  39366. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39367. /**
  39368. * Adds the given material to this scene
  39369. * @param newMaterial The material to add
  39370. */
  39371. addMaterial(newMaterial: Material): void;
  39372. /**
  39373. * Adds the given morph target to this scene
  39374. * @param newMorphTargetManager The morph target to add
  39375. */
  39376. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39377. /**
  39378. * Adds the given geometry to this scene
  39379. * @param newGeometry The geometry to add
  39380. */
  39381. addGeometry(newGeometry: Geometry): void;
  39382. /**
  39383. * Adds the given action manager to this scene
  39384. * @param newActionManager The action manager to add
  39385. */
  39386. addActionManager(newActionManager: AbstractActionManager): void;
  39387. /**
  39388. * Adds the given texture to this scene.
  39389. * @param newTexture The texture to add
  39390. */
  39391. addTexture(newTexture: BaseTexture): void;
  39392. /**
  39393. * Switch active camera
  39394. * @param newCamera defines the new active camera
  39395. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39396. */
  39397. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39398. /**
  39399. * sets the active camera of the scene using its ID
  39400. * @param id defines the camera's ID
  39401. * @return the new active camera or null if none found.
  39402. */
  39403. setActiveCameraByID(id: string): Nullable<Camera>;
  39404. /**
  39405. * sets the active camera of the scene using its name
  39406. * @param name defines the camera's name
  39407. * @returns the new active camera or null if none found.
  39408. */
  39409. setActiveCameraByName(name: string): Nullable<Camera>;
  39410. /**
  39411. * get an animation group using its name
  39412. * @param name defines the material's name
  39413. * @return the animation group or null if none found.
  39414. */
  39415. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39416. /**
  39417. * Get a material using its unique id
  39418. * @param uniqueId defines the material's unique id
  39419. * @return the material or null if none found.
  39420. */
  39421. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39422. /**
  39423. * get a material using its id
  39424. * @param id defines the material's ID
  39425. * @return the material or null if none found.
  39426. */
  39427. getMaterialByID(id: string): Nullable<Material>;
  39428. /**
  39429. * Gets a the last added material using a given id
  39430. * @param id defines the material's ID
  39431. * @return the last material with the given id or null if none found.
  39432. */
  39433. getLastMaterialByID(id: string): Nullable<Material>;
  39434. /**
  39435. * Gets a material using its name
  39436. * @param name defines the material's name
  39437. * @return the material or null if none found.
  39438. */
  39439. getMaterialByName(name: string): Nullable<Material>;
  39440. /**
  39441. * Get a texture using its unique id
  39442. * @param uniqueId defines the texture's unique id
  39443. * @return the texture or null if none found.
  39444. */
  39445. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39446. /**
  39447. * Gets a camera using its id
  39448. * @param id defines the id to look for
  39449. * @returns the camera or null if not found
  39450. */
  39451. getCameraByID(id: string): Nullable<Camera>;
  39452. /**
  39453. * Gets a camera using its unique id
  39454. * @param uniqueId defines the unique id to look for
  39455. * @returns the camera or null if not found
  39456. */
  39457. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39458. /**
  39459. * Gets a camera using its name
  39460. * @param name defines the camera's name
  39461. * @return the camera or null if none found.
  39462. */
  39463. getCameraByName(name: string): Nullable<Camera>;
  39464. /**
  39465. * Gets a bone using its id
  39466. * @param id defines the bone's id
  39467. * @return the bone or null if not found
  39468. */
  39469. getBoneByID(id: string): Nullable<Bone>;
  39470. /**
  39471. * Gets a bone using its id
  39472. * @param name defines the bone's name
  39473. * @return the bone or null if not found
  39474. */
  39475. getBoneByName(name: string): Nullable<Bone>;
  39476. /**
  39477. * Gets a light node using its name
  39478. * @param name defines the the light's name
  39479. * @return the light or null if none found.
  39480. */
  39481. getLightByName(name: string): Nullable<Light>;
  39482. /**
  39483. * Gets a light node using its id
  39484. * @param id defines the light's id
  39485. * @return the light or null if none found.
  39486. */
  39487. getLightByID(id: string): Nullable<Light>;
  39488. /**
  39489. * Gets a light node using its scene-generated unique ID
  39490. * @param uniqueId defines the light's unique id
  39491. * @return the light or null if none found.
  39492. */
  39493. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39494. /**
  39495. * Gets a particle system by id
  39496. * @param id defines the particle system id
  39497. * @return the corresponding system or null if none found
  39498. */
  39499. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39500. /**
  39501. * Gets a geometry using its ID
  39502. * @param id defines the geometry's id
  39503. * @return the geometry or null if none found.
  39504. */
  39505. getGeometryByID(id: string): Nullable<Geometry>;
  39506. private _getGeometryByUniqueID;
  39507. /**
  39508. * Add a new geometry to this scene
  39509. * @param geometry defines the geometry to be added to the scene.
  39510. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39511. * @return a boolean defining if the geometry was added or not
  39512. */
  39513. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39514. /**
  39515. * Removes an existing geometry
  39516. * @param geometry defines the geometry to be removed from the scene
  39517. * @return a boolean defining if the geometry was removed or not
  39518. */
  39519. removeGeometry(geometry: Geometry): boolean;
  39520. /**
  39521. * Gets the list of geometries attached to the scene
  39522. * @returns an array of Geometry
  39523. */
  39524. getGeometries(): Geometry[];
  39525. /**
  39526. * Gets the first added mesh found of a given ID
  39527. * @param id defines the id to search for
  39528. * @return the mesh found or null if not found at all
  39529. */
  39530. getMeshByID(id: string): Nullable<AbstractMesh>;
  39531. /**
  39532. * Gets a list of meshes using their id
  39533. * @param id defines the id to search for
  39534. * @returns a list of meshes
  39535. */
  39536. getMeshesByID(id: string): Array<AbstractMesh>;
  39537. /**
  39538. * Gets the first added transform node found of a given ID
  39539. * @param id defines the id to search for
  39540. * @return the found transform node or null if not found at all.
  39541. */
  39542. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39543. /**
  39544. * Gets a transform node with its auto-generated unique id
  39545. * @param uniqueId efines the unique id to search for
  39546. * @return the found transform node or null if not found at all.
  39547. */
  39548. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39549. /**
  39550. * Gets a list of transform nodes using their id
  39551. * @param id defines the id to search for
  39552. * @returns a list of transform nodes
  39553. */
  39554. getTransformNodesByID(id: string): Array<TransformNode>;
  39555. /**
  39556. * Gets a mesh with its auto-generated unique id
  39557. * @param uniqueId defines the unique id to search for
  39558. * @return the found mesh or null if not found at all.
  39559. */
  39560. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39561. /**
  39562. * Gets a the last added mesh using a given id
  39563. * @param id defines the id to search for
  39564. * @return the found mesh or null if not found at all.
  39565. */
  39566. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39567. /**
  39568. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39569. * @param id defines the id to search for
  39570. * @return the found node or null if not found at all
  39571. */
  39572. getLastEntryByID(id: string): Nullable<Node>;
  39573. /**
  39574. * Gets a node (Mesh, Camera, Light) using a given id
  39575. * @param id defines the id to search for
  39576. * @return the found node or null if not found at all
  39577. */
  39578. getNodeByID(id: string): Nullable<Node>;
  39579. /**
  39580. * Gets a node (Mesh, Camera, Light) using a given name
  39581. * @param name defines the name to search for
  39582. * @return the found node or null if not found at all.
  39583. */
  39584. getNodeByName(name: string): Nullable<Node>;
  39585. /**
  39586. * Gets a mesh using a given name
  39587. * @param name defines the name to search for
  39588. * @return the found mesh or null if not found at all.
  39589. */
  39590. getMeshByName(name: string): Nullable<AbstractMesh>;
  39591. /**
  39592. * Gets a transform node using a given name
  39593. * @param name defines the name to search for
  39594. * @return the found transform node or null if not found at all.
  39595. */
  39596. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39597. /**
  39598. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39599. * @param id defines the id to search for
  39600. * @return the found skeleton or null if not found at all.
  39601. */
  39602. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39603. /**
  39604. * Gets a skeleton using a given auto generated unique id
  39605. * @param uniqueId defines the unique id to search for
  39606. * @return the found skeleton or null if not found at all.
  39607. */
  39608. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39609. /**
  39610. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39611. * @param id defines the id to search for
  39612. * @return the found skeleton or null if not found at all.
  39613. */
  39614. getSkeletonById(id: string): Nullable<Skeleton>;
  39615. /**
  39616. * Gets a skeleton using a given name
  39617. * @param name defines the name to search for
  39618. * @return the found skeleton or null if not found at all.
  39619. */
  39620. getSkeletonByName(name: string): Nullable<Skeleton>;
  39621. /**
  39622. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39623. * @param id defines the id to search for
  39624. * @return the found morph target manager or null if not found at all.
  39625. */
  39626. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39627. /**
  39628. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39629. * @param id defines the id to search for
  39630. * @return the found morph target or null if not found at all.
  39631. */
  39632. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39633. /**
  39634. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39635. * @param name defines the name to search for
  39636. * @return the found morph target or null if not found at all.
  39637. */
  39638. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39639. /**
  39640. * Gets a boolean indicating if the given mesh is active
  39641. * @param mesh defines the mesh to look for
  39642. * @returns true if the mesh is in the active list
  39643. */
  39644. isActiveMesh(mesh: AbstractMesh): boolean;
  39645. /**
  39646. * Return a unique id as a string which can serve as an identifier for the scene
  39647. */
  39648. get uid(): string;
  39649. /**
  39650. * Add an externaly attached data from its key.
  39651. * This method call will fail and return false, if such key already exists.
  39652. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39653. * @param key the unique key that identifies the data
  39654. * @param data the data object to associate to the key for this Engine instance
  39655. * @return true if no such key were already present and the data was added successfully, false otherwise
  39656. */
  39657. addExternalData<T>(key: string, data: T): boolean;
  39658. /**
  39659. * Get an externaly attached data from its key
  39660. * @param key the unique key that identifies the data
  39661. * @return the associated data, if present (can be null), or undefined if not present
  39662. */
  39663. getExternalData<T>(key: string): Nullable<T>;
  39664. /**
  39665. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39666. * @param key the unique key that identifies the data
  39667. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39668. * @return the associated data, can be null if the factory returned null.
  39669. */
  39670. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39671. /**
  39672. * Remove an externaly attached data from the Engine instance
  39673. * @param key the unique key that identifies the data
  39674. * @return true if the data was successfully removed, false if it doesn't exist
  39675. */
  39676. removeExternalData(key: string): boolean;
  39677. private _evaluateSubMesh;
  39678. /**
  39679. * Clear the processed materials smart array preventing retention point in material dispose.
  39680. */
  39681. freeProcessedMaterials(): void;
  39682. private _preventFreeActiveMeshesAndRenderingGroups;
  39683. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39684. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39685. * when disposing several meshes in a row or a hierarchy of meshes.
  39686. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39687. */
  39688. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39689. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39690. /**
  39691. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39692. */
  39693. freeActiveMeshes(): void;
  39694. /**
  39695. * Clear the info related to rendering groups preventing retention points during dispose.
  39696. */
  39697. freeRenderingGroups(): void;
  39698. /** @hidden */
  39699. _isInIntermediateRendering(): boolean;
  39700. /**
  39701. * Lambda returning the list of potentially active meshes.
  39702. */
  39703. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39704. /**
  39705. * Lambda returning the list of potentially active sub meshes.
  39706. */
  39707. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39708. /**
  39709. * Lambda returning the list of potentially intersecting sub meshes.
  39710. */
  39711. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39712. /**
  39713. * Lambda returning the list of potentially colliding sub meshes.
  39714. */
  39715. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39716. private _activeMeshesFrozen;
  39717. private _skipEvaluateActiveMeshesCompletely;
  39718. /**
  39719. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39720. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39721. * @returns the current scene
  39722. */
  39723. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39724. /**
  39725. * Use this function to restart evaluating active meshes on every frame
  39726. * @returns the current scene
  39727. */
  39728. unfreezeActiveMeshes(): Scene;
  39729. private _evaluateActiveMeshes;
  39730. private _activeMesh;
  39731. /**
  39732. * Update the transform matrix to update from the current active camera
  39733. * @param force defines a boolean used to force the update even if cache is up to date
  39734. */
  39735. updateTransformMatrix(force?: boolean): void;
  39736. private _bindFrameBuffer;
  39737. /** @hidden */
  39738. _allowPostProcessClearColor: boolean;
  39739. /** @hidden */
  39740. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39741. private _processSubCameras;
  39742. private _checkIntersections;
  39743. /** @hidden */
  39744. _advancePhysicsEngineStep(step: number): void;
  39745. /**
  39746. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39747. */
  39748. getDeterministicFrameTime: () => number;
  39749. /** @hidden */
  39750. _animate(): void;
  39751. /** Execute all animations (for a frame) */
  39752. animate(): void;
  39753. /**
  39754. * Render the scene
  39755. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39756. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39757. */
  39758. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  39759. /**
  39760. * Freeze all materials
  39761. * A frozen material will not be updatable but should be faster to render
  39762. */
  39763. freezeMaterials(): void;
  39764. /**
  39765. * Unfreeze all materials
  39766. * A frozen material will not be updatable but should be faster to render
  39767. */
  39768. unfreezeMaterials(): void;
  39769. /**
  39770. * Releases all held ressources
  39771. */
  39772. dispose(): void;
  39773. /**
  39774. * Gets if the scene is already disposed
  39775. */
  39776. get isDisposed(): boolean;
  39777. /**
  39778. * Call this function to reduce memory footprint of the scene.
  39779. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  39780. */
  39781. clearCachedVertexData(): void;
  39782. /**
  39783. * This function will remove the local cached buffer data from texture.
  39784. * It will save memory but will prevent the texture from being rebuilt
  39785. */
  39786. cleanCachedTextureBuffer(): void;
  39787. /**
  39788. * Get the world extend vectors with an optional filter
  39789. *
  39790. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  39791. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  39792. */
  39793. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  39794. min: Vector3;
  39795. max: Vector3;
  39796. };
  39797. /**
  39798. * Creates a ray that can be used to pick in the scene
  39799. * @param x defines the x coordinate of the origin (on-screen)
  39800. * @param y defines the y coordinate of the origin (on-screen)
  39801. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39802. * @param camera defines the camera to use for the picking
  39803. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39804. * @returns a Ray
  39805. */
  39806. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  39807. /**
  39808. * Creates a ray that can be used to pick in the scene
  39809. * @param x defines the x coordinate of the origin (on-screen)
  39810. * @param y defines the y coordinate of the origin (on-screen)
  39811. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39812. * @param result defines the ray where to store the picking ray
  39813. * @param camera defines the camera to use for the picking
  39814. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39815. * @returns the current scene
  39816. */
  39817. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  39818. /**
  39819. * Creates a ray that can be used to pick in the scene
  39820. * @param x defines the x coordinate of the origin (on-screen)
  39821. * @param y defines the y coordinate of the origin (on-screen)
  39822. * @param camera defines the camera to use for the picking
  39823. * @returns a Ray
  39824. */
  39825. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  39826. /**
  39827. * Creates a ray that can be used to pick in the scene
  39828. * @param x defines the x coordinate of the origin (on-screen)
  39829. * @param y defines the y coordinate of the origin (on-screen)
  39830. * @param result defines the ray where to store the picking ray
  39831. * @param camera defines the camera to use for the picking
  39832. * @returns the current scene
  39833. */
  39834. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  39835. /** Launch a ray to try to pick a mesh in the scene
  39836. * @param x position on screen
  39837. * @param y position on screen
  39838. * @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
  39839. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39840. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39841. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39842. * @returns a PickingInfo
  39843. */
  39844. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39845. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  39846. * @param x position on screen
  39847. * @param y position on screen
  39848. * @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
  39849. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39850. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39851. * @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)
  39852. */
  39853. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  39854. /** Use the given ray to pick a mesh in the scene
  39855. * @param ray The ray to use to pick meshes
  39856. * @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
  39857. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39858. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39859. * @returns a PickingInfo
  39860. */
  39861. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39862. /**
  39863. * Launch a ray to try to pick a mesh in the scene
  39864. * @param x X position on screen
  39865. * @param y Y position on screen
  39866. * @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
  39867. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39868. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39869. * @returns an array of PickingInfo
  39870. */
  39871. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39872. /**
  39873. * Launch a ray to try to pick a mesh in the scene
  39874. * @param ray Ray to use
  39875. * @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
  39876. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39877. * @returns an array of PickingInfo
  39878. */
  39879. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39880. /**
  39881. * Force the value of meshUnderPointer
  39882. * @param mesh defines the mesh to use
  39883. */
  39884. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39885. /**
  39886. * Gets the mesh under the pointer
  39887. * @returns a Mesh or null if no mesh is under the pointer
  39888. */
  39889. getPointerOverMesh(): Nullable<AbstractMesh>;
  39890. /** @hidden */
  39891. _rebuildGeometries(): void;
  39892. /** @hidden */
  39893. _rebuildTextures(): void;
  39894. private _getByTags;
  39895. /**
  39896. * Get a list of meshes by tags
  39897. * @param tagsQuery defines the tags query to use
  39898. * @param forEach defines a predicate used to filter results
  39899. * @returns an array of Mesh
  39900. */
  39901. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  39902. /**
  39903. * Get a list of cameras by tags
  39904. * @param tagsQuery defines the tags query to use
  39905. * @param forEach defines a predicate used to filter results
  39906. * @returns an array of Camera
  39907. */
  39908. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  39909. /**
  39910. * Get a list of lights by tags
  39911. * @param tagsQuery defines the tags query to use
  39912. * @param forEach defines a predicate used to filter results
  39913. * @returns an array of Light
  39914. */
  39915. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  39916. /**
  39917. * Get a list of materials by tags
  39918. * @param tagsQuery defines the tags query to use
  39919. * @param forEach defines a predicate used to filter results
  39920. * @returns an array of Material
  39921. */
  39922. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  39923. /**
  39924. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39925. * This allowed control for front to back rendering or reversly depending of the special needs.
  39926. *
  39927. * @param renderingGroupId The rendering group id corresponding to its index
  39928. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39929. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39930. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39931. */
  39932. 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;
  39933. /**
  39934. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39935. *
  39936. * @param renderingGroupId The rendering group id corresponding to its index
  39937. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39938. * @param depth Automatically clears depth between groups if true and autoClear is true.
  39939. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  39940. */
  39941. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  39942. /**
  39943. * Gets the current auto clear configuration for one rendering group of the rendering
  39944. * manager.
  39945. * @param index the rendering group index to get the information for
  39946. * @returns The auto clear setup for the requested rendering group
  39947. */
  39948. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  39949. private _blockMaterialDirtyMechanism;
  39950. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  39951. get blockMaterialDirtyMechanism(): boolean;
  39952. set blockMaterialDirtyMechanism(value: boolean);
  39953. /**
  39954. * Will flag all materials as dirty to trigger new shader compilation
  39955. * @param flag defines the flag used to specify which material part must be marked as dirty
  39956. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  39957. */
  39958. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  39959. /** @hidden */
  39960. _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;
  39961. /** @hidden */
  39962. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39963. /** @hidden */
  39964. _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;
  39965. /** @hidden */
  39966. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  39967. /** @hidden */
  39968. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39969. /** @hidden */
  39970. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39971. }
  39972. }
  39973. declare module BABYLON {
  39974. /**
  39975. * Set of assets to keep when moving a scene into an asset container.
  39976. */
  39977. export class KeepAssets extends AbstractScene {
  39978. }
  39979. /**
  39980. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  39981. */
  39982. export class InstantiatedEntries {
  39983. /**
  39984. * List of new root nodes (eg. nodes with no parent)
  39985. */
  39986. rootNodes: TransformNode[];
  39987. /**
  39988. * List of new skeletons
  39989. */
  39990. skeletons: Skeleton[];
  39991. /**
  39992. * List of new animation groups
  39993. */
  39994. animationGroups: AnimationGroup[];
  39995. }
  39996. /**
  39997. * Container with a set of assets that can be added or removed from a scene.
  39998. */
  39999. export class AssetContainer extends AbstractScene {
  40000. private _wasAddedToScene;
  40001. /**
  40002. * The scene the AssetContainer belongs to.
  40003. */
  40004. scene: Scene;
  40005. /**
  40006. * Instantiates an AssetContainer.
  40007. * @param scene The scene the AssetContainer belongs to.
  40008. */
  40009. constructor(scene: Scene);
  40010. /**
  40011. * Instantiate or clone all meshes and add the new ones to the scene.
  40012. * Skeletons and animation groups will all be cloned
  40013. * @param nameFunction defines an optional function used to get new names for clones
  40014. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40015. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40016. */
  40017. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40018. /**
  40019. * Adds all the assets from the container to the scene.
  40020. */
  40021. addAllToScene(): void;
  40022. /**
  40023. * Removes all the assets in the container from the scene
  40024. */
  40025. removeAllFromScene(): void;
  40026. /**
  40027. * Disposes all the assets in the container
  40028. */
  40029. dispose(): void;
  40030. private _moveAssets;
  40031. /**
  40032. * Removes all the assets contained in the scene and adds them to the container.
  40033. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40034. */
  40035. moveAllFromScene(keepAssets?: KeepAssets): void;
  40036. /**
  40037. * 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.
  40038. * @returns the root mesh
  40039. */
  40040. createRootMesh(): Mesh;
  40041. /**
  40042. * Merge animations (direct and animation groups) from this asset container into a scene
  40043. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40044. * @param animatables set of animatables to retarget to a node from the scene
  40045. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40046. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40047. */
  40048. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40049. }
  40050. }
  40051. declare module BABYLON {
  40052. /**
  40053. * Defines how the parser contract is defined.
  40054. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40055. */
  40056. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40057. /**
  40058. * Defines how the individual parser contract is defined.
  40059. * These parser can parse an individual asset
  40060. */
  40061. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40062. /**
  40063. * Base class of the scene acting as a container for the different elements composing a scene.
  40064. * This class is dynamically extended by the different components of the scene increasing
  40065. * flexibility and reducing coupling
  40066. */
  40067. export abstract class AbstractScene {
  40068. /**
  40069. * Stores the list of available parsers in the application.
  40070. */
  40071. private static _BabylonFileParsers;
  40072. /**
  40073. * Stores the list of available individual parsers in the application.
  40074. */
  40075. private static _IndividualBabylonFileParsers;
  40076. /**
  40077. * Adds a parser in the list of available ones
  40078. * @param name Defines the name of the parser
  40079. * @param parser Defines the parser to add
  40080. */
  40081. static AddParser(name: string, parser: BabylonFileParser): void;
  40082. /**
  40083. * Gets a general parser from the list of avaialble ones
  40084. * @param name Defines the name of the parser
  40085. * @returns the requested parser or null
  40086. */
  40087. static GetParser(name: string): Nullable<BabylonFileParser>;
  40088. /**
  40089. * Adds n individual parser in the list of available ones
  40090. * @param name Defines the name of the parser
  40091. * @param parser Defines the parser to add
  40092. */
  40093. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40094. /**
  40095. * Gets an individual parser from the list of avaialble ones
  40096. * @param name Defines the name of the parser
  40097. * @returns the requested parser or null
  40098. */
  40099. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40100. /**
  40101. * Parser json data and populate both a scene and its associated container object
  40102. * @param jsonData Defines the data to parse
  40103. * @param scene Defines the scene to parse the data for
  40104. * @param container Defines the container attached to the parsing sequence
  40105. * @param rootUrl Defines the root url of the data
  40106. */
  40107. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40108. /**
  40109. * Gets the list of root nodes (ie. nodes with no parent)
  40110. */
  40111. rootNodes: Node[];
  40112. /** All of the cameras added to this scene
  40113. * @see http://doc.babylonjs.com/babylon101/cameras
  40114. */
  40115. cameras: Camera[];
  40116. /**
  40117. * All of the lights added to this scene
  40118. * @see http://doc.babylonjs.com/babylon101/lights
  40119. */
  40120. lights: Light[];
  40121. /**
  40122. * All of the (abstract) meshes added to this scene
  40123. */
  40124. meshes: AbstractMesh[];
  40125. /**
  40126. * The list of skeletons added to the scene
  40127. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40128. */
  40129. skeletons: Skeleton[];
  40130. /**
  40131. * All of the particle systems added to this scene
  40132. * @see http://doc.babylonjs.com/babylon101/particles
  40133. */
  40134. particleSystems: IParticleSystem[];
  40135. /**
  40136. * Gets a list of Animations associated with the scene
  40137. */
  40138. animations: Animation[];
  40139. /**
  40140. * All of the animation groups added to this scene
  40141. * @see http://doc.babylonjs.com/how_to/group
  40142. */
  40143. animationGroups: AnimationGroup[];
  40144. /**
  40145. * All of the multi-materials added to this scene
  40146. * @see http://doc.babylonjs.com/how_to/multi_materials
  40147. */
  40148. multiMaterials: MultiMaterial[];
  40149. /**
  40150. * All of the materials added to this scene
  40151. * In the context of a Scene, it is not supposed to be modified manually.
  40152. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40153. * Note also that the order of the Material within the array is not significant and might change.
  40154. * @see http://doc.babylonjs.com/babylon101/materials
  40155. */
  40156. materials: Material[];
  40157. /**
  40158. * The list of morph target managers added to the scene
  40159. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40160. */
  40161. morphTargetManagers: MorphTargetManager[];
  40162. /**
  40163. * The list of geometries used in the scene.
  40164. */
  40165. geometries: Geometry[];
  40166. /**
  40167. * All of the tranform nodes added to this scene
  40168. * In the context of a Scene, it is not supposed to be modified manually.
  40169. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40170. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40171. * @see http://doc.babylonjs.com/how_to/transformnode
  40172. */
  40173. transformNodes: TransformNode[];
  40174. /**
  40175. * ActionManagers available on the scene.
  40176. */
  40177. actionManagers: AbstractActionManager[];
  40178. /**
  40179. * Textures to keep.
  40180. */
  40181. textures: BaseTexture[];
  40182. /**
  40183. * Environment texture for the scene
  40184. */
  40185. environmentTexture: Nullable<BaseTexture>;
  40186. /**
  40187. * @returns all meshes, lights, cameras, transformNodes and bones
  40188. */
  40189. getNodes(): Array<Node>;
  40190. }
  40191. }
  40192. declare module BABYLON {
  40193. /**
  40194. * Interface used to define options for Sound class
  40195. */
  40196. export interface ISoundOptions {
  40197. /**
  40198. * Does the sound autoplay once loaded.
  40199. */
  40200. autoplay?: boolean;
  40201. /**
  40202. * Does the sound loop after it finishes playing once.
  40203. */
  40204. loop?: boolean;
  40205. /**
  40206. * Sound's volume
  40207. */
  40208. volume?: number;
  40209. /**
  40210. * Is it a spatial sound?
  40211. */
  40212. spatialSound?: boolean;
  40213. /**
  40214. * Maximum distance to hear that sound
  40215. */
  40216. maxDistance?: number;
  40217. /**
  40218. * Uses user defined attenuation function
  40219. */
  40220. useCustomAttenuation?: boolean;
  40221. /**
  40222. * Define the roll off factor of spatial sounds.
  40223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40224. */
  40225. rolloffFactor?: number;
  40226. /**
  40227. * Define the reference distance the sound should be heard perfectly.
  40228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40229. */
  40230. refDistance?: number;
  40231. /**
  40232. * Define the distance attenuation model the sound will follow.
  40233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40234. */
  40235. distanceModel?: string;
  40236. /**
  40237. * Defines the playback speed (1 by default)
  40238. */
  40239. playbackRate?: number;
  40240. /**
  40241. * Defines if the sound is from a streaming source
  40242. */
  40243. streaming?: boolean;
  40244. /**
  40245. * Defines an optional length (in seconds) inside the sound file
  40246. */
  40247. length?: number;
  40248. /**
  40249. * Defines an optional offset (in seconds) inside the sound file
  40250. */
  40251. offset?: number;
  40252. /**
  40253. * If true, URLs will not be required to state the audio file codec to use.
  40254. */
  40255. skipCodecCheck?: boolean;
  40256. }
  40257. /**
  40258. * Defines a sound that can be played in the application.
  40259. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40261. */
  40262. export class Sound {
  40263. /**
  40264. * The name of the sound in the scene.
  40265. */
  40266. name: string;
  40267. /**
  40268. * Does the sound autoplay once loaded.
  40269. */
  40270. autoplay: boolean;
  40271. /**
  40272. * Does the sound loop after it finishes playing once.
  40273. */
  40274. loop: boolean;
  40275. /**
  40276. * Does the sound use a custom attenuation curve to simulate the falloff
  40277. * happening when the source gets further away from the camera.
  40278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40279. */
  40280. useCustomAttenuation: boolean;
  40281. /**
  40282. * The sound track id this sound belongs to.
  40283. */
  40284. soundTrackId: number;
  40285. /**
  40286. * Is this sound currently played.
  40287. */
  40288. isPlaying: boolean;
  40289. /**
  40290. * Is this sound currently paused.
  40291. */
  40292. isPaused: boolean;
  40293. /**
  40294. * Does this sound enables spatial sound.
  40295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40296. */
  40297. spatialSound: boolean;
  40298. /**
  40299. * Define the reference distance the sound should be heard perfectly.
  40300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40301. */
  40302. refDistance: number;
  40303. /**
  40304. * Define the roll off factor of spatial sounds.
  40305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40306. */
  40307. rolloffFactor: number;
  40308. /**
  40309. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40311. */
  40312. maxDistance: number;
  40313. /**
  40314. * Define the distance attenuation model the sound will follow.
  40315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40316. */
  40317. distanceModel: string;
  40318. /**
  40319. * @hidden
  40320. * Back Compat
  40321. **/
  40322. onended: () => any;
  40323. /**
  40324. * Gets or sets an object used to store user defined information for the sound.
  40325. */
  40326. metadata: any;
  40327. /**
  40328. * Observable event when the current playing sound finishes.
  40329. */
  40330. onEndedObservable: Observable<Sound>;
  40331. private _panningModel;
  40332. private _playbackRate;
  40333. private _streaming;
  40334. private _startTime;
  40335. private _startOffset;
  40336. private _position;
  40337. /** @hidden */
  40338. _positionInEmitterSpace: boolean;
  40339. private _localDirection;
  40340. private _volume;
  40341. private _isReadyToPlay;
  40342. private _isDirectional;
  40343. private _readyToPlayCallback;
  40344. private _audioBuffer;
  40345. private _soundSource;
  40346. private _streamingSource;
  40347. private _soundPanner;
  40348. private _soundGain;
  40349. private _inputAudioNode;
  40350. private _outputAudioNode;
  40351. private _coneInnerAngle;
  40352. private _coneOuterAngle;
  40353. private _coneOuterGain;
  40354. private _scene;
  40355. private _connectedTransformNode;
  40356. private _customAttenuationFunction;
  40357. private _registerFunc;
  40358. private _isOutputConnected;
  40359. private _htmlAudioElement;
  40360. private _urlType;
  40361. private _length?;
  40362. private _offset?;
  40363. /** @hidden */
  40364. static _SceneComponentInitialization: (scene: Scene) => void;
  40365. /**
  40366. * Create a sound and attach it to a scene
  40367. * @param name Name of your sound
  40368. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40369. * @param scene defines the scene the sound belongs to
  40370. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40371. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40372. */
  40373. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40374. /**
  40375. * Release the sound and its associated resources
  40376. */
  40377. dispose(): void;
  40378. /**
  40379. * Gets if the sounds is ready to be played or not.
  40380. * @returns true if ready, otherwise false
  40381. */
  40382. isReady(): boolean;
  40383. private _soundLoaded;
  40384. /**
  40385. * Sets the data of the sound from an audiobuffer
  40386. * @param audioBuffer The audioBuffer containing the data
  40387. */
  40388. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40389. /**
  40390. * Updates the current sounds options such as maxdistance, loop...
  40391. * @param options A JSON object containing values named as the object properties
  40392. */
  40393. updateOptions(options: ISoundOptions): void;
  40394. private _createSpatialParameters;
  40395. private _updateSpatialParameters;
  40396. /**
  40397. * Switch the panning model to HRTF:
  40398. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40400. */
  40401. switchPanningModelToHRTF(): void;
  40402. /**
  40403. * Switch the panning model to Equal Power:
  40404. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40405. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40406. */
  40407. switchPanningModelToEqualPower(): void;
  40408. private _switchPanningModel;
  40409. /**
  40410. * Connect this sound to a sound track audio node like gain...
  40411. * @param soundTrackAudioNode the sound track audio node to connect to
  40412. */
  40413. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40414. /**
  40415. * Transform this sound into a directional source
  40416. * @param coneInnerAngle Size of the inner cone in degree
  40417. * @param coneOuterAngle Size of the outer cone in degree
  40418. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40419. */
  40420. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40421. /**
  40422. * Gets or sets the inner angle for the directional cone.
  40423. */
  40424. get directionalConeInnerAngle(): number;
  40425. /**
  40426. * Gets or sets the inner angle for the directional cone.
  40427. */
  40428. set directionalConeInnerAngle(value: number);
  40429. /**
  40430. * Gets or sets the outer angle for the directional cone.
  40431. */
  40432. get directionalConeOuterAngle(): number;
  40433. /**
  40434. * Gets or sets the outer angle for the directional cone.
  40435. */
  40436. set directionalConeOuterAngle(value: number);
  40437. /**
  40438. * Sets the position of the emitter if spatial sound is enabled
  40439. * @param newPosition Defines the new posisiton
  40440. */
  40441. setPosition(newPosition: Vector3): void;
  40442. /**
  40443. * Sets the local direction of the emitter if spatial sound is enabled
  40444. * @param newLocalDirection Defines the new local direction
  40445. */
  40446. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40447. private _updateDirection;
  40448. /** @hidden */
  40449. updateDistanceFromListener(): void;
  40450. /**
  40451. * Sets a new custom attenuation function for the sound.
  40452. * @param callback Defines the function used for the attenuation
  40453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40454. */
  40455. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40456. /**
  40457. * Play the sound
  40458. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40459. * @param offset (optional) Start the sound at a specific time in seconds
  40460. * @param length (optional) Sound duration (in seconds)
  40461. */
  40462. play(time?: number, offset?: number, length?: number): void;
  40463. private _onended;
  40464. /**
  40465. * Stop the sound
  40466. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40467. */
  40468. stop(time?: number): void;
  40469. /**
  40470. * Put the sound in pause
  40471. */
  40472. pause(): void;
  40473. /**
  40474. * Sets a dedicated volume for this sounds
  40475. * @param newVolume Define the new volume of the sound
  40476. * @param time Define time for gradual change to new volume
  40477. */
  40478. setVolume(newVolume: number, time?: number): void;
  40479. /**
  40480. * Set the sound play back rate
  40481. * @param newPlaybackRate Define the playback rate the sound should be played at
  40482. */
  40483. setPlaybackRate(newPlaybackRate: number): void;
  40484. /**
  40485. * Gets the volume of the sound.
  40486. * @returns the volume of the sound
  40487. */
  40488. getVolume(): number;
  40489. /**
  40490. * Attach the sound to a dedicated mesh
  40491. * @param transformNode The transform node to connect the sound with
  40492. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40493. */
  40494. attachToMesh(transformNode: TransformNode): void;
  40495. /**
  40496. * Detach the sound from the previously attached mesh
  40497. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40498. */
  40499. detachFromMesh(): void;
  40500. private _onRegisterAfterWorldMatrixUpdate;
  40501. /**
  40502. * Clone the current sound in the scene.
  40503. * @returns the new sound clone
  40504. */
  40505. clone(): Nullable<Sound>;
  40506. /**
  40507. * Gets the current underlying audio buffer containing the data
  40508. * @returns the audio buffer
  40509. */
  40510. getAudioBuffer(): Nullable<AudioBuffer>;
  40511. /**
  40512. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40513. * @returns the source node
  40514. */
  40515. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40516. /**
  40517. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40518. * @returns the gain node
  40519. */
  40520. getSoundGain(): Nullable<GainNode>;
  40521. /**
  40522. * Serializes the Sound in a JSON representation
  40523. * @returns the JSON representation of the sound
  40524. */
  40525. serialize(): any;
  40526. /**
  40527. * Parse a JSON representation of a sound to innstantiate in a given scene
  40528. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40529. * @param scene Define the scene the new parsed sound should be created in
  40530. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40531. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40532. * @returns the newly parsed sound
  40533. */
  40534. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40535. }
  40536. }
  40537. declare module BABYLON {
  40538. /**
  40539. * This defines an action helpful to play a defined sound on a triggered action.
  40540. */
  40541. export class PlaySoundAction extends Action {
  40542. private _sound;
  40543. /**
  40544. * Instantiate the action
  40545. * @param triggerOptions defines the trigger options
  40546. * @param sound defines the sound to play
  40547. * @param condition defines the trigger related conditions
  40548. */
  40549. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40550. /** @hidden */
  40551. _prepare(): void;
  40552. /**
  40553. * Execute the action and play the sound.
  40554. */
  40555. execute(): void;
  40556. /**
  40557. * Serializes the actions and its related information.
  40558. * @param parent defines the object to serialize in
  40559. * @returns the serialized object
  40560. */
  40561. serialize(parent: any): any;
  40562. }
  40563. /**
  40564. * This defines an action helpful to stop a defined sound on a triggered action.
  40565. */
  40566. export class StopSoundAction extends Action {
  40567. private _sound;
  40568. /**
  40569. * Instantiate the action
  40570. * @param triggerOptions defines the trigger options
  40571. * @param sound defines the sound to stop
  40572. * @param condition defines the trigger related conditions
  40573. */
  40574. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40575. /** @hidden */
  40576. _prepare(): void;
  40577. /**
  40578. * Execute the action and stop the sound.
  40579. */
  40580. execute(): void;
  40581. /**
  40582. * Serializes the actions and its related information.
  40583. * @param parent defines the object to serialize in
  40584. * @returns the serialized object
  40585. */
  40586. serialize(parent: any): any;
  40587. }
  40588. }
  40589. declare module BABYLON {
  40590. /**
  40591. * This defines an action responsible to change the value of a property
  40592. * by interpolating between its current value and the newly set one once triggered.
  40593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40594. */
  40595. export class InterpolateValueAction extends Action {
  40596. /**
  40597. * Defines the path of the property where the value should be interpolated
  40598. */
  40599. propertyPath: string;
  40600. /**
  40601. * Defines the target value at the end of the interpolation.
  40602. */
  40603. value: any;
  40604. /**
  40605. * Defines the time it will take for the property to interpolate to the value.
  40606. */
  40607. duration: number;
  40608. /**
  40609. * Defines if the other scene animations should be stopped when the action has been triggered
  40610. */
  40611. stopOtherAnimations?: boolean;
  40612. /**
  40613. * Defines a callback raised once the interpolation animation has been done.
  40614. */
  40615. onInterpolationDone?: () => void;
  40616. /**
  40617. * Observable triggered once the interpolation animation has been done.
  40618. */
  40619. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40620. private _target;
  40621. private _effectiveTarget;
  40622. private _property;
  40623. /**
  40624. * Instantiate the action
  40625. * @param triggerOptions defines the trigger options
  40626. * @param target defines the object containing the value to interpolate
  40627. * @param propertyPath defines the path to the property in the target object
  40628. * @param value defines the target value at the end of the interpolation
  40629. * @param duration deines the time it will take for the property to interpolate to the value.
  40630. * @param condition defines the trigger related conditions
  40631. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40632. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40633. */
  40634. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40635. /** @hidden */
  40636. _prepare(): void;
  40637. /**
  40638. * Execute the action starts the value interpolation.
  40639. */
  40640. execute(): void;
  40641. /**
  40642. * Serializes the actions and its related information.
  40643. * @param parent defines the object to serialize in
  40644. * @returns the serialized object
  40645. */
  40646. serialize(parent: any): any;
  40647. }
  40648. }
  40649. declare module BABYLON {
  40650. /**
  40651. * Options allowed during the creation of a sound track.
  40652. */
  40653. export interface ISoundTrackOptions {
  40654. /**
  40655. * The volume the sound track should take during creation
  40656. */
  40657. volume?: number;
  40658. /**
  40659. * Define if the sound track is the main sound track of the scene
  40660. */
  40661. mainTrack?: boolean;
  40662. }
  40663. /**
  40664. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40665. * It will be also used in a future release to apply effects on a specific track.
  40666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40667. */
  40668. export class SoundTrack {
  40669. /**
  40670. * The unique identifier of the sound track in the scene.
  40671. */
  40672. id: number;
  40673. /**
  40674. * The list of sounds included in the sound track.
  40675. */
  40676. soundCollection: Array<Sound>;
  40677. private _outputAudioNode;
  40678. private _scene;
  40679. private _connectedAnalyser;
  40680. private _options;
  40681. private _isInitialized;
  40682. /**
  40683. * Creates a new sound track.
  40684. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40685. * @param scene Define the scene the sound track belongs to
  40686. * @param options
  40687. */
  40688. constructor(scene: Scene, options?: ISoundTrackOptions);
  40689. private _initializeSoundTrackAudioGraph;
  40690. /**
  40691. * Release the sound track and its associated resources
  40692. */
  40693. dispose(): void;
  40694. /**
  40695. * Adds a sound to this sound track
  40696. * @param sound define the cound to add
  40697. * @ignoreNaming
  40698. */
  40699. AddSound(sound: Sound): void;
  40700. /**
  40701. * Removes a sound to this sound track
  40702. * @param sound define the cound to remove
  40703. * @ignoreNaming
  40704. */
  40705. RemoveSound(sound: Sound): void;
  40706. /**
  40707. * Set a global volume for the full sound track.
  40708. * @param newVolume Define the new volume of the sound track
  40709. */
  40710. setVolume(newVolume: number): void;
  40711. /**
  40712. * Switch the panning model to HRTF:
  40713. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40715. */
  40716. switchPanningModelToHRTF(): void;
  40717. /**
  40718. * Switch the panning model to Equal Power:
  40719. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40721. */
  40722. switchPanningModelToEqualPower(): void;
  40723. /**
  40724. * Connect the sound track to an audio analyser allowing some amazing
  40725. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40727. * @param analyser The analyser to connect to the engine
  40728. */
  40729. connectToAnalyser(analyser: Analyser): void;
  40730. }
  40731. }
  40732. declare module BABYLON {
  40733. interface AbstractScene {
  40734. /**
  40735. * The list of sounds used in the scene.
  40736. */
  40737. sounds: Nullable<Array<Sound>>;
  40738. }
  40739. interface Scene {
  40740. /**
  40741. * @hidden
  40742. * Backing field
  40743. */
  40744. _mainSoundTrack: SoundTrack;
  40745. /**
  40746. * The main sound track played by the scene.
  40747. * It cotains your primary collection of sounds.
  40748. */
  40749. mainSoundTrack: SoundTrack;
  40750. /**
  40751. * The list of sound tracks added to the scene
  40752. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40753. */
  40754. soundTracks: Nullable<Array<SoundTrack>>;
  40755. /**
  40756. * Gets a sound using a given name
  40757. * @param name defines the name to search for
  40758. * @return the found sound or null if not found at all.
  40759. */
  40760. getSoundByName(name: string): Nullable<Sound>;
  40761. /**
  40762. * Gets or sets if audio support is enabled
  40763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40764. */
  40765. audioEnabled: boolean;
  40766. /**
  40767. * Gets or sets if audio will be output to headphones
  40768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40769. */
  40770. headphone: boolean;
  40771. /**
  40772. * Gets or sets custom audio listener position provider
  40773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40774. */
  40775. audioListenerPositionProvider: Nullable<() => Vector3>;
  40776. /**
  40777. * Gets or sets a refresh rate when using 3D audio positioning
  40778. */
  40779. audioPositioningRefreshRate: number;
  40780. }
  40781. /**
  40782. * Defines the sound scene component responsible to manage any sounds
  40783. * in a given scene.
  40784. */
  40785. export class AudioSceneComponent implements ISceneSerializableComponent {
  40786. /**
  40787. * The component name helpfull to identify the component in the list of scene components.
  40788. */
  40789. readonly name: string;
  40790. /**
  40791. * The scene the component belongs to.
  40792. */
  40793. scene: Scene;
  40794. private _audioEnabled;
  40795. /**
  40796. * Gets whether audio is enabled or not.
  40797. * Please use related enable/disable method to switch state.
  40798. */
  40799. get audioEnabled(): boolean;
  40800. private _headphone;
  40801. /**
  40802. * Gets whether audio is outputing to headphone or not.
  40803. * Please use the according Switch methods to change output.
  40804. */
  40805. get headphone(): boolean;
  40806. /**
  40807. * Gets or sets a refresh rate when using 3D audio positioning
  40808. */
  40809. audioPositioningRefreshRate: number;
  40810. private _audioListenerPositionProvider;
  40811. /**
  40812. * Gets the current audio listener position provider
  40813. */
  40814. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  40815. /**
  40816. * Sets a custom listener position for all sounds in the scene
  40817. * By default, this is the position of the first active camera
  40818. */
  40819. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  40820. /**
  40821. * Creates a new instance of the component for the given scene
  40822. * @param scene Defines the scene to register the component in
  40823. */
  40824. constructor(scene: Scene);
  40825. /**
  40826. * Registers the component in a given scene
  40827. */
  40828. register(): void;
  40829. /**
  40830. * Rebuilds the elements related to this component in case of
  40831. * context lost for instance.
  40832. */
  40833. rebuild(): void;
  40834. /**
  40835. * Serializes the component data to the specified json object
  40836. * @param serializationObject The object to serialize to
  40837. */
  40838. serialize(serializationObject: any): void;
  40839. /**
  40840. * Adds all the elements from the container to the scene
  40841. * @param container the container holding the elements
  40842. */
  40843. addFromContainer(container: AbstractScene): void;
  40844. /**
  40845. * Removes all the elements in the container from the scene
  40846. * @param container contains the elements to remove
  40847. * @param dispose if the removed element should be disposed (default: false)
  40848. */
  40849. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  40850. /**
  40851. * Disposes the component and the associated ressources.
  40852. */
  40853. dispose(): void;
  40854. /**
  40855. * Disables audio in the associated scene.
  40856. */
  40857. disableAudio(): void;
  40858. /**
  40859. * Enables audio in the associated scene.
  40860. */
  40861. enableAudio(): void;
  40862. /**
  40863. * Switch audio to headphone output.
  40864. */
  40865. switchAudioModeForHeadphones(): void;
  40866. /**
  40867. * Switch audio to normal speakers.
  40868. */
  40869. switchAudioModeForNormalSpeakers(): void;
  40870. private _cachedCameraDirection;
  40871. private _cachedCameraPosition;
  40872. private _lastCheck;
  40873. private _afterRender;
  40874. }
  40875. }
  40876. declare module BABYLON {
  40877. /**
  40878. * Wraps one or more Sound objects and selects one with random weight for playback.
  40879. */
  40880. export class WeightedSound {
  40881. /** When true a Sound will be selected and played when the current playing Sound completes. */
  40882. loop: boolean;
  40883. private _coneInnerAngle;
  40884. private _coneOuterAngle;
  40885. private _volume;
  40886. /** A Sound is currently playing. */
  40887. isPlaying: boolean;
  40888. /** A Sound is currently paused. */
  40889. isPaused: boolean;
  40890. private _sounds;
  40891. private _weights;
  40892. private _currentIndex?;
  40893. /**
  40894. * Creates a new WeightedSound from the list of sounds given.
  40895. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  40896. * @param sounds Array of Sounds that will be selected from.
  40897. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  40898. */
  40899. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  40900. /**
  40901. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  40902. */
  40903. get directionalConeInnerAngle(): number;
  40904. /**
  40905. * The size of cone in degress for a directional sound in which there will be no attenuation.
  40906. */
  40907. set directionalConeInnerAngle(value: number);
  40908. /**
  40909. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40910. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40911. */
  40912. get directionalConeOuterAngle(): number;
  40913. /**
  40914. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40915. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40916. */
  40917. set directionalConeOuterAngle(value: number);
  40918. /**
  40919. * Playback volume.
  40920. */
  40921. get volume(): number;
  40922. /**
  40923. * Playback volume.
  40924. */
  40925. set volume(value: number);
  40926. private _onended;
  40927. /**
  40928. * Suspend playback
  40929. */
  40930. pause(): void;
  40931. /**
  40932. * Stop playback
  40933. */
  40934. stop(): void;
  40935. /**
  40936. * Start playback.
  40937. * @param startOffset Position the clip head at a specific time in seconds.
  40938. */
  40939. play(startOffset?: number): void;
  40940. }
  40941. }
  40942. declare module BABYLON {
  40943. /**
  40944. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40945. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40946. */
  40947. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40948. /**
  40949. * Gets the name of the behavior.
  40950. */
  40951. get name(): string;
  40952. /**
  40953. * The easing function used by animations
  40954. */
  40955. static EasingFunction: BackEase;
  40956. /**
  40957. * The easing mode used by animations
  40958. */
  40959. static EasingMode: number;
  40960. /**
  40961. * The duration of the animation, in milliseconds
  40962. */
  40963. transitionDuration: number;
  40964. /**
  40965. * Length of the distance animated by the transition when lower radius is reached
  40966. */
  40967. lowerRadiusTransitionRange: number;
  40968. /**
  40969. * Length of the distance animated by the transition when upper radius is reached
  40970. */
  40971. upperRadiusTransitionRange: number;
  40972. private _autoTransitionRange;
  40973. /**
  40974. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40975. */
  40976. get autoTransitionRange(): boolean;
  40977. /**
  40978. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40979. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40980. */
  40981. set autoTransitionRange(value: boolean);
  40982. private _attachedCamera;
  40983. private _onAfterCheckInputsObserver;
  40984. private _onMeshTargetChangedObserver;
  40985. /**
  40986. * Initializes the behavior.
  40987. */
  40988. init(): void;
  40989. /**
  40990. * Attaches the behavior to its arc rotate camera.
  40991. * @param camera Defines the camera to attach the behavior to
  40992. */
  40993. attach(camera: ArcRotateCamera): void;
  40994. /**
  40995. * Detaches the behavior from its current arc rotate camera.
  40996. */
  40997. detach(): void;
  40998. private _radiusIsAnimating;
  40999. private _radiusBounceTransition;
  41000. private _animatables;
  41001. private _cachedWheelPrecision;
  41002. /**
  41003. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41004. * @param radiusLimit The limit to check against.
  41005. * @return Bool to indicate if at limit.
  41006. */
  41007. private _isRadiusAtLimit;
  41008. /**
  41009. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41010. * @param radiusDelta The delta by which to animate to. Can be negative.
  41011. */
  41012. private _applyBoundRadiusAnimation;
  41013. /**
  41014. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41015. */
  41016. protected _clearAnimationLocks(): void;
  41017. /**
  41018. * Stops and removes all animations that have been applied to the camera
  41019. */
  41020. stopAllAnimations(): void;
  41021. }
  41022. }
  41023. declare module BABYLON {
  41024. /**
  41025. * 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.
  41026. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41027. */
  41028. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41029. /**
  41030. * Gets the name of the behavior.
  41031. */
  41032. get name(): string;
  41033. private _mode;
  41034. private _radiusScale;
  41035. private _positionScale;
  41036. private _defaultElevation;
  41037. private _elevationReturnTime;
  41038. private _elevationReturnWaitTime;
  41039. private _zoomStopsAnimation;
  41040. private _framingTime;
  41041. /**
  41042. * The easing function used by animations
  41043. */
  41044. static EasingFunction: ExponentialEase;
  41045. /**
  41046. * The easing mode used by animations
  41047. */
  41048. static EasingMode: number;
  41049. /**
  41050. * Sets the current mode used by the behavior
  41051. */
  41052. set mode(mode: number);
  41053. /**
  41054. * Gets current mode used by the behavior.
  41055. */
  41056. get mode(): number;
  41057. /**
  41058. * Sets the scale applied to the radius (1 by default)
  41059. */
  41060. set radiusScale(radius: number);
  41061. /**
  41062. * Gets the scale applied to the radius
  41063. */
  41064. get radiusScale(): number;
  41065. /**
  41066. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41067. */
  41068. set positionScale(scale: number);
  41069. /**
  41070. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41071. */
  41072. get positionScale(): number;
  41073. /**
  41074. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41075. * behaviour is triggered, in radians.
  41076. */
  41077. set defaultElevation(elevation: number);
  41078. /**
  41079. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41080. * behaviour is triggered, in radians.
  41081. */
  41082. get defaultElevation(): number;
  41083. /**
  41084. * Sets the time (in milliseconds) taken to return to the default beta position.
  41085. * Negative value indicates camera should not return to default.
  41086. */
  41087. set elevationReturnTime(speed: number);
  41088. /**
  41089. * Gets the time (in milliseconds) taken to return to the default beta position.
  41090. * Negative value indicates camera should not return to default.
  41091. */
  41092. get elevationReturnTime(): number;
  41093. /**
  41094. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41095. */
  41096. set elevationReturnWaitTime(time: number);
  41097. /**
  41098. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41099. */
  41100. get elevationReturnWaitTime(): number;
  41101. /**
  41102. * Sets the flag that indicates if user zooming should stop animation.
  41103. */
  41104. set zoomStopsAnimation(flag: boolean);
  41105. /**
  41106. * Gets the flag that indicates if user zooming should stop animation.
  41107. */
  41108. get zoomStopsAnimation(): boolean;
  41109. /**
  41110. * Sets the transition time when framing the mesh, in milliseconds
  41111. */
  41112. set framingTime(time: number);
  41113. /**
  41114. * Gets the transition time when framing the mesh, in milliseconds
  41115. */
  41116. get framingTime(): number;
  41117. /**
  41118. * Define if the behavior should automatically change the configured
  41119. * camera limits and sensibilities.
  41120. */
  41121. autoCorrectCameraLimitsAndSensibility: boolean;
  41122. private _onPrePointerObservableObserver;
  41123. private _onAfterCheckInputsObserver;
  41124. private _onMeshTargetChangedObserver;
  41125. private _attachedCamera;
  41126. private _isPointerDown;
  41127. private _lastInteractionTime;
  41128. /**
  41129. * Initializes the behavior.
  41130. */
  41131. init(): void;
  41132. /**
  41133. * Attaches the behavior to its arc rotate camera.
  41134. * @param camera Defines the camera to attach the behavior to
  41135. */
  41136. attach(camera: ArcRotateCamera): void;
  41137. /**
  41138. * Detaches the behavior from its current arc rotate camera.
  41139. */
  41140. detach(): void;
  41141. private _animatables;
  41142. private _betaIsAnimating;
  41143. private _betaTransition;
  41144. private _radiusTransition;
  41145. private _vectorTransition;
  41146. /**
  41147. * Targets the given mesh and updates zoom level accordingly.
  41148. * @param mesh The mesh to target.
  41149. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41150. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41151. */
  41152. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41153. /**
  41154. * Targets the given mesh with its children and updates zoom level accordingly.
  41155. * @param mesh The mesh to target.
  41156. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41157. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41158. */
  41159. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41160. /**
  41161. * Targets the given meshes with their children and updates zoom level accordingly.
  41162. * @param meshes The mesh to target.
  41163. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41164. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41165. */
  41166. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41167. /**
  41168. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41169. * @param minimumWorld Determines the smaller position of the bounding box extend
  41170. * @param maximumWorld Determines the bigger position of the bounding box extend
  41171. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41172. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41173. */
  41174. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41175. /**
  41176. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41177. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41178. * frustum width.
  41179. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41180. * to fully enclose the mesh in the viewing frustum.
  41181. */
  41182. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41183. /**
  41184. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41185. * is automatically returned to its default position (expected to be above ground plane).
  41186. */
  41187. private _maintainCameraAboveGround;
  41188. /**
  41189. * Returns the frustum slope based on the canvas ratio and camera FOV
  41190. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41191. */
  41192. private _getFrustumSlope;
  41193. /**
  41194. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41195. */
  41196. private _clearAnimationLocks;
  41197. /**
  41198. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41199. */
  41200. private _applyUserInteraction;
  41201. /**
  41202. * Stops and removes all animations that have been applied to the camera
  41203. */
  41204. stopAllAnimations(): void;
  41205. /**
  41206. * Gets a value indicating if the user is moving the camera
  41207. */
  41208. get isUserIsMoving(): boolean;
  41209. /**
  41210. * The camera can move all the way towards the mesh.
  41211. */
  41212. static IgnoreBoundsSizeMode: number;
  41213. /**
  41214. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41215. */
  41216. static FitFrustumSidesMode: number;
  41217. }
  41218. }
  41219. declare module BABYLON {
  41220. /**
  41221. * Base class for Camera Pointer Inputs.
  41222. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41223. * for example usage.
  41224. */
  41225. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41226. /**
  41227. * Defines the camera the input is attached to.
  41228. */
  41229. abstract camera: Camera;
  41230. /**
  41231. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41232. */
  41233. protected _altKey: boolean;
  41234. protected _ctrlKey: boolean;
  41235. protected _metaKey: boolean;
  41236. protected _shiftKey: boolean;
  41237. /**
  41238. * Which mouse buttons were pressed at time of last mouse event.
  41239. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41240. */
  41241. protected _buttonsPressed: number;
  41242. /**
  41243. * Defines the buttons associated with the input to handle camera move.
  41244. */
  41245. buttons: number[];
  41246. /**
  41247. * Attach the input controls to a specific dom element to get the input from.
  41248. * @param element Defines the element the controls should be listened from
  41249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41250. */
  41251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41252. /**
  41253. * Detach the current controls from the specified dom element.
  41254. * @param element Defines the element to stop listening the inputs from
  41255. */
  41256. detachControl(element: Nullable<HTMLElement>): void;
  41257. /**
  41258. * Gets the class name of the current input.
  41259. * @returns the class name
  41260. */
  41261. getClassName(): string;
  41262. /**
  41263. * Get the friendly name associated with the input class.
  41264. * @returns the input friendly name
  41265. */
  41266. getSimpleName(): string;
  41267. /**
  41268. * Called on pointer POINTERDOUBLETAP event.
  41269. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41270. */
  41271. protected onDoubleTap(type: string): void;
  41272. /**
  41273. * Called on pointer POINTERMOVE event if only a single touch is active.
  41274. * Override this method to provide functionality.
  41275. */
  41276. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41277. /**
  41278. * Called on pointer POINTERMOVE event if multiple touches are active.
  41279. * Override this method to provide functionality.
  41280. */
  41281. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41282. /**
  41283. * Called on JS contextmenu event.
  41284. * Override this method to provide functionality.
  41285. */
  41286. protected onContextMenu(evt: PointerEvent): void;
  41287. /**
  41288. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41289. * press.
  41290. * Override this method to provide functionality.
  41291. */
  41292. protected onButtonDown(evt: PointerEvent): void;
  41293. /**
  41294. * Called each time a new POINTERUP event occurs. Ie, for each button
  41295. * release.
  41296. * Override this method to provide functionality.
  41297. */
  41298. protected onButtonUp(evt: PointerEvent): void;
  41299. /**
  41300. * Called when window becomes inactive.
  41301. * Override this method to provide functionality.
  41302. */
  41303. protected onLostFocus(): void;
  41304. private _pointerInput;
  41305. private _observer;
  41306. private _onLostFocus;
  41307. private pointA;
  41308. private pointB;
  41309. }
  41310. }
  41311. declare module BABYLON {
  41312. /**
  41313. * Manage the pointers inputs to control an arc rotate camera.
  41314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41315. */
  41316. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41317. /**
  41318. * Defines the camera the input is attached to.
  41319. */
  41320. camera: ArcRotateCamera;
  41321. /**
  41322. * Gets the class name of the current input.
  41323. * @returns the class name
  41324. */
  41325. getClassName(): string;
  41326. /**
  41327. * Defines the buttons associated with the input to handle camera move.
  41328. */
  41329. buttons: number[];
  41330. /**
  41331. * Defines the pointer angular sensibility along the X axis or how fast is
  41332. * the camera rotating.
  41333. */
  41334. angularSensibilityX: number;
  41335. /**
  41336. * Defines the pointer angular sensibility along the Y axis or how fast is
  41337. * the camera rotating.
  41338. */
  41339. angularSensibilityY: number;
  41340. /**
  41341. * Defines the pointer pinch precision or how fast is the camera zooming.
  41342. */
  41343. pinchPrecision: number;
  41344. /**
  41345. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41346. * from 0.
  41347. * It defines the percentage of current camera.radius to use as delta when
  41348. * pinch zoom is used.
  41349. */
  41350. pinchDeltaPercentage: number;
  41351. /**
  41352. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41353. * that any object in the plane at the camera's target point will scale
  41354. * perfectly with finger motion.
  41355. * Overrides pinchDeltaPercentage and pinchPrecision.
  41356. */
  41357. useNaturalPinchZoom: boolean;
  41358. /**
  41359. * Defines the pointer panning sensibility or how fast is the camera moving.
  41360. */
  41361. panningSensibility: number;
  41362. /**
  41363. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41364. */
  41365. multiTouchPanning: boolean;
  41366. /**
  41367. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41368. * zoom (pinch) through multitouch.
  41369. */
  41370. multiTouchPanAndZoom: boolean;
  41371. /**
  41372. * Revers pinch action direction.
  41373. */
  41374. pinchInwards: boolean;
  41375. private _isPanClick;
  41376. private _twoFingerActivityCount;
  41377. private _isPinching;
  41378. /**
  41379. * Called on pointer POINTERMOVE event if only a single touch is active.
  41380. */
  41381. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41382. /**
  41383. * Called on pointer POINTERDOUBLETAP event.
  41384. */
  41385. protected onDoubleTap(type: string): void;
  41386. /**
  41387. * Called on pointer POINTERMOVE event if multiple touches are active.
  41388. */
  41389. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41390. /**
  41391. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41392. * press.
  41393. */
  41394. protected onButtonDown(evt: PointerEvent): void;
  41395. /**
  41396. * Called each time a new POINTERUP event occurs. Ie, for each button
  41397. * release.
  41398. */
  41399. protected onButtonUp(evt: PointerEvent): void;
  41400. /**
  41401. * Called when window becomes inactive.
  41402. */
  41403. protected onLostFocus(): void;
  41404. }
  41405. }
  41406. declare module BABYLON {
  41407. /**
  41408. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41409. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41410. */
  41411. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41412. /**
  41413. * Defines the camera the input is attached to.
  41414. */
  41415. camera: ArcRotateCamera;
  41416. /**
  41417. * Defines the list of key codes associated with the up action (increase alpha)
  41418. */
  41419. keysUp: number[];
  41420. /**
  41421. * Defines the list of key codes associated with the down action (decrease alpha)
  41422. */
  41423. keysDown: number[];
  41424. /**
  41425. * Defines the list of key codes associated with the left action (increase beta)
  41426. */
  41427. keysLeft: number[];
  41428. /**
  41429. * Defines the list of key codes associated with the right action (decrease beta)
  41430. */
  41431. keysRight: number[];
  41432. /**
  41433. * Defines the list of key codes associated with the reset action.
  41434. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41435. */
  41436. keysReset: number[];
  41437. /**
  41438. * Defines the panning sensibility of the inputs.
  41439. * (How fast is the camera panning)
  41440. */
  41441. panningSensibility: number;
  41442. /**
  41443. * Defines the zooming sensibility of the inputs.
  41444. * (How fast is the camera zooming)
  41445. */
  41446. zoomingSensibility: number;
  41447. /**
  41448. * Defines whether maintaining the alt key down switch the movement mode from
  41449. * orientation to zoom.
  41450. */
  41451. useAltToZoom: boolean;
  41452. /**
  41453. * Rotation speed of the camera
  41454. */
  41455. angularSpeed: number;
  41456. private _keys;
  41457. private _ctrlPressed;
  41458. private _altPressed;
  41459. private _onCanvasBlurObserver;
  41460. private _onKeyboardObserver;
  41461. private _engine;
  41462. private _scene;
  41463. /**
  41464. * Attach the input controls to a specific dom element to get the input from.
  41465. * @param element Defines the element the controls should be listened from
  41466. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41467. */
  41468. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41469. /**
  41470. * Detach the current controls from the specified dom element.
  41471. * @param element Defines the element to stop listening the inputs from
  41472. */
  41473. detachControl(element: Nullable<HTMLElement>): void;
  41474. /**
  41475. * Update the current camera state depending on the inputs that have been used this frame.
  41476. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41477. */
  41478. checkInputs(): void;
  41479. /**
  41480. * Gets the class name of the current intput.
  41481. * @returns the class name
  41482. */
  41483. getClassName(): string;
  41484. /**
  41485. * Get the friendly name associated with the input class.
  41486. * @returns the input friendly name
  41487. */
  41488. getSimpleName(): string;
  41489. }
  41490. }
  41491. declare module BABYLON {
  41492. /**
  41493. * Manage the mouse wheel inputs to control an arc rotate camera.
  41494. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41495. */
  41496. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41497. /**
  41498. * Defines the camera the input is attached to.
  41499. */
  41500. camera: ArcRotateCamera;
  41501. /**
  41502. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41503. */
  41504. wheelPrecision: number;
  41505. /**
  41506. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41507. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41508. */
  41509. wheelDeltaPercentage: number;
  41510. private _wheel;
  41511. private _observer;
  41512. private computeDeltaFromMouseWheelLegacyEvent;
  41513. /**
  41514. * Attach the input controls to a specific dom element to get the input from.
  41515. * @param element Defines the element the controls should be listened from
  41516. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41517. */
  41518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41519. /**
  41520. * Detach the current controls from the specified dom element.
  41521. * @param element Defines the element to stop listening the inputs from
  41522. */
  41523. detachControl(element: Nullable<HTMLElement>): void;
  41524. /**
  41525. * Gets the class name of the current intput.
  41526. * @returns the class name
  41527. */
  41528. getClassName(): string;
  41529. /**
  41530. * Get the friendly name associated with the input class.
  41531. * @returns the input friendly name
  41532. */
  41533. getSimpleName(): string;
  41534. }
  41535. }
  41536. declare module BABYLON {
  41537. /**
  41538. * Default Inputs manager for the ArcRotateCamera.
  41539. * It groups all the default supported inputs for ease of use.
  41540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41541. */
  41542. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41543. /**
  41544. * Instantiates a new ArcRotateCameraInputsManager.
  41545. * @param camera Defines the camera the inputs belong to
  41546. */
  41547. constructor(camera: ArcRotateCamera);
  41548. /**
  41549. * Add mouse wheel input support to the input manager.
  41550. * @returns the current input manager
  41551. */
  41552. addMouseWheel(): ArcRotateCameraInputsManager;
  41553. /**
  41554. * Add pointers input support to the input manager.
  41555. * @returns the current input manager
  41556. */
  41557. addPointers(): ArcRotateCameraInputsManager;
  41558. /**
  41559. * Add keyboard input support to the input manager.
  41560. * @returns the current input manager
  41561. */
  41562. addKeyboard(): ArcRotateCameraInputsManager;
  41563. }
  41564. }
  41565. declare module BABYLON {
  41566. /**
  41567. * This represents an orbital type of camera.
  41568. *
  41569. * 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.
  41570. * 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.
  41571. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41572. */
  41573. export class ArcRotateCamera extends TargetCamera {
  41574. /**
  41575. * Defines the rotation angle of the camera along the longitudinal axis.
  41576. */
  41577. alpha: number;
  41578. /**
  41579. * Defines the rotation angle of the camera along the latitudinal axis.
  41580. */
  41581. beta: number;
  41582. /**
  41583. * Defines the radius of the camera from it s target point.
  41584. */
  41585. radius: number;
  41586. protected _target: Vector3;
  41587. protected _targetHost: Nullable<AbstractMesh>;
  41588. /**
  41589. * Defines the target point of the camera.
  41590. * The camera looks towards it form the radius distance.
  41591. */
  41592. get target(): Vector3;
  41593. set target(value: Vector3);
  41594. /**
  41595. * Define the current local position of the camera in the scene
  41596. */
  41597. get position(): Vector3;
  41598. set position(newPosition: Vector3);
  41599. protected _upVector: Vector3;
  41600. protected _upToYMatrix: Matrix;
  41601. protected _YToUpMatrix: Matrix;
  41602. /**
  41603. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41604. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41605. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41606. */
  41607. set upVector(vec: Vector3);
  41608. get upVector(): Vector3;
  41609. /**
  41610. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41611. */
  41612. setMatUp(): void;
  41613. /**
  41614. * Current inertia value on the longitudinal axis.
  41615. * The bigger this number the longer it will take for the camera to stop.
  41616. */
  41617. inertialAlphaOffset: number;
  41618. /**
  41619. * Current inertia value on the latitudinal axis.
  41620. * The bigger this number the longer it will take for the camera to stop.
  41621. */
  41622. inertialBetaOffset: number;
  41623. /**
  41624. * Current inertia value on the radius axis.
  41625. * The bigger this number the longer it will take for the camera to stop.
  41626. */
  41627. inertialRadiusOffset: number;
  41628. /**
  41629. * Minimum allowed angle on the longitudinal axis.
  41630. * This can help limiting how the Camera is able to move in the scene.
  41631. */
  41632. lowerAlphaLimit: Nullable<number>;
  41633. /**
  41634. * Maximum allowed angle on the longitudinal axis.
  41635. * This can help limiting how the Camera is able to move in the scene.
  41636. */
  41637. upperAlphaLimit: Nullable<number>;
  41638. /**
  41639. * Minimum allowed angle on the latitudinal axis.
  41640. * This can help limiting how the Camera is able to move in the scene.
  41641. */
  41642. lowerBetaLimit: number;
  41643. /**
  41644. * Maximum allowed angle on the latitudinal axis.
  41645. * This can help limiting how the Camera is able to move in the scene.
  41646. */
  41647. upperBetaLimit: number;
  41648. /**
  41649. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41650. * This can help limiting how the Camera is able to move in the scene.
  41651. */
  41652. lowerRadiusLimit: Nullable<number>;
  41653. /**
  41654. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41655. * This can help limiting how the Camera is able to move in the scene.
  41656. */
  41657. upperRadiusLimit: Nullable<number>;
  41658. /**
  41659. * Defines the current inertia value used during panning of the camera along the X axis.
  41660. */
  41661. inertialPanningX: number;
  41662. /**
  41663. * Defines the current inertia value used during panning of the camera along the Y axis.
  41664. */
  41665. inertialPanningY: number;
  41666. /**
  41667. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41668. * Basically if your fingers moves away from more than this distance you will be considered
  41669. * in pinch mode.
  41670. */
  41671. pinchToPanMaxDistance: number;
  41672. /**
  41673. * Defines the maximum distance the camera can pan.
  41674. * This could help keeping the cammera always in your scene.
  41675. */
  41676. panningDistanceLimit: Nullable<number>;
  41677. /**
  41678. * Defines the target of the camera before paning.
  41679. */
  41680. panningOriginTarget: Vector3;
  41681. /**
  41682. * Defines the value of the inertia used during panning.
  41683. * 0 would mean stop inertia and one would mean no decelleration at all.
  41684. */
  41685. panningInertia: number;
  41686. /**
  41687. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41688. */
  41689. get angularSensibilityX(): number;
  41690. set angularSensibilityX(value: number);
  41691. /**
  41692. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41693. */
  41694. get angularSensibilityY(): number;
  41695. set angularSensibilityY(value: number);
  41696. /**
  41697. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41698. */
  41699. get pinchPrecision(): number;
  41700. set pinchPrecision(value: number);
  41701. /**
  41702. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41703. * It will be used instead of pinchDeltaPrecision if different from 0.
  41704. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41705. */
  41706. get pinchDeltaPercentage(): number;
  41707. set pinchDeltaPercentage(value: number);
  41708. /**
  41709. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41710. * and pinch delta percentage.
  41711. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41712. * that any object in the plane at the camera's target point will scale
  41713. * perfectly with finger motion.
  41714. */
  41715. get useNaturalPinchZoom(): boolean;
  41716. set useNaturalPinchZoom(value: boolean);
  41717. /**
  41718. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41719. */
  41720. get panningSensibility(): number;
  41721. set panningSensibility(value: number);
  41722. /**
  41723. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41724. */
  41725. get keysUp(): number[];
  41726. set keysUp(value: number[]);
  41727. /**
  41728. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41729. */
  41730. get keysDown(): number[];
  41731. set keysDown(value: number[]);
  41732. /**
  41733. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41734. */
  41735. get keysLeft(): number[];
  41736. set keysLeft(value: number[]);
  41737. /**
  41738. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41739. */
  41740. get keysRight(): number[];
  41741. set keysRight(value: number[]);
  41742. /**
  41743. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41744. */
  41745. get wheelPrecision(): number;
  41746. set wheelPrecision(value: number);
  41747. /**
  41748. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41749. * It will be used instead of pinchDeltaPrecision if different from 0.
  41750. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41751. */
  41752. get wheelDeltaPercentage(): number;
  41753. set wheelDeltaPercentage(value: number);
  41754. /**
  41755. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41756. */
  41757. zoomOnFactor: number;
  41758. /**
  41759. * Defines a screen offset for the camera position.
  41760. */
  41761. targetScreenOffset: Vector2;
  41762. /**
  41763. * Allows the camera to be completely reversed.
  41764. * If false the camera can not arrive upside down.
  41765. */
  41766. allowUpsideDown: boolean;
  41767. /**
  41768. * Define if double tap/click is used to restore the previously saved state of the camera.
  41769. */
  41770. useInputToRestoreState: boolean;
  41771. /** @hidden */
  41772. _viewMatrix: Matrix;
  41773. /** @hidden */
  41774. _useCtrlForPanning: boolean;
  41775. /** @hidden */
  41776. _panningMouseButton: number;
  41777. /**
  41778. * Defines the input associated to the camera.
  41779. */
  41780. inputs: ArcRotateCameraInputsManager;
  41781. /** @hidden */
  41782. _reset: () => void;
  41783. /**
  41784. * Defines the allowed panning axis.
  41785. */
  41786. panningAxis: Vector3;
  41787. protected _localDirection: Vector3;
  41788. protected _transformedDirection: Vector3;
  41789. private _bouncingBehavior;
  41790. /**
  41791. * Gets the bouncing behavior of the camera if it has been enabled.
  41792. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41793. */
  41794. get bouncingBehavior(): Nullable<BouncingBehavior>;
  41795. /**
  41796. * Defines if the bouncing behavior of the camera is enabled on the camera.
  41797. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41798. */
  41799. get useBouncingBehavior(): boolean;
  41800. set useBouncingBehavior(value: boolean);
  41801. private _framingBehavior;
  41802. /**
  41803. * Gets the framing behavior of the camera if it has been enabled.
  41804. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41805. */
  41806. get framingBehavior(): Nullable<FramingBehavior>;
  41807. /**
  41808. * Defines if the framing behavior of the camera is enabled on the camera.
  41809. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41810. */
  41811. get useFramingBehavior(): boolean;
  41812. set useFramingBehavior(value: boolean);
  41813. private _autoRotationBehavior;
  41814. /**
  41815. * Gets the auto rotation behavior of the camera if it has been enabled.
  41816. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41817. */
  41818. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  41819. /**
  41820. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  41821. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41822. */
  41823. get useAutoRotationBehavior(): boolean;
  41824. set useAutoRotationBehavior(value: boolean);
  41825. /**
  41826. * Observable triggered when the mesh target has been changed on the camera.
  41827. */
  41828. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  41829. /**
  41830. * Event raised when the camera is colliding with a mesh.
  41831. */
  41832. onCollide: (collidedMesh: AbstractMesh) => void;
  41833. /**
  41834. * Defines whether the camera should check collision with the objects oh the scene.
  41835. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  41836. */
  41837. checkCollisions: boolean;
  41838. /**
  41839. * Defines the collision radius of the camera.
  41840. * This simulates a sphere around the camera.
  41841. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41842. */
  41843. collisionRadius: Vector3;
  41844. protected _collider: Collider;
  41845. protected _previousPosition: Vector3;
  41846. protected _collisionVelocity: Vector3;
  41847. protected _newPosition: Vector3;
  41848. protected _previousAlpha: number;
  41849. protected _previousBeta: number;
  41850. protected _previousRadius: number;
  41851. protected _collisionTriggered: boolean;
  41852. protected _targetBoundingCenter: Nullable<Vector3>;
  41853. private _computationVector;
  41854. /**
  41855. * Instantiates a new ArcRotateCamera in a given scene
  41856. * @param name Defines the name of the camera
  41857. * @param alpha Defines the camera rotation along the logitudinal axis
  41858. * @param beta Defines the camera rotation along the latitudinal axis
  41859. * @param radius Defines the camera distance from its target
  41860. * @param target Defines the camera target
  41861. * @param scene Defines the scene the camera belongs to
  41862. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  41863. */
  41864. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41865. /** @hidden */
  41866. _initCache(): void;
  41867. /** @hidden */
  41868. _updateCache(ignoreParentClass?: boolean): void;
  41869. protected _getTargetPosition(): Vector3;
  41870. private _storedAlpha;
  41871. private _storedBeta;
  41872. private _storedRadius;
  41873. private _storedTarget;
  41874. private _storedTargetScreenOffset;
  41875. /**
  41876. * Stores the current state of the camera (alpha, beta, radius and target)
  41877. * @returns the camera itself
  41878. */
  41879. storeState(): Camera;
  41880. /**
  41881. * @hidden
  41882. * Restored camera state. You must call storeState() first
  41883. */
  41884. _restoreStateValues(): boolean;
  41885. /** @hidden */
  41886. _isSynchronizedViewMatrix(): boolean;
  41887. /**
  41888. * Attached controls to the current camera.
  41889. * @param element Defines the element the controls should be listened from
  41890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41891. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  41892. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  41893. */
  41894. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  41895. /**
  41896. * Detach the current controls from the camera.
  41897. * The camera will stop reacting to inputs.
  41898. * @param element Defines the element to stop listening the inputs from
  41899. */
  41900. detachControl(element: HTMLElement): void;
  41901. /** @hidden */
  41902. _checkInputs(): void;
  41903. protected _checkLimits(): void;
  41904. /**
  41905. * Rebuilds angles (alpha, beta) and radius from the give position and target
  41906. */
  41907. rebuildAnglesAndRadius(): void;
  41908. /**
  41909. * Use a position to define the current camera related information like alpha, beta and radius
  41910. * @param position Defines the position to set the camera at
  41911. */
  41912. setPosition(position: Vector3): void;
  41913. /**
  41914. * Defines the target the camera should look at.
  41915. * This will automatically adapt alpha beta and radius to fit within the new target.
  41916. * @param target Defines the new target as a Vector or a mesh
  41917. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  41918. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  41919. */
  41920. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  41921. /** @hidden */
  41922. _getViewMatrix(): Matrix;
  41923. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  41924. /**
  41925. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  41926. * @param meshes Defines the mesh to zoom on
  41927. * @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)
  41928. */
  41929. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  41930. /**
  41931. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  41932. * The target will be changed but the radius
  41933. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  41934. * @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)
  41935. */
  41936. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  41937. min: Vector3;
  41938. max: Vector3;
  41939. distance: number;
  41940. }, doNotUpdateMaxZ?: boolean): void;
  41941. /**
  41942. * @override
  41943. * Override Camera.createRigCamera
  41944. */
  41945. createRigCamera(name: string, cameraIndex: number): Camera;
  41946. /**
  41947. * @hidden
  41948. * @override
  41949. * Override Camera._updateRigCameras
  41950. */
  41951. _updateRigCameras(): void;
  41952. /**
  41953. * Destroy the camera and release the current resources hold by it.
  41954. */
  41955. dispose(): void;
  41956. /**
  41957. * Gets the current object class name.
  41958. * @return the class name
  41959. */
  41960. getClassName(): string;
  41961. }
  41962. }
  41963. declare module BABYLON {
  41964. /**
  41965. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  41966. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41967. */
  41968. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  41969. /**
  41970. * Gets the name of the behavior.
  41971. */
  41972. get name(): string;
  41973. private _zoomStopsAnimation;
  41974. private _idleRotationSpeed;
  41975. private _idleRotationWaitTime;
  41976. private _idleRotationSpinupTime;
  41977. /**
  41978. * Sets the flag that indicates if user zooming should stop animation.
  41979. */
  41980. set zoomStopsAnimation(flag: boolean);
  41981. /**
  41982. * Gets the flag that indicates if user zooming should stop animation.
  41983. */
  41984. get zoomStopsAnimation(): boolean;
  41985. /**
  41986. * Sets the default speed at which the camera rotates around the model.
  41987. */
  41988. set idleRotationSpeed(speed: number);
  41989. /**
  41990. * Gets the default speed at which the camera rotates around the model.
  41991. */
  41992. get idleRotationSpeed(): number;
  41993. /**
  41994. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  41995. */
  41996. set idleRotationWaitTime(time: number);
  41997. /**
  41998. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  41999. */
  42000. get idleRotationWaitTime(): number;
  42001. /**
  42002. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42003. */
  42004. set idleRotationSpinupTime(time: number);
  42005. /**
  42006. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42007. */
  42008. get idleRotationSpinupTime(): number;
  42009. /**
  42010. * Gets a value indicating if the camera is currently rotating because of this behavior
  42011. */
  42012. get rotationInProgress(): boolean;
  42013. private _onPrePointerObservableObserver;
  42014. private _onAfterCheckInputsObserver;
  42015. private _attachedCamera;
  42016. private _isPointerDown;
  42017. private _lastFrameTime;
  42018. private _lastInteractionTime;
  42019. private _cameraRotationSpeed;
  42020. /**
  42021. * Initializes the behavior.
  42022. */
  42023. init(): void;
  42024. /**
  42025. * Attaches the behavior to its arc rotate camera.
  42026. * @param camera Defines the camera to attach the behavior to
  42027. */
  42028. attach(camera: ArcRotateCamera): void;
  42029. /**
  42030. * Detaches the behavior from its current arc rotate camera.
  42031. */
  42032. detach(): void;
  42033. /**
  42034. * Returns true if user is scrolling.
  42035. * @return true if user is scrolling.
  42036. */
  42037. private _userIsZooming;
  42038. private _lastFrameRadius;
  42039. private _shouldAnimationStopForInteraction;
  42040. /**
  42041. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42042. */
  42043. private _applyUserInteraction;
  42044. private _userIsMoving;
  42045. }
  42046. }
  42047. declare module BABYLON {
  42048. /**
  42049. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42050. */
  42051. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42052. private ui;
  42053. /**
  42054. * The name of the behavior
  42055. */
  42056. name: string;
  42057. /**
  42058. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42059. */
  42060. distanceAwayFromFace: number;
  42061. /**
  42062. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42063. */
  42064. distanceAwayFromBottomOfFace: number;
  42065. private _faceVectors;
  42066. private _target;
  42067. private _scene;
  42068. private _onRenderObserver;
  42069. private _tmpMatrix;
  42070. private _tmpVector;
  42071. /**
  42072. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42073. * @param ui The transform node that should be attched to the mesh
  42074. */
  42075. constructor(ui: TransformNode);
  42076. /**
  42077. * Initializes the behavior
  42078. */
  42079. init(): void;
  42080. private _closestFace;
  42081. private _zeroVector;
  42082. private _lookAtTmpMatrix;
  42083. private _lookAtToRef;
  42084. /**
  42085. * Attaches the AttachToBoxBehavior to the passed in mesh
  42086. * @param target The mesh that the specified node will be attached to
  42087. */
  42088. attach(target: Mesh): void;
  42089. /**
  42090. * Detaches the behavior from the mesh
  42091. */
  42092. detach(): void;
  42093. }
  42094. }
  42095. declare module BABYLON {
  42096. /**
  42097. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42098. */
  42099. export class FadeInOutBehavior implements Behavior<Mesh> {
  42100. /**
  42101. * Time in milliseconds to delay before fading in (Default: 0)
  42102. */
  42103. delay: number;
  42104. /**
  42105. * Time in milliseconds for the mesh to fade in (Default: 300)
  42106. */
  42107. fadeInTime: number;
  42108. private _millisecondsPerFrame;
  42109. private _hovered;
  42110. private _hoverValue;
  42111. private _ownerNode;
  42112. /**
  42113. * Instatiates the FadeInOutBehavior
  42114. */
  42115. constructor();
  42116. /**
  42117. * The name of the behavior
  42118. */
  42119. get name(): string;
  42120. /**
  42121. * Initializes the behavior
  42122. */
  42123. init(): void;
  42124. /**
  42125. * Attaches the fade behavior on the passed in mesh
  42126. * @param ownerNode The mesh that will be faded in/out once attached
  42127. */
  42128. attach(ownerNode: Mesh): void;
  42129. /**
  42130. * Detaches the behavior from the mesh
  42131. */
  42132. detach(): void;
  42133. /**
  42134. * Triggers the mesh to begin fading in or out
  42135. * @param value if the object should fade in or out (true to fade in)
  42136. */
  42137. fadeIn(value: boolean): void;
  42138. private _update;
  42139. private _setAllVisibility;
  42140. }
  42141. }
  42142. declare module BABYLON {
  42143. /**
  42144. * Class containing a set of static utilities functions for managing Pivots
  42145. * @hidden
  42146. */
  42147. export class PivotTools {
  42148. private static _PivotCached;
  42149. private static _OldPivotPoint;
  42150. private static _PivotTranslation;
  42151. private static _PivotTmpVector;
  42152. /** @hidden */
  42153. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42154. /** @hidden */
  42155. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42156. }
  42157. }
  42158. declare module BABYLON {
  42159. /**
  42160. * Class containing static functions to help procedurally build meshes
  42161. */
  42162. export class PlaneBuilder {
  42163. /**
  42164. * Creates a plane mesh
  42165. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42166. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42167. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42169. * * 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
  42170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42171. * @param name defines the name of the mesh
  42172. * @param options defines the options used to create the mesh
  42173. * @param scene defines the hosting scene
  42174. * @returns the plane mesh
  42175. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42176. */
  42177. static CreatePlane(name: string, options: {
  42178. size?: number;
  42179. width?: number;
  42180. height?: number;
  42181. sideOrientation?: number;
  42182. frontUVs?: Vector4;
  42183. backUVs?: Vector4;
  42184. updatable?: boolean;
  42185. sourcePlane?: Plane;
  42186. }, scene?: Nullable<Scene>): Mesh;
  42187. }
  42188. }
  42189. declare module BABYLON {
  42190. /**
  42191. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42192. */
  42193. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42194. private static _AnyMouseID;
  42195. /**
  42196. * Abstract mesh the behavior is set on
  42197. */
  42198. attachedNode: AbstractMesh;
  42199. private _dragPlane;
  42200. private _scene;
  42201. private _pointerObserver;
  42202. private _beforeRenderObserver;
  42203. private static _planeScene;
  42204. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42205. /**
  42206. * 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)
  42207. */
  42208. maxDragAngle: number;
  42209. /**
  42210. * @hidden
  42211. */
  42212. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42213. /**
  42214. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42215. */
  42216. currentDraggingPointerID: number;
  42217. /**
  42218. * The last position where the pointer hit the drag plane in world space
  42219. */
  42220. lastDragPosition: Vector3;
  42221. /**
  42222. * If the behavior is currently in a dragging state
  42223. */
  42224. dragging: boolean;
  42225. /**
  42226. * 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)
  42227. */
  42228. dragDeltaRatio: number;
  42229. /**
  42230. * If the drag plane orientation should be updated during the dragging (Default: true)
  42231. */
  42232. updateDragPlane: boolean;
  42233. private _debugMode;
  42234. private _moving;
  42235. /**
  42236. * Fires each time the attached mesh is dragged with the pointer
  42237. * * delta between last drag position and current drag position in world space
  42238. * * dragDistance along the drag axis
  42239. * * dragPlaneNormal normal of the current drag plane used during the drag
  42240. * * dragPlanePoint in world space where the drag intersects the drag plane
  42241. */
  42242. onDragObservable: Observable<{
  42243. delta: Vector3;
  42244. dragPlanePoint: Vector3;
  42245. dragPlaneNormal: Vector3;
  42246. dragDistance: number;
  42247. pointerId: number;
  42248. }>;
  42249. /**
  42250. * Fires each time a drag begins (eg. mouse down on mesh)
  42251. */
  42252. onDragStartObservable: Observable<{
  42253. dragPlanePoint: Vector3;
  42254. pointerId: number;
  42255. }>;
  42256. /**
  42257. * Fires each time a drag ends (eg. mouse release after drag)
  42258. */
  42259. onDragEndObservable: Observable<{
  42260. dragPlanePoint: Vector3;
  42261. pointerId: number;
  42262. }>;
  42263. /**
  42264. * If the attached mesh should be moved when dragged
  42265. */
  42266. moveAttached: boolean;
  42267. /**
  42268. * If the drag behavior will react to drag events (Default: true)
  42269. */
  42270. enabled: boolean;
  42271. /**
  42272. * If pointer events should start and release the drag (Default: true)
  42273. */
  42274. startAndReleaseDragOnPointerEvents: boolean;
  42275. /**
  42276. * If camera controls should be detached during the drag
  42277. */
  42278. detachCameraControls: boolean;
  42279. /**
  42280. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42281. */
  42282. useObjectOrientationForDragging: boolean;
  42283. private _options;
  42284. /**
  42285. * Gets the options used by the behavior
  42286. */
  42287. get options(): {
  42288. dragAxis?: Vector3;
  42289. dragPlaneNormal?: Vector3;
  42290. };
  42291. /**
  42292. * Sets the options used by the behavior
  42293. */
  42294. set options(options: {
  42295. dragAxis?: Vector3;
  42296. dragPlaneNormal?: Vector3;
  42297. });
  42298. /**
  42299. * Creates a pointer drag behavior that can be attached to a mesh
  42300. * @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)
  42301. */
  42302. constructor(options?: {
  42303. dragAxis?: Vector3;
  42304. dragPlaneNormal?: Vector3;
  42305. });
  42306. /**
  42307. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42308. */
  42309. validateDrag: (targetPosition: Vector3) => boolean;
  42310. /**
  42311. * The name of the behavior
  42312. */
  42313. get name(): string;
  42314. /**
  42315. * Initializes the behavior
  42316. */
  42317. init(): void;
  42318. private _tmpVector;
  42319. private _alternatePickedPoint;
  42320. private _worldDragAxis;
  42321. private _targetPosition;
  42322. private _attachedElement;
  42323. /**
  42324. * Attaches the drag behavior the passed in mesh
  42325. * @param ownerNode The mesh that will be dragged around once attached
  42326. * @param predicate Predicate to use for pick filtering
  42327. */
  42328. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42329. /**
  42330. * Force relase the drag action by code.
  42331. */
  42332. releaseDrag(): void;
  42333. private _startDragRay;
  42334. private _lastPointerRay;
  42335. /**
  42336. * Simulates the start of a pointer drag event on the behavior
  42337. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42338. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42339. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42340. */
  42341. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42342. private _startDrag;
  42343. private _dragDelta;
  42344. private _moveDrag;
  42345. private _pickWithRayOnDragPlane;
  42346. private _pointA;
  42347. private _pointB;
  42348. private _pointC;
  42349. private _lineA;
  42350. private _lineB;
  42351. private _localAxis;
  42352. private _lookAt;
  42353. private _updateDragPlanePosition;
  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 scaled
  42363. */
  42364. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42365. private _dragBehaviorA;
  42366. private _dragBehaviorB;
  42367. private _startDistance;
  42368. private _initialScale;
  42369. private _targetScale;
  42370. private _ownerNode;
  42371. private _sceneRenderObserver;
  42372. /**
  42373. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42374. */
  42375. constructor();
  42376. /**
  42377. * The name of the behavior
  42378. */
  42379. get name(): string;
  42380. /**
  42381. * Initializes the behavior
  42382. */
  42383. init(): void;
  42384. private _getCurrentDistance;
  42385. /**
  42386. * Attaches the scale behavior the passed in mesh
  42387. * @param ownerNode The mesh that will be scaled around once attached
  42388. */
  42389. attach(ownerNode: Mesh): void;
  42390. /**
  42391. * Detaches the behavior from the mesh
  42392. */
  42393. detach(): void;
  42394. }
  42395. }
  42396. declare module BABYLON {
  42397. /**
  42398. * 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
  42399. */
  42400. export class SixDofDragBehavior implements Behavior<Mesh> {
  42401. private static _virtualScene;
  42402. private _ownerNode;
  42403. private _sceneRenderObserver;
  42404. private _scene;
  42405. private _targetPosition;
  42406. private _virtualOriginMesh;
  42407. private _virtualDragMesh;
  42408. private _pointerObserver;
  42409. private _moving;
  42410. private _startingOrientation;
  42411. private _attachedElement;
  42412. /**
  42413. * 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)
  42414. */
  42415. private zDragFactor;
  42416. /**
  42417. * If the object should rotate to face the drag origin
  42418. */
  42419. rotateDraggedObject: boolean;
  42420. /**
  42421. * If the behavior is currently in a dragging state
  42422. */
  42423. dragging: boolean;
  42424. /**
  42425. * 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)
  42426. */
  42427. dragDeltaRatio: number;
  42428. /**
  42429. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42430. */
  42431. currentDraggingPointerID: number;
  42432. /**
  42433. * If camera controls should be detached during the drag
  42434. */
  42435. detachCameraControls: boolean;
  42436. /**
  42437. * Fires each time a drag starts
  42438. */
  42439. onDragStartObservable: Observable<{}>;
  42440. /**
  42441. * Fires each time a drag ends (eg. mouse release after drag)
  42442. */
  42443. onDragEndObservable: Observable<{}>;
  42444. /**
  42445. * 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
  42446. */
  42447. constructor();
  42448. /**
  42449. * The name of the behavior
  42450. */
  42451. get name(): string;
  42452. /**
  42453. * Initializes the behavior
  42454. */
  42455. init(): void;
  42456. /**
  42457. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42458. */
  42459. private get _pointerCamera();
  42460. /**
  42461. * Attaches the scale behavior the passed in mesh
  42462. * @param ownerNode The mesh that will be scaled around once attached
  42463. */
  42464. attach(ownerNode: Mesh): void;
  42465. /**
  42466. * Detaches the behavior from the mesh
  42467. */
  42468. detach(): void;
  42469. }
  42470. }
  42471. declare module BABYLON {
  42472. /**
  42473. * Class used to apply inverse kinematics to bones
  42474. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42475. */
  42476. export class BoneIKController {
  42477. private static _tmpVecs;
  42478. private static _tmpQuat;
  42479. private static _tmpMats;
  42480. /**
  42481. * Gets or sets the target mesh
  42482. */
  42483. targetMesh: AbstractMesh;
  42484. /** Gets or sets the mesh used as pole */
  42485. poleTargetMesh: AbstractMesh;
  42486. /**
  42487. * Gets or sets the bone used as pole
  42488. */
  42489. poleTargetBone: Nullable<Bone>;
  42490. /**
  42491. * Gets or sets the target position
  42492. */
  42493. targetPosition: Vector3;
  42494. /**
  42495. * Gets or sets the pole target position
  42496. */
  42497. poleTargetPosition: Vector3;
  42498. /**
  42499. * Gets or sets the pole target local offset
  42500. */
  42501. poleTargetLocalOffset: Vector3;
  42502. /**
  42503. * Gets or sets the pole angle
  42504. */
  42505. poleAngle: number;
  42506. /**
  42507. * Gets or sets the mesh associated with the controller
  42508. */
  42509. mesh: AbstractMesh;
  42510. /**
  42511. * 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)
  42512. */
  42513. slerpAmount: number;
  42514. private _bone1Quat;
  42515. private _bone1Mat;
  42516. private _bone2Ang;
  42517. private _bone1;
  42518. private _bone2;
  42519. private _bone1Length;
  42520. private _bone2Length;
  42521. private _maxAngle;
  42522. private _maxReach;
  42523. private _rightHandedSystem;
  42524. private _bendAxis;
  42525. private _slerping;
  42526. private _adjustRoll;
  42527. /**
  42528. * Gets or sets maximum allowed angle
  42529. */
  42530. get maxAngle(): number;
  42531. set maxAngle(value: number);
  42532. /**
  42533. * Creates a new BoneIKController
  42534. * @param mesh defines the mesh to control
  42535. * @param bone defines the bone to control
  42536. * @param options defines options to set up the controller
  42537. */
  42538. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42539. targetMesh?: AbstractMesh;
  42540. poleTargetMesh?: AbstractMesh;
  42541. poleTargetBone?: Bone;
  42542. poleTargetLocalOffset?: Vector3;
  42543. poleAngle?: number;
  42544. bendAxis?: Vector3;
  42545. maxAngle?: number;
  42546. slerpAmount?: number;
  42547. });
  42548. private _setMaxAngle;
  42549. /**
  42550. * Force the controller to update the bones
  42551. */
  42552. update(): void;
  42553. }
  42554. }
  42555. declare module BABYLON {
  42556. /**
  42557. * Class used to make a bone look toward a point in space
  42558. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42559. */
  42560. export class BoneLookController {
  42561. private static _tmpVecs;
  42562. private static _tmpQuat;
  42563. private static _tmpMats;
  42564. /**
  42565. * The target Vector3 that the bone will look at
  42566. */
  42567. target: Vector3;
  42568. /**
  42569. * The mesh that the bone is attached to
  42570. */
  42571. mesh: AbstractMesh;
  42572. /**
  42573. * The bone that will be looking to the target
  42574. */
  42575. bone: Bone;
  42576. /**
  42577. * The up axis of the coordinate system that is used when the bone is rotated
  42578. */
  42579. upAxis: Vector3;
  42580. /**
  42581. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42582. */
  42583. upAxisSpace: Space;
  42584. /**
  42585. * Used to make an adjustment to the yaw of the bone
  42586. */
  42587. adjustYaw: number;
  42588. /**
  42589. * Used to make an adjustment to the pitch of the bone
  42590. */
  42591. adjustPitch: number;
  42592. /**
  42593. * Used to make an adjustment to the roll of the bone
  42594. */
  42595. adjustRoll: number;
  42596. /**
  42597. * 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)
  42598. */
  42599. slerpAmount: number;
  42600. private _minYaw;
  42601. private _maxYaw;
  42602. private _minPitch;
  42603. private _maxPitch;
  42604. private _minYawSin;
  42605. private _minYawCos;
  42606. private _maxYawSin;
  42607. private _maxYawCos;
  42608. private _midYawConstraint;
  42609. private _minPitchTan;
  42610. private _maxPitchTan;
  42611. private _boneQuat;
  42612. private _slerping;
  42613. private _transformYawPitch;
  42614. private _transformYawPitchInv;
  42615. private _firstFrameSkipped;
  42616. private _yawRange;
  42617. private _fowardAxis;
  42618. /**
  42619. * Gets or sets the minimum yaw angle that the bone can look to
  42620. */
  42621. get minYaw(): number;
  42622. set minYaw(value: number);
  42623. /**
  42624. * Gets or sets the maximum yaw angle that the bone can look to
  42625. */
  42626. get maxYaw(): number;
  42627. set maxYaw(value: number);
  42628. /**
  42629. * Gets or sets the minimum pitch angle that the bone can look to
  42630. */
  42631. get minPitch(): number;
  42632. set minPitch(value: number);
  42633. /**
  42634. * Gets or sets the maximum pitch angle that the bone can look to
  42635. */
  42636. get maxPitch(): number;
  42637. set maxPitch(value: number);
  42638. /**
  42639. * Create a BoneLookController
  42640. * @param mesh the mesh that the bone belongs to
  42641. * @param bone the bone that will be looking to the target
  42642. * @param target the target Vector3 to look at
  42643. * @param options optional settings:
  42644. * * maxYaw: the maximum angle the bone will yaw to
  42645. * * minYaw: the minimum angle the bone will yaw to
  42646. * * maxPitch: the maximum angle the bone will pitch to
  42647. * * minPitch: the minimum angle the bone will yaw to
  42648. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42649. * * upAxis: the up axis of the coordinate system
  42650. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42651. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42652. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42653. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42654. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42655. * * adjustRoll: used to make an adjustment to the roll of the bone
  42656. **/
  42657. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42658. maxYaw?: number;
  42659. minYaw?: number;
  42660. maxPitch?: number;
  42661. minPitch?: number;
  42662. slerpAmount?: number;
  42663. upAxis?: Vector3;
  42664. upAxisSpace?: Space;
  42665. yawAxis?: Vector3;
  42666. pitchAxis?: Vector3;
  42667. adjustYaw?: number;
  42668. adjustPitch?: number;
  42669. adjustRoll?: number;
  42670. });
  42671. /**
  42672. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42673. */
  42674. update(): void;
  42675. private _getAngleDiff;
  42676. private _getAngleBetween;
  42677. private _isAngleBetween;
  42678. }
  42679. }
  42680. declare module BABYLON {
  42681. /**
  42682. * Manage the gamepad inputs to control an arc rotate camera.
  42683. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42684. */
  42685. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42686. /**
  42687. * Defines the camera the input is attached to.
  42688. */
  42689. camera: ArcRotateCamera;
  42690. /**
  42691. * Defines the gamepad the input is gathering event from.
  42692. */
  42693. gamepad: Nullable<Gamepad>;
  42694. /**
  42695. * Defines the gamepad rotation sensiblity.
  42696. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42697. */
  42698. gamepadRotationSensibility: number;
  42699. /**
  42700. * Defines the gamepad move sensiblity.
  42701. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42702. */
  42703. gamepadMoveSensibility: number;
  42704. private _yAxisScale;
  42705. /**
  42706. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42707. */
  42708. get invertYAxis(): boolean;
  42709. set invertYAxis(value: boolean);
  42710. private _onGamepadConnectedObserver;
  42711. private _onGamepadDisconnectedObserver;
  42712. /**
  42713. * Attach the input controls to a specific dom element to get the input from.
  42714. * @param element Defines the element the controls should be listened from
  42715. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42716. */
  42717. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42718. /**
  42719. * Detach the current controls from the specified dom element.
  42720. * @param element Defines the element to stop listening the inputs from
  42721. */
  42722. detachControl(element: Nullable<HTMLElement>): void;
  42723. /**
  42724. * Update the current camera state depending on the inputs that have been used this frame.
  42725. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42726. */
  42727. checkInputs(): void;
  42728. /**
  42729. * Gets the class name of the current intput.
  42730. * @returns the class name
  42731. */
  42732. getClassName(): string;
  42733. /**
  42734. * Get the friendly name associated with the input class.
  42735. * @returns the input friendly name
  42736. */
  42737. getSimpleName(): string;
  42738. }
  42739. }
  42740. declare module BABYLON {
  42741. interface ArcRotateCameraInputsManager {
  42742. /**
  42743. * Add orientation input support to the input manager.
  42744. * @returns the current input manager
  42745. */
  42746. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42747. }
  42748. /**
  42749. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42750. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42751. */
  42752. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42753. /**
  42754. * Defines the camera the input is attached to.
  42755. */
  42756. camera: ArcRotateCamera;
  42757. /**
  42758. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42759. */
  42760. alphaCorrection: number;
  42761. /**
  42762. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42763. */
  42764. gammaCorrection: number;
  42765. private _alpha;
  42766. private _gamma;
  42767. private _dirty;
  42768. private _deviceOrientationHandler;
  42769. /**
  42770. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42771. */
  42772. constructor();
  42773. /**
  42774. * Attach the input controls to a specific dom element to get the input from.
  42775. * @param element Defines the element the controls should be listened from
  42776. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42777. */
  42778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42779. /** @hidden */
  42780. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42781. /**
  42782. * Update the current camera state depending on the inputs that have been used this frame.
  42783. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42784. */
  42785. checkInputs(): void;
  42786. /**
  42787. * Detach the current controls from the specified dom element.
  42788. * @param element Defines the element to stop listening the inputs from
  42789. */
  42790. detachControl(element: Nullable<HTMLElement>): void;
  42791. /**
  42792. * Gets the class name of the current intput.
  42793. * @returns the class name
  42794. */
  42795. getClassName(): string;
  42796. /**
  42797. * Get the friendly name associated with the input class.
  42798. * @returns the input friendly name
  42799. */
  42800. getSimpleName(): string;
  42801. }
  42802. }
  42803. declare module BABYLON {
  42804. /**
  42805. * Listen to mouse events to control the camera.
  42806. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42807. */
  42808. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42809. /**
  42810. * Defines the camera the input is attached to.
  42811. */
  42812. camera: FlyCamera;
  42813. /**
  42814. * Defines if touch is enabled. (Default is true.)
  42815. */
  42816. touchEnabled: boolean;
  42817. /**
  42818. * Defines the buttons associated with the input to handle camera rotation.
  42819. */
  42820. buttons: number[];
  42821. /**
  42822. * Assign buttons for Yaw control.
  42823. */
  42824. buttonsYaw: number[];
  42825. /**
  42826. * Assign buttons for Pitch control.
  42827. */
  42828. buttonsPitch: number[];
  42829. /**
  42830. * Assign buttons for Roll control.
  42831. */
  42832. buttonsRoll: number[];
  42833. /**
  42834. * Detect if any button is being pressed while mouse is moved.
  42835. * -1 = Mouse locked.
  42836. * 0 = Left button.
  42837. * 1 = Middle Button.
  42838. * 2 = Right Button.
  42839. */
  42840. activeButton: number;
  42841. /**
  42842. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42843. * Higher values reduce its sensitivity.
  42844. */
  42845. angularSensibility: number;
  42846. private _mousemoveCallback;
  42847. private _observer;
  42848. private _rollObserver;
  42849. private previousPosition;
  42850. private noPreventDefault;
  42851. private element;
  42852. /**
  42853. * Listen to mouse events to control the camera.
  42854. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42855. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42856. */
  42857. constructor(touchEnabled?: boolean);
  42858. /**
  42859. * Attach the mouse control to the HTML DOM element.
  42860. * @param element Defines the element that listens to the input events.
  42861. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42862. */
  42863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42864. /**
  42865. * Detach the current controls from the specified dom element.
  42866. * @param element Defines the element to stop listening the inputs from
  42867. */
  42868. detachControl(element: Nullable<HTMLElement>): void;
  42869. /**
  42870. * Gets the class name of the current input.
  42871. * @returns the class name.
  42872. */
  42873. getClassName(): string;
  42874. /**
  42875. * Get the friendly name associated with the input class.
  42876. * @returns the input's friendly name.
  42877. */
  42878. getSimpleName(): string;
  42879. private _pointerInput;
  42880. private _onMouseMove;
  42881. /**
  42882. * Rotate camera by mouse offset.
  42883. */
  42884. private rotateCamera;
  42885. }
  42886. }
  42887. declare module BABYLON {
  42888. /**
  42889. * Default Inputs manager for the FlyCamera.
  42890. * It groups all the default supported inputs for ease of use.
  42891. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42892. */
  42893. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  42894. /**
  42895. * Instantiates a new FlyCameraInputsManager.
  42896. * @param camera Defines the camera the inputs belong to.
  42897. */
  42898. constructor(camera: FlyCamera);
  42899. /**
  42900. * Add keyboard input support to the input manager.
  42901. * @returns the new FlyCameraKeyboardMoveInput().
  42902. */
  42903. addKeyboard(): FlyCameraInputsManager;
  42904. /**
  42905. * Add mouse input support to the input manager.
  42906. * @param touchEnabled Enable touch screen support.
  42907. * @returns the new FlyCameraMouseInput().
  42908. */
  42909. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  42910. }
  42911. }
  42912. declare module BABYLON {
  42913. /**
  42914. * This is a flying camera, designed for 3D movement and rotation in all directions,
  42915. * such as in a 3D Space Shooter or a Flight Simulator.
  42916. */
  42917. export class FlyCamera extends TargetCamera {
  42918. /**
  42919. * Define the collision ellipsoid of the camera.
  42920. * This is helpful for simulating a camera body, like a player's body.
  42921. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42922. */
  42923. ellipsoid: Vector3;
  42924. /**
  42925. * Define an offset for the position of the ellipsoid around the camera.
  42926. * This can be helpful if the camera is attached away from the player's body center,
  42927. * such as at its head.
  42928. */
  42929. ellipsoidOffset: Vector3;
  42930. /**
  42931. * Enable or disable collisions of the camera with the rest of the scene objects.
  42932. */
  42933. checkCollisions: boolean;
  42934. /**
  42935. * Enable or disable gravity on the camera.
  42936. */
  42937. applyGravity: boolean;
  42938. /**
  42939. * Define the current direction the camera is moving to.
  42940. */
  42941. cameraDirection: Vector3;
  42942. /**
  42943. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  42944. * This overrides and empties cameraRotation.
  42945. */
  42946. rotationQuaternion: Quaternion;
  42947. /**
  42948. * Track Roll to maintain the wanted Rolling when looking around.
  42949. */
  42950. _trackRoll: number;
  42951. /**
  42952. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  42953. */
  42954. rollCorrect: number;
  42955. /**
  42956. * Mimic a banked turn, Rolling the camera when Yawing.
  42957. * It's recommended to use rollCorrect = 10 for faster banking correction.
  42958. */
  42959. bankedTurn: boolean;
  42960. /**
  42961. * Limit in radians for how much Roll banking will add. (Default: 90°)
  42962. */
  42963. bankedTurnLimit: number;
  42964. /**
  42965. * Value of 0 disables the banked Roll.
  42966. * Value of 1 is equal to the Yaw angle in radians.
  42967. */
  42968. bankedTurnMultiplier: number;
  42969. /**
  42970. * The inputs manager loads all the input sources, such as keyboard and mouse.
  42971. */
  42972. inputs: FlyCameraInputsManager;
  42973. /**
  42974. * Gets the input sensibility for mouse input.
  42975. * Higher values reduce sensitivity.
  42976. */
  42977. get angularSensibility(): number;
  42978. /**
  42979. * Sets the input sensibility for a mouse input.
  42980. * Higher values reduce sensitivity.
  42981. */
  42982. set angularSensibility(value: number);
  42983. /**
  42984. * Get the keys for camera movement forward.
  42985. */
  42986. get keysForward(): number[];
  42987. /**
  42988. * Set the keys for camera movement forward.
  42989. */
  42990. set keysForward(value: number[]);
  42991. /**
  42992. * Get the keys for camera movement backward.
  42993. */
  42994. get keysBackward(): number[];
  42995. set keysBackward(value: number[]);
  42996. /**
  42997. * Get the keys for camera movement up.
  42998. */
  42999. get keysUp(): number[];
  43000. /**
  43001. * Set the keys for camera movement up.
  43002. */
  43003. set keysUp(value: number[]);
  43004. /**
  43005. * Get the keys for camera movement down.
  43006. */
  43007. get keysDown(): number[];
  43008. /**
  43009. * Set the keys for camera movement down.
  43010. */
  43011. set keysDown(value: number[]);
  43012. /**
  43013. * Get the keys for camera movement left.
  43014. */
  43015. get keysLeft(): number[];
  43016. /**
  43017. * Set the keys for camera movement left.
  43018. */
  43019. set keysLeft(value: number[]);
  43020. /**
  43021. * Set the keys for camera movement right.
  43022. */
  43023. get keysRight(): number[];
  43024. /**
  43025. * Set the keys for camera movement right.
  43026. */
  43027. set keysRight(value: number[]);
  43028. /**
  43029. * Event raised when the camera collides with a mesh in the scene.
  43030. */
  43031. onCollide: (collidedMesh: AbstractMesh) => void;
  43032. private _collider;
  43033. private _needMoveForGravity;
  43034. private _oldPosition;
  43035. private _diffPosition;
  43036. private _newPosition;
  43037. /** @hidden */
  43038. _localDirection: Vector3;
  43039. /** @hidden */
  43040. _transformedDirection: Vector3;
  43041. /**
  43042. * Instantiates a FlyCamera.
  43043. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43044. * such as in a 3D Space Shooter or a Flight Simulator.
  43045. * @param name Define the name of the camera in the scene.
  43046. * @param position Define the starting position of the camera in the scene.
  43047. * @param scene Define the scene the camera belongs to.
  43048. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43049. */
  43050. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43051. /**
  43052. * Attach a control to the HTML DOM element.
  43053. * @param element Defines the element that listens to the input events.
  43054. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43055. */
  43056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43057. /**
  43058. * Detach a control from the HTML DOM element.
  43059. * The camera will stop reacting to that input.
  43060. * @param element Defines the element that listens to the input events.
  43061. */
  43062. detachControl(element: HTMLElement): void;
  43063. private _collisionMask;
  43064. /**
  43065. * Get the mask that the camera ignores in collision events.
  43066. */
  43067. get collisionMask(): number;
  43068. /**
  43069. * Set the mask that the camera ignores in collision events.
  43070. */
  43071. set collisionMask(mask: number);
  43072. /** @hidden */
  43073. _collideWithWorld(displacement: Vector3): void;
  43074. /** @hidden */
  43075. private _onCollisionPositionChange;
  43076. /** @hidden */
  43077. _checkInputs(): void;
  43078. /** @hidden */
  43079. _decideIfNeedsToMove(): boolean;
  43080. /** @hidden */
  43081. _updatePosition(): void;
  43082. /**
  43083. * Restore the Roll to its target value at the rate specified.
  43084. * @param rate - Higher means slower restoring.
  43085. * @hidden
  43086. */
  43087. restoreRoll(rate: number): void;
  43088. /**
  43089. * Destroy the camera and release the current resources held by it.
  43090. */
  43091. dispose(): void;
  43092. /**
  43093. * Get the current object class name.
  43094. * @returns the class name.
  43095. */
  43096. getClassName(): string;
  43097. }
  43098. }
  43099. declare module BABYLON {
  43100. /**
  43101. * Listen to keyboard events to control the camera.
  43102. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43103. */
  43104. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43105. /**
  43106. * Defines the camera the input is attached to.
  43107. */
  43108. camera: FlyCamera;
  43109. /**
  43110. * The list of keyboard keys used to control the forward move of the camera.
  43111. */
  43112. keysForward: number[];
  43113. /**
  43114. * The list of keyboard keys used to control the backward move of the camera.
  43115. */
  43116. keysBackward: number[];
  43117. /**
  43118. * The list of keyboard keys used to control the forward move of the camera.
  43119. */
  43120. keysUp: number[];
  43121. /**
  43122. * The list of keyboard keys used to control the backward move of the camera.
  43123. */
  43124. keysDown: number[];
  43125. /**
  43126. * The list of keyboard keys used to control the right strafe move of the camera.
  43127. */
  43128. keysRight: number[];
  43129. /**
  43130. * The list of keyboard keys used to control the left strafe move of the camera.
  43131. */
  43132. keysLeft: number[];
  43133. private _keys;
  43134. private _onCanvasBlurObserver;
  43135. private _onKeyboardObserver;
  43136. private _engine;
  43137. private _scene;
  43138. /**
  43139. * Attach the input controls to a specific dom element to get the input from.
  43140. * @param element Defines the element the controls should be listened from
  43141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43142. */
  43143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43144. /**
  43145. * Detach the current controls from the specified dom element.
  43146. * @param element Defines the element to stop listening the inputs from
  43147. */
  43148. detachControl(element: Nullable<HTMLElement>): void;
  43149. /**
  43150. * Gets the class name of the current intput.
  43151. * @returns the class name
  43152. */
  43153. getClassName(): string;
  43154. /** @hidden */
  43155. _onLostFocus(e: FocusEvent): void;
  43156. /**
  43157. * Get the friendly name associated with the input class.
  43158. * @returns the input friendly name
  43159. */
  43160. getSimpleName(): string;
  43161. /**
  43162. * Update the current camera state depending on the inputs that have been used this frame.
  43163. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43164. */
  43165. checkInputs(): void;
  43166. }
  43167. }
  43168. declare module BABYLON {
  43169. /**
  43170. * Manage the mouse wheel inputs to control a follow camera.
  43171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43172. */
  43173. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43174. /**
  43175. * Defines the camera the input is attached to.
  43176. */
  43177. camera: FollowCamera;
  43178. /**
  43179. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43180. */
  43181. axisControlRadius: boolean;
  43182. /**
  43183. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43184. */
  43185. axisControlHeight: boolean;
  43186. /**
  43187. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43188. */
  43189. axisControlRotation: boolean;
  43190. /**
  43191. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43192. * relation to mouseWheel events.
  43193. */
  43194. wheelPrecision: number;
  43195. /**
  43196. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43197. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43198. */
  43199. wheelDeltaPercentage: number;
  43200. private _wheel;
  43201. private _observer;
  43202. /**
  43203. * Attach the input controls to a specific dom element to get the input from.
  43204. * @param element Defines the element the controls should be listened from
  43205. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43206. */
  43207. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43208. /**
  43209. * Detach the current controls from the specified dom element.
  43210. * @param element Defines the element to stop listening the inputs from
  43211. */
  43212. detachControl(element: Nullable<HTMLElement>): void;
  43213. /**
  43214. * Gets the class name of the current intput.
  43215. * @returns the class name
  43216. */
  43217. getClassName(): string;
  43218. /**
  43219. * Get the friendly name associated with the input class.
  43220. * @returns the input friendly name
  43221. */
  43222. getSimpleName(): string;
  43223. }
  43224. }
  43225. declare module BABYLON {
  43226. /**
  43227. * Manage the pointers inputs to control an follow camera.
  43228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43229. */
  43230. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43231. /**
  43232. * Defines the camera the input is attached to.
  43233. */
  43234. camera: FollowCamera;
  43235. /**
  43236. * Gets the class name of the current input.
  43237. * @returns the class name
  43238. */
  43239. getClassName(): string;
  43240. /**
  43241. * Defines the pointer angular sensibility along the X axis or how fast is
  43242. * the camera rotating.
  43243. * A negative number will reverse the axis direction.
  43244. */
  43245. angularSensibilityX: number;
  43246. /**
  43247. * Defines the pointer angular sensibility along the Y axis or how fast is
  43248. * the camera rotating.
  43249. * A negative number will reverse the axis direction.
  43250. */
  43251. angularSensibilityY: number;
  43252. /**
  43253. * Defines the pointer pinch precision or how fast is the camera zooming.
  43254. * A negative number will reverse the axis direction.
  43255. */
  43256. pinchPrecision: number;
  43257. /**
  43258. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43259. * from 0.
  43260. * It defines the percentage of current camera.radius to use as delta when
  43261. * pinch zoom is used.
  43262. */
  43263. pinchDeltaPercentage: number;
  43264. /**
  43265. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43266. */
  43267. axisXControlRadius: boolean;
  43268. /**
  43269. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43270. */
  43271. axisXControlHeight: boolean;
  43272. /**
  43273. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43274. */
  43275. axisXControlRotation: boolean;
  43276. /**
  43277. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43278. */
  43279. axisYControlRadius: boolean;
  43280. /**
  43281. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43282. */
  43283. axisYControlHeight: boolean;
  43284. /**
  43285. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43286. */
  43287. axisYControlRotation: boolean;
  43288. /**
  43289. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43290. */
  43291. axisPinchControlRadius: boolean;
  43292. /**
  43293. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43294. */
  43295. axisPinchControlHeight: boolean;
  43296. /**
  43297. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43298. */
  43299. axisPinchControlRotation: boolean;
  43300. /**
  43301. * Log error messages if basic misconfiguration has occurred.
  43302. */
  43303. warningEnable: boolean;
  43304. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43305. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43306. private _warningCounter;
  43307. private _warning;
  43308. }
  43309. }
  43310. declare module BABYLON {
  43311. /**
  43312. * Default Inputs manager for the FollowCamera.
  43313. * It groups all the default supported inputs for ease of use.
  43314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43315. */
  43316. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43317. /**
  43318. * Instantiates a new FollowCameraInputsManager.
  43319. * @param camera Defines the camera the inputs belong to
  43320. */
  43321. constructor(camera: FollowCamera);
  43322. /**
  43323. * Add keyboard input support to the input manager.
  43324. * @returns the current input manager
  43325. */
  43326. addKeyboard(): FollowCameraInputsManager;
  43327. /**
  43328. * Add mouse wheel input support to the input manager.
  43329. * @returns the current input manager
  43330. */
  43331. addMouseWheel(): FollowCameraInputsManager;
  43332. /**
  43333. * Add pointers input support to the input manager.
  43334. * @returns the current input manager
  43335. */
  43336. addPointers(): FollowCameraInputsManager;
  43337. /**
  43338. * Add orientation input support to the input manager.
  43339. * @returns the current input manager
  43340. */
  43341. addVRDeviceOrientation(): FollowCameraInputsManager;
  43342. }
  43343. }
  43344. declare module BABYLON {
  43345. /**
  43346. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43347. * an arc rotate version arcFollowCamera are available.
  43348. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43349. */
  43350. export class FollowCamera extends TargetCamera {
  43351. /**
  43352. * Distance the follow camera should follow an object at
  43353. */
  43354. radius: number;
  43355. /**
  43356. * Minimum allowed distance of the camera to the axis of rotation
  43357. * (The camera can not get closer).
  43358. * This can help limiting how the Camera is able to move in the scene.
  43359. */
  43360. lowerRadiusLimit: Nullable<number>;
  43361. /**
  43362. * Maximum allowed distance of the camera to the axis of rotation
  43363. * (The camera can not get further).
  43364. * This can help limiting how the Camera is able to move in the scene.
  43365. */
  43366. upperRadiusLimit: Nullable<number>;
  43367. /**
  43368. * Define a rotation offset between the camera and the object it follows
  43369. */
  43370. rotationOffset: number;
  43371. /**
  43372. * Minimum allowed angle to camera position relative to target object.
  43373. * This can help limiting how the Camera is able to move in the scene.
  43374. */
  43375. lowerRotationOffsetLimit: Nullable<number>;
  43376. /**
  43377. * Maximum allowed angle to camera position relative to target object.
  43378. * This can help limiting how the Camera is able to move in the scene.
  43379. */
  43380. upperRotationOffsetLimit: Nullable<number>;
  43381. /**
  43382. * Define a height offset between the camera and the object it follows.
  43383. * It can help following an object from the top (like a car chaing a plane)
  43384. */
  43385. heightOffset: number;
  43386. /**
  43387. * Minimum allowed height of camera position relative to target object.
  43388. * This can help limiting how the Camera is able to move in the scene.
  43389. */
  43390. lowerHeightOffsetLimit: Nullable<number>;
  43391. /**
  43392. * Maximum allowed height of camera position relative to target object.
  43393. * This can help limiting how the Camera is able to move in the scene.
  43394. */
  43395. upperHeightOffsetLimit: Nullable<number>;
  43396. /**
  43397. * Define how fast the camera can accelerate to follow it s target.
  43398. */
  43399. cameraAcceleration: number;
  43400. /**
  43401. * Define the speed limit of the camera following an object.
  43402. */
  43403. maxCameraSpeed: number;
  43404. /**
  43405. * Define the target of the camera.
  43406. */
  43407. lockedTarget: Nullable<AbstractMesh>;
  43408. /**
  43409. * Defines the input associated with the camera.
  43410. */
  43411. inputs: FollowCameraInputsManager;
  43412. /**
  43413. * Instantiates the follow camera.
  43414. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43415. * @param name Define the name of the camera in the scene
  43416. * @param position Define the position of the camera
  43417. * @param scene Define the scene the camera belong to
  43418. * @param lockedTarget Define the target of the camera
  43419. */
  43420. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43421. private _follow;
  43422. /**
  43423. * Attached controls to the current camera.
  43424. * @param element Defines the element the controls should be listened from
  43425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43426. */
  43427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43428. /**
  43429. * Detach the current controls from the camera.
  43430. * The camera will stop reacting to inputs.
  43431. * @param element Defines the element to stop listening the inputs from
  43432. */
  43433. detachControl(element: HTMLElement): void;
  43434. /** @hidden */
  43435. _checkInputs(): void;
  43436. private _checkLimits;
  43437. /**
  43438. * Gets the camera class name.
  43439. * @returns the class name
  43440. */
  43441. getClassName(): string;
  43442. }
  43443. /**
  43444. * Arc Rotate version of the follow camera.
  43445. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43446. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43447. */
  43448. export class ArcFollowCamera extends TargetCamera {
  43449. /** The longitudinal angle of the camera */
  43450. alpha: number;
  43451. /** The latitudinal angle of the camera */
  43452. beta: number;
  43453. /** The radius of the camera from its target */
  43454. radius: number;
  43455. /** Define the camera target (the messh it should follow) */
  43456. target: Nullable<AbstractMesh>;
  43457. private _cartesianCoordinates;
  43458. /**
  43459. * Instantiates a new ArcFollowCamera
  43460. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43461. * @param name Define the name of the camera
  43462. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43463. * @param beta Define the rotation angle of the camera around the elevation axis
  43464. * @param radius Define the radius of the camera from its target point
  43465. * @param target Define the target of the camera
  43466. * @param scene Define the scene the camera belongs to
  43467. */
  43468. constructor(name: string,
  43469. /** The longitudinal angle of the camera */
  43470. alpha: number,
  43471. /** The latitudinal angle of the camera */
  43472. beta: number,
  43473. /** The radius of the camera from its target */
  43474. radius: number,
  43475. /** Define the camera target (the messh it should follow) */
  43476. target: Nullable<AbstractMesh>, scene: Scene);
  43477. private _follow;
  43478. /** @hidden */
  43479. _checkInputs(): void;
  43480. /**
  43481. * Returns the class name of the object.
  43482. * It is mostly used internally for serialization purposes.
  43483. */
  43484. getClassName(): string;
  43485. }
  43486. }
  43487. declare module BABYLON {
  43488. /**
  43489. * Manage the keyboard inputs to control the movement of a follow camera.
  43490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43491. */
  43492. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43493. /**
  43494. * Defines the camera the input is attached to.
  43495. */
  43496. camera: FollowCamera;
  43497. /**
  43498. * Defines the list of key codes associated with the up action (increase heightOffset)
  43499. */
  43500. keysHeightOffsetIncr: number[];
  43501. /**
  43502. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43503. */
  43504. keysHeightOffsetDecr: number[];
  43505. /**
  43506. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43507. */
  43508. keysHeightOffsetModifierAlt: boolean;
  43509. /**
  43510. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43511. */
  43512. keysHeightOffsetModifierCtrl: boolean;
  43513. /**
  43514. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43515. */
  43516. keysHeightOffsetModifierShift: boolean;
  43517. /**
  43518. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43519. */
  43520. keysRotationOffsetIncr: number[];
  43521. /**
  43522. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43523. */
  43524. keysRotationOffsetDecr: number[];
  43525. /**
  43526. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43527. */
  43528. keysRotationOffsetModifierAlt: boolean;
  43529. /**
  43530. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43531. */
  43532. keysRotationOffsetModifierCtrl: boolean;
  43533. /**
  43534. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43535. */
  43536. keysRotationOffsetModifierShift: boolean;
  43537. /**
  43538. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43539. */
  43540. keysRadiusIncr: number[];
  43541. /**
  43542. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43543. */
  43544. keysRadiusDecr: number[];
  43545. /**
  43546. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43547. */
  43548. keysRadiusModifierAlt: boolean;
  43549. /**
  43550. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43551. */
  43552. keysRadiusModifierCtrl: boolean;
  43553. /**
  43554. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43555. */
  43556. keysRadiusModifierShift: boolean;
  43557. /**
  43558. * Defines the rate of change of heightOffset.
  43559. */
  43560. heightSensibility: number;
  43561. /**
  43562. * Defines the rate of change of rotationOffset.
  43563. */
  43564. rotationSensibility: number;
  43565. /**
  43566. * Defines the rate of change of radius.
  43567. */
  43568. radiusSensibility: number;
  43569. private _keys;
  43570. private _ctrlPressed;
  43571. private _altPressed;
  43572. private _shiftPressed;
  43573. private _onCanvasBlurObserver;
  43574. private _onKeyboardObserver;
  43575. private _engine;
  43576. private _scene;
  43577. /**
  43578. * Attach the input controls to a specific dom element to get the input from.
  43579. * @param element Defines the element the controls should be listened from
  43580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43581. */
  43582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43583. /**
  43584. * Detach the current controls from the specified dom element.
  43585. * @param element Defines the element to stop listening the inputs from
  43586. */
  43587. detachControl(element: Nullable<HTMLElement>): void;
  43588. /**
  43589. * Update the current camera state depending on the inputs that have been used this frame.
  43590. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43591. */
  43592. checkInputs(): void;
  43593. /**
  43594. * Gets the class name of the current input.
  43595. * @returns the class name
  43596. */
  43597. getClassName(): string;
  43598. /**
  43599. * Get the friendly name associated with the input class.
  43600. * @returns the input friendly name
  43601. */
  43602. getSimpleName(): string;
  43603. /**
  43604. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43605. * allow modification of the heightOffset value.
  43606. */
  43607. private _modifierHeightOffset;
  43608. /**
  43609. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43610. * allow modification of the rotationOffset value.
  43611. */
  43612. private _modifierRotationOffset;
  43613. /**
  43614. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43615. * allow modification of the radius value.
  43616. */
  43617. private _modifierRadius;
  43618. }
  43619. }
  43620. declare module BABYLON {
  43621. interface FreeCameraInputsManager {
  43622. /**
  43623. * @hidden
  43624. */
  43625. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43626. /**
  43627. * Add orientation input support to the input manager.
  43628. * @returns the current input manager
  43629. */
  43630. addDeviceOrientation(): FreeCameraInputsManager;
  43631. }
  43632. /**
  43633. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43634. * Screen rotation is taken into account.
  43635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43636. */
  43637. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43638. private _camera;
  43639. private _screenOrientationAngle;
  43640. private _constantTranform;
  43641. private _screenQuaternion;
  43642. private _alpha;
  43643. private _beta;
  43644. private _gamma;
  43645. /**
  43646. * Can be used to detect if a device orientation sensor is available on a device
  43647. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43648. * @returns a promise that will resolve on orientation change
  43649. */
  43650. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43651. /**
  43652. * @hidden
  43653. */
  43654. _onDeviceOrientationChangedObservable: Observable<void>;
  43655. /**
  43656. * Instantiates a new input
  43657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43658. */
  43659. constructor();
  43660. /**
  43661. * Define the camera controlled by the input.
  43662. */
  43663. get camera(): FreeCamera;
  43664. set camera(camera: FreeCamera);
  43665. /**
  43666. * Attach the input controls to a specific dom element to get the input from.
  43667. * @param element Defines the element the controls should be listened from
  43668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43669. */
  43670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43671. private _orientationChanged;
  43672. private _deviceOrientation;
  43673. /**
  43674. * Detach the current controls from the specified dom element.
  43675. * @param element Defines the element to stop listening the inputs from
  43676. */
  43677. detachControl(element: Nullable<HTMLElement>): void;
  43678. /**
  43679. * Update the current camera state depending on the inputs that have been used this frame.
  43680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43681. */
  43682. checkInputs(): void;
  43683. /**
  43684. * Gets the class name of the current intput.
  43685. * @returns the class name
  43686. */
  43687. getClassName(): string;
  43688. /**
  43689. * Get the friendly name associated with the input class.
  43690. * @returns the input friendly name
  43691. */
  43692. getSimpleName(): string;
  43693. }
  43694. }
  43695. declare module BABYLON {
  43696. /**
  43697. * Manage the gamepad inputs to control a free camera.
  43698. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43699. */
  43700. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43701. /**
  43702. * Define the camera the input is attached to.
  43703. */
  43704. camera: FreeCamera;
  43705. /**
  43706. * Define the Gamepad controlling the input
  43707. */
  43708. gamepad: Nullable<Gamepad>;
  43709. /**
  43710. * Defines the gamepad rotation sensiblity.
  43711. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43712. */
  43713. gamepadAngularSensibility: number;
  43714. /**
  43715. * Defines the gamepad move sensiblity.
  43716. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43717. */
  43718. gamepadMoveSensibility: number;
  43719. private _yAxisScale;
  43720. /**
  43721. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43722. */
  43723. get invertYAxis(): boolean;
  43724. set invertYAxis(value: boolean);
  43725. private _onGamepadConnectedObserver;
  43726. private _onGamepadDisconnectedObserver;
  43727. private _cameraTransform;
  43728. private _deltaTransform;
  43729. private _vector3;
  43730. private _vector2;
  43731. /**
  43732. * Attach the input controls to a specific dom element to get the input from.
  43733. * @param element Defines the element the controls should be listened from
  43734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43735. */
  43736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43737. /**
  43738. * Detach the current controls from the specified dom element.
  43739. * @param element Defines the element to stop listening the inputs from
  43740. */
  43741. detachControl(element: Nullable<HTMLElement>): void;
  43742. /**
  43743. * Update the current camera state depending on the inputs that have been used this frame.
  43744. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43745. */
  43746. checkInputs(): void;
  43747. /**
  43748. * Gets the class name of the current intput.
  43749. * @returns the class name
  43750. */
  43751. getClassName(): string;
  43752. /**
  43753. * Get the friendly name associated with the input class.
  43754. * @returns the input friendly name
  43755. */
  43756. getSimpleName(): string;
  43757. }
  43758. }
  43759. declare module BABYLON {
  43760. /**
  43761. * Defines the potential axis of a Joystick
  43762. */
  43763. export enum JoystickAxis {
  43764. /** X axis */
  43765. X = 0,
  43766. /** Y axis */
  43767. Y = 1,
  43768. /** Z axis */
  43769. Z = 2
  43770. }
  43771. /**
  43772. * Class used to define virtual joystick (used in touch mode)
  43773. */
  43774. export class VirtualJoystick {
  43775. /**
  43776. * Gets or sets a boolean indicating that left and right values must be inverted
  43777. */
  43778. reverseLeftRight: boolean;
  43779. /**
  43780. * Gets or sets a boolean indicating that up and down values must be inverted
  43781. */
  43782. reverseUpDown: boolean;
  43783. /**
  43784. * Gets the offset value for the position (ie. the change of the position value)
  43785. */
  43786. deltaPosition: Vector3;
  43787. /**
  43788. * Gets a boolean indicating if the virtual joystick was pressed
  43789. */
  43790. pressed: boolean;
  43791. /**
  43792. * Canvas the virtual joystick will render onto, default z-index of this is 5
  43793. */
  43794. static Canvas: Nullable<HTMLCanvasElement>;
  43795. private static _globalJoystickIndex;
  43796. private static vjCanvasContext;
  43797. private static vjCanvasWidth;
  43798. private static vjCanvasHeight;
  43799. private static halfWidth;
  43800. private _action;
  43801. private _axisTargetedByLeftAndRight;
  43802. private _axisTargetedByUpAndDown;
  43803. private _joystickSensibility;
  43804. private _inversedSensibility;
  43805. private _joystickPointerID;
  43806. private _joystickColor;
  43807. private _joystickPointerPos;
  43808. private _joystickPreviousPointerPos;
  43809. private _joystickPointerStartPos;
  43810. private _deltaJoystickVector;
  43811. private _leftJoystick;
  43812. private _touches;
  43813. private _onPointerDownHandlerRef;
  43814. private _onPointerMoveHandlerRef;
  43815. private _onPointerUpHandlerRef;
  43816. private _onResize;
  43817. /**
  43818. * Creates a new virtual joystick
  43819. * @param leftJoystick defines that the joystick is for left hand (false by default)
  43820. */
  43821. constructor(leftJoystick?: boolean);
  43822. /**
  43823. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  43824. * @param newJoystickSensibility defines the new sensibility
  43825. */
  43826. setJoystickSensibility(newJoystickSensibility: number): void;
  43827. private _onPointerDown;
  43828. private _onPointerMove;
  43829. private _onPointerUp;
  43830. /**
  43831. * Change the color of the virtual joystick
  43832. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  43833. */
  43834. setJoystickColor(newColor: string): void;
  43835. /**
  43836. * Defines a callback to call when the joystick is touched
  43837. * @param action defines the callback
  43838. */
  43839. setActionOnTouch(action: () => any): void;
  43840. /**
  43841. * Defines which axis you'd like to control for left & right
  43842. * @param axis defines the axis to use
  43843. */
  43844. setAxisForLeftRight(axis: JoystickAxis): void;
  43845. /**
  43846. * Defines which axis you'd like to control for up & down
  43847. * @param axis defines the axis to use
  43848. */
  43849. setAxisForUpDown(axis: JoystickAxis): void;
  43850. private _drawVirtualJoystick;
  43851. /**
  43852. * Release internal HTML canvas
  43853. */
  43854. releaseCanvas(): void;
  43855. }
  43856. }
  43857. declare module BABYLON {
  43858. interface FreeCameraInputsManager {
  43859. /**
  43860. * Add virtual joystick input support to the input manager.
  43861. * @returns the current input manager
  43862. */
  43863. addVirtualJoystick(): FreeCameraInputsManager;
  43864. }
  43865. /**
  43866. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  43867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43868. */
  43869. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  43870. /**
  43871. * Defines the camera the input is attached to.
  43872. */
  43873. camera: FreeCamera;
  43874. private _leftjoystick;
  43875. private _rightjoystick;
  43876. /**
  43877. * Gets the left stick of the virtual joystick.
  43878. * @returns The virtual Joystick
  43879. */
  43880. getLeftJoystick(): VirtualJoystick;
  43881. /**
  43882. * Gets the right stick of the virtual joystick.
  43883. * @returns The virtual Joystick
  43884. */
  43885. getRightJoystick(): VirtualJoystick;
  43886. /**
  43887. * Update the current camera state depending on the inputs that have been used this frame.
  43888. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43889. */
  43890. checkInputs(): void;
  43891. /**
  43892. * Attach the input controls to a specific dom element to get the input from.
  43893. * @param element Defines the element the controls should be listened from
  43894. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43895. */
  43896. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43897. /**
  43898. * Detach the current controls from the specified dom element.
  43899. * @param element Defines the element to stop listening the inputs from
  43900. */
  43901. detachControl(element: Nullable<HTMLElement>): void;
  43902. /**
  43903. * Gets the class name of the current intput.
  43904. * @returns the class name
  43905. */
  43906. getClassName(): string;
  43907. /**
  43908. * Get the friendly name associated with the input class.
  43909. * @returns the input friendly name
  43910. */
  43911. getSimpleName(): string;
  43912. }
  43913. }
  43914. declare module BABYLON {
  43915. /**
  43916. * This represents a FPS type of camera controlled by touch.
  43917. * This is like a universal camera minus the Gamepad controls.
  43918. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43919. */
  43920. export class TouchCamera extends FreeCamera {
  43921. /**
  43922. * Defines the touch sensibility for rotation.
  43923. * The higher the faster.
  43924. */
  43925. get touchAngularSensibility(): number;
  43926. set touchAngularSensibility(value: number);
  43927. /**
  43928. * Defines the touch sensibility for move.
  43929. * The higher the faster.
  43930. */
  43931. get touchMoveSensibility(): number;
  43932. set touchMoveSensibility(value: number);
  43933. /**
  43934. * Instantiates a new touch camera.
  43935. * This represents a FPS type of camera controlled by touch.
  43936. * This is like a universal camera minus the Gamepad controls.
  43937. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43938. * @param name Define the name of the camera in the scene
  43939. * @param position Define the start position of the camera in the scene
  43940. * @param scene Define the scene the camera belongs to
  43941. */
  43942. constructor(name: string, position: Vector3, scene: Scene);
  43943. /**
  43944. * Gets the current object class name.
  43945. * @return the class name
  43946. */
  43947. getClassName(): string;
  43948. /** @hidden */
  43949. _setupInputs(): void;
  43950. }
  43951. }
  43952. declare module BABYLON {
  43953. /**
  43954. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  43955. * being tilted forward or back and left or right.
  43956. */
  43957. export class DeviceOrientationCamera extends FreeCamera {
  43958. private _initialQuaternion;
  43959. private _quaternionCache;
  43960. private _tmpDragQuaternion;
  43961. private _disablePointerInputWhenUsingDeviceOrientation;
  43962. /**
  43963. * Creates a new device orientation camera
  43964. * @param name The name of the camera
  43965. * @param position The start position camera
  43966. * @param scene The scene the camera belongs to
  43967. */
  43968. constructor(name: string, position: Vector3, scene: Scene);
  43969. /**
  43970. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  43971. */
  43972. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  43973. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  43974. private _dragFactor;
  43975. /**
  43976. * Enabled turning on the y axis when the orientation sensor is active
  43977. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  43978. */
  43979. enableHorizontalDragging(dragFactor?: number): void;
  43980. /**
  43981. * Gets the current instance class name ("DeviceOrientationCamera").
  43982. * This helps avoiding instanceof at run time.
  43983. * @returns the class name
  43984. */
  43985. getClassName(): string;
  43986. /**
  43987. * @hidden
  43988. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  43989. */
  43990. _checkInputs(): void;
  43991. /**
  43992. * Reset the camera to its default orientation on the specified axis only.
  43993. * @param axis The axis to reset
  43994. */
  43995. resetToCurrentRotation(axis?: Axis): void;
  43996. }
  43997. }
  43998. declare module BABYLON {
  43999. /**
  44000. * Defines supported buttons for XBox360 compatible gamepads
  44001. */
  44002. export enum Xbox360Button {
  44003. /** A */
  44004. A = 0,
  44005. /** B */
  44006. B = 1,
  44007. /** X */
  44008. X = 2,
  44009. /** Y */
  44010. Y = 3,
  44011. /** Left button */
  44012. LB = 4,
  44013. /** Right button */
  44014. RB = 5,
  44015. /** Back */
  44016. Back = 8,
  44017. /** Start */
  44018. Start = 9,
  44019. /** Left stick */
  44020. LeftStick = 10,
  44021. /** Right stick */
  44022. RightStick = 11
  44023. }
  44024. /** Defines values for XBox360 DPad */
  44025. export enum Xbox360Dpad {
  44026. /** Up */
  44027. Up = 12,
  44028. /** Down */
  44029. Down = 13,
  44030. /** Left */
  44031. Left = 14,
  44032. /** Right */
  44033. Right = 15
  44034. }
  44035. /**
  44036. * Defines a XBox360 gamepad
  44037. */
  44038. export class Xbox360Pad extends Gamepad {
  44039. private _leftTrigger;
  44040. private _rightTrigger;
  44041. private _onlefttriggerchanged;
  44042. private _onrighttriggerchanged;
  44043. private _onbuttondown;
  44044. private _onbuttonup;
  44045. private _ondpaddown;
  44046. private _ondpadup;
  44047. /** Observable raised when a button is pressed */
  44048. onButtonDownObservable: Observable<Xbox360Button>;
  44049. /** Observable raised when a button is released */
  44050. onButtonUpObservable: Observable<Xbox360Button>;
  44051. /** Observable raised when a pad is pressed */
  44052. onPadDownObservable: Observable<Xbox360Dpad>;
  44053. /** Observable raised when a pad is released */
  44054. onPadUpObservable: Observable<Xbox360Dpad>;
  44055. private _buttonA;
  44056. private _buttonB;
  44057. private _buttonX;
  44058. private _buttonY;
  44059. private _buttonBack;
  44060. private _buttonStart;
  44061. private _buttonLB;
  44062. private _buttonRB;
  44063. private _buttonLeftStick;
  44064. private _buttonRightStick;
  44065. private _dPadUp;
  44066. private _dPadDown;
  44067. private _dPadLeft;
  44068. private _dPadRight;
  44069. private _isXboxOnePad;
  44070. /**
  44071. * Creates a new XBox360 gamepad object
  44072. * @param id defines the id of this gamepad
  44073. * @param index defines its index
  44074. * @param gamepad defines the internal HTML gamepad object
  44075. * @param xboxOne defines if it is a XBox One gamepad
  44076. */
  44077. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44078. /**
  44079. * Defines the callback to call when left trigger is pressed
  44080. * @param callback defines the callback to use
  44081. */
  44082. onlefttriggerchanged(callback: (value: number) => void): void;
  44083. /**
  44084. * Defines the callback to call when right trigger is pressed
  44085. * @param callback defines the callback to use
  44086. */
  44087. onrighttriggerchanged(callback: (value: number) => void): void;
  44088. /**
  44089. * Gets the left trigger value
  44090. */
  44091. get leftTrigger(): number;
  44092. /**
  44093. * Sets the left trigger value
  44094. */
  44095. set leftTrigger(newValue: number);
  44096. /**
  44097. * Gets the right trigger value
  44098. */
  44099. get rightTrigger(): number;
  44100. /**
  44101. * Sets the right trigger value
  44102. */
  44103. set rightTrigger(newValue: number);
  44104. /**
  44105. * Defines the callback to call when a button is pressed
  44106. * @param callback defines the callback to use
  44107. */
  44108. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44109. /**
  44110. * Defines the callback to call when a button is released
  44111. * @param callback defines the callback to use
  44112. */
  44113. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44114. /**
  44115. * Defines the callback to call when a pad is pressed
  44116. * @param callback defines the callback to use
  44117. */
  44118. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44119. /**
  44120. * Defines the callback to call when a pad is released
  44121. * @param callback defines the callback to use
  44122. */
  44123. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44124. private _setButtonValue;
  44125. private _setDPadValue;
  44126. /**
  44127. * Gets the value of the `A` button
  44128. */
  44129. get buttonA(): number;
  44130. /**
  44131. * Sets the value of the `A` button
  44132. */
  44133. set buttonA(value: number);
  44134. /**
  44135. * Gets the value of the `B` button
  44136. */
  44137. get buttonB(): number;
  44138. /**
  44139. * Sets the value of the `B` button
  44140. */
  44141. set buttonB(value: number);
  44142. /**
  44143. * Gets the value of the `X` button
  44144. */
  44145. get buttonX(): number;
  44146. /**
  44147. * Sets the value of the `X` button
  44148. */
  44149. set buttonX(value: number);
  44150. /**
  44151. * Gets the value of the `Y` button
  44152. */
  44153. get buttonY(): number;
  44154. /**
  44155. * Sets the value of the `Y` button
  44156. */
  44157. set buttonY(value: number);
  44158. /**
  44159. * Gets the value of the `Start` button
  44160. */
  44161. get buttonStart(): number;
  44162. /**
  44163. * Sets the value of the `Start` button
  44164. */
  44165. set buttonStart(value: number);
  44166. /**
  44167. * Gets the value of the `Back` button
  44168. */
  44169. get buttonBack(): number;
  44170. /**
  44171. * Sets the value of the `Back` button
  44172. */
  44173. set buttonBack(value: number);
  44174. /**
  44175. * Gets the value of the `Left` button
  44176. */
  44177. get buttonLB(): number;
  44178. /**
  44179. * Sets the value of the `Left` button
  44180. */
  44181. set buttonLB(value: number);
  44182. /**
  44183. * Gets the value of the `Right` button
  44184. */
  44185. get buttonRB(): number;
  44186. /**
  44187. * Sets the value of the `Right` button
  44188. */
  44189. set buttonRB(value: number);
  44190. /**
  44191. * Gets the value of the Left joystick
  44192. */
  44193. get buttonLeftStick(): number;
  44194. /**
  44195. * Sets the value of the Left joystick
  44196. */
  44197. set buttonLeftStick(value: number);
  44198. /**
  44199. * Gets the value of the Right joystick
  44200. */
  44201. get buttonRightStick(): number;
  44202. /**
  44203. * Sets the value of the Right joystick
  44204. */
  44205. set buttonRightStick(value: number);
  44206. /**
  44207. * Gets the value of D-pad up
  44208. */
  44209. get dPadUp(): number;
  44210. /**
  44211. * Sets the value of D-pad up
  44212. */
  44213. set dPadUp(value: number);
  44214. /**
  44215. * Gets the value of D-pad down
  44216. */
  44217. get dPadDown(): number;
  44218. /**
  44219. * Sets the value of D-pad down
  44220. */
  44221. set dPadDown(value: number);
  44222. /**
  44223. * Gets the value of D-pad left
  44224. */
  44225. get dPadLeft(): number;
  44226. /**
  44227. * Sets the value of D-pad left
  44228. */
  44229. set dPadLeft(value: number);
  44230. /**
  44231. * Gets the value of D-pad right
  44232. */
  44233. get dPadRight(): number;
  44234. /**
  44235. * Sets the value of D-pad right
  44236. */
  44237. set dPadRight(value: number);
  44238. /**
  44239. * Force the gamepad to synchronize with device values
  44240. */
  44241. update(): void;
  44242. /**
  44243. * Disposes the gamepad
  44244. */
  44245. dispose(): void;
  44246. }
  44247. }
  44248. declare module BABYLON {
  44249. /**
  44250. * Defines supported buttons for DualShock compatible gamepads
  44251. */
  44252. export enum DualShockButton {
  44253. /** Cross */
  44254. Cross = 0,
  44255. /** Circle */
  44256. Circle = 1,
  44257. /** Square */
  44258. Square = 2,
  44259. /** Triangle */
  44260. Triangle = 3,
  44261. /** L1 */
  44262. L1 = 4,
  44263. /** R1 */
  44264. R1 = 5,
  44265. /** Share */
  44266. Share = 8,
  44267. /** Options */
  44268. Options = 9,
  44269. /** Left stick */
  44270. LeftStick = 10,
  44271. /** Right stick */
  44272. RightStick = 11
  44273. }
  44274. /** Defines values for DualShock DPad */
  44275. export enum DualShockDpad {
  44276. /** Up */
  44277. Up = 12,
  44278. /** Down */
  44279. Down = 13,
  44280. /** Left */
  44281. Left = 14,
  44282. /** Right */
  44283. Right = 15
  44284. }
  44285. /**
  44286. * Defines a DualShock gamepad
  44287. */
  44288. export class DualShockPad extends Gamepad {
  44289. private _leftTrigger;
  44290. private _rightTrigger;
  44291. private _onlefttriggerchanged;
  44292. private _onrighttriggerchanged;
  44293. private _onbuttondown;
  44294. private _onbuttonup;
  44295. private _ondpaddown;
  44296. private _ondpadup;
  44297. /** Observable raised when a button is pressed */
  44298. onButtonDownObservable: Observable<DualShockButton>;
  44299. /** Observable raised when a button is released */
  44300. onButtonUpObservable: Observable<DualShockButton>;
  44301. /** Observable raised when a pad is pressed */
  44302. onPadDownObservable: Observable<DualShockDpad>;
  44303. /** Observable raised when a pad is released */
  44304. onPadUpObservable: Observable<DualShockDpad>;
  44305. private _buttonCross;
  44306. private _buttonCircle;
  44307. private _buttonSquare;
  44308. private _buttonTriangle;
  44309. private _buttonShare;
  44310. private _buttonOptions;
  44311. private _buttonL1;
  44312. private _buttonR1;
  44313. private _buttonLeftStick;
  44314. private _buttonRightStick;
  44315. private _dPadUp;
  44316. private _dPadDown;
  44317. private _dPadLeft;
  44318. private _dPadRight;
  44319. /**
  44320. * Creates a new DualShock gamepad object
  44321. * @param id defines the id of this gamepad
  44322. * @param index defines its index
  44323. * @param gamepad defines the internal HTML gamepad object
  44324. */
  44325. constructor(id: string, index: number, gamepad: any);
  44326. /**
  44327. * Defines the callback to call when left trigger is pressed
  44328. * @param callback defines the callback to use
  44329. */
  44330. onlefttriggerchanged(callback: (value: number) => void): void;
  44331. /**
  44332. * Defines the callback to call when right trigger is pressed
  44333. * @param callback defines the callback to use
  44334. */
  44335. onrighttriggerchanged(callback: (value: number) => void): void;
  44336. /**
  44337. * Gets the left trigger value
  44338. */
  44339. get leftTrigger(): number;
  44340. /**
  44341. * Sets the left trigger value
  44342. */
  44343. set leftTrigger(newValue: number);
  44344. /**
  44345. * Gets the right trigger value
  44346. */
  44347. get rightTrigger(): number;
  44348. /**
  44349. * Sets the right trigger value
  44350. */
  44351. set rightTrigger(newValue: number);
  44352. /**
  44353. * Defines the callback to call when a button is pressed
  44354. * @param callback defines the callback to use
  44355. */
  44356. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44357. /**
  44358. * Defines the callback to call when a button is released
  44359. * @param callback defines the callback to use
  44360. */
  44361. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44362. /**
  44363. * Defines the callback to call when a pad is pressed
  44364. * @param callback defines the callback to use
  44365. */
  44366. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44367. /**
  44368. * Defines the callback to call when a pad is released
  44369. * @param callback defines the callback to use
  44370. */
  44371. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44372. private _setButtonValue;
  44373. private _setDPadValue;
  44374. /**
  44375. * Gets the value of the `Cross` button
  44376. */
  44377. get buttonCross(): number;
  44378. /**
  44379. * Sets the value of the `Cross` button
  44380. */
  44381. set buttonCross(value: number);
  44382. /**
  44383. * Gets the value of the `Circle` button
  44384. */
  44385. get buttonCircle(): number;
  44386. /**
  44387. * Sets the value of the `Circle` button
  44388. */
  44389. set buttonCircle(value: number);
  44390. /**
  44391. * Gets the value of the `Square` button
  44392. */
  44393. get buttonSquare(): number;
  44394. /**
  44395. * Sets the value of the `Square` button
  44396. */
  44397. set buttonSquare(value: number);
  44398. /**
  44399. * Gets the value of the `Triangle` button
  44400. */
  44401. get buttonTriangle(): number;
  44402. /**
  44403. * Sets the value of the `Triangle` button
  44404. */
  44405. set buttonTriangle(value: number);
  44406. /**
  44407. * Gets the value of the `Options` button
  44408. */
  44409. get buttonOptions(): number;
  44410. /**
  44411. * Sets the value of the `Options` button
  44412. */
  44413. set buttonOptions(value: number);
  44414. /**
  44415. * Gets the value of the `Share` button
  44416. */
  44417. get buttonShare(): number;
  44418. /**
  44419. * Sets the value of the `Share` button
  44420. */
  44421. set buttonShare(value: number);
  44422. /**
  44423. * Gets the value of the `L1` button
  44424. */
  44425. get buttonL1(): number;
  44426. /**
  44427. * Sets the value of the `L1` button
  44428. */
  44429. set buttonL1(value: number);
  44430. /**
  44431. * Gets the value of the `R1` button
  44432. */
  44433. get buttonR1(): number;
  44434. /**
  44435. * Sets the value of the `R1` button
  44436. */
  44437. set buttonR1(value: number);
  44438. /**
  44439. * Gets the value of the Left joystick
  44440. */
  44441. get buttonLeftStick(): number;
  44442. /**
  44443. * Sets the value of the Left joystick
  44444. */
  44445. set buttonLeftStick(value: number);
  44446. /**
  44447. * Gets the value of the Right joystick
  44448. */
  44449. get buttonRightStick(): number;
  44450. /**
  44451. * Sets the value of the Right joystick
  44452. */
  44453. set buttonRightStick(value: number);
  44454. /**
  44455. * Gets the value of D-pad up
  44456. */
  44457. get dPadUp(): number;
  44458. /**
  44459. * Sets the value of D-pad up
  44460. */
  44461. set dPadUp(value: number);
  44462. /**
  44463. * Gets the value of D-pad down
  44464. */
  44465. get dPadDown(): number;
  44466. /**
  44467. * Sets the value of D-pad down
  44468. */
  44469. set dPadDown(value: number);
  44470. /**
  44471. * Gets the value of D-pad left
  44472. */
  44473. get dPadLeft(): number;
  44474. /**
  44475. * Sets the value of D-pad left
  44476. */
  44477. set dPadLeft(value: number);
  44478. /**
  44479. * Gets the value of D-pad right
  44480. */
  44481. get dPadRight(): number;
  44482. /**
  44483. * Sets the value of D-pad right
  44484. */
  44485. set dPadRight(value: number);
  44486. /**
  44487. * Force the gamepad to synchronize with device values
  44488. */
  44489. update(): void;
  44490. /**
  44491. * Disposes the gamepad
  44492. */
  44493. dispose(): void;
  44494. }
  44495. }
  44496. declare module BABYLON {
  44497. /**
  44498. * Manager for handling gamepads
  44499. */
  44500. export class GamepadManager {
  44501. private _scene?;
  44502. private _babylonGamepads;
  44503. private _oneGamepadConnected;
  44504. /** @hidden */
  44505. _isMonitoring: boolean;
  44506. private _gamepadEventSupported;
  44507. private _gamepadSupport?;
  44508. /**
  44509. * observable to be triggered when the gamepad controller has been connected
  44510. */
  44511. onGamepadConnectedObservable: Observable<Gamepad>;
  44512. /**
  44513. * observable to be triggered when the gamepad controller has been disconnected
  44514. */
  44515. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44516. private _onGamepadConnectedEvent;
  44517. private _onGamepadDisconnectedEvent;
  44518. /**
  44519. * Initializes the gamepad manager
  44520. * @param _scene BabylonJS scene
  44521. */
  44522. constructor(_scene?: Scene | undefined);
  44523. /**
  44524. * The gamepads in the game pad manager
  44525. */
  44526. get gamepads(): Gamepad[];
  44527. /**
  44528. * Get the gamepad controllers based on type
  44529. * @param type The type of gamepad controller
  44530. * @returns Nullable gamepad
  44531. */
  44532. getGamepadByType(type?: number): Nullable<Gamepad>;
  44533. /**
  44534. * Disposes the gamepad manager
  44535. */
  44536. dispose(): void;
  44537. private _addNewGamepad;
  44538. private _startMonitoringGamepads;
  44539. private _stopMonitoringGamepads;
  44540. /** @hidden */
  44541. _checkGamepadsStatus(): void;
  44542. private _updateGamepadObjects;
  44543. }
  44544. }
  44545. declare module BABYLON {
  44546. interface Scene {
  44547. /** @hidden */
  44548. _gamepadManager: Nullable<GamepadManager>;
  44549. /**
  44550. * Gets the gamepad manager associated with the scene
  44551. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44552. */
  44553. gamepadManager: GamepadManager;
  44554. }
  44555. /**
  44556. * Interface representing a free camera inputs manager
  44557. */
  44558. interface FreeCameraInputsManager {
  44559. /**
  44560. * Adds gamepad input support to the FreeCameraInputsManager.
  44561. * @returns the FreeCameraInputsManager
  44562. */
  44563. addGamepad(): FreeCameraInputsManager;
  44564. }
  44565. /**
  44566. * Interface representing an arc rotate camera inputs manager
  44567. */
  44568. interface ArcRotateCameraInputsManager {
  44569. /**
  44570. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44571. * @returns the camera inputs manager
  44572. */
  44573. addGamepad(): ArcRotateCameraInputsManager;
  44574. }
  44575. /**
  44576. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44577. */
  44578. export class GamepadSystemSceneComponent implements ISceneComponent {
  44579. /**
  44580. * The component name helpfull to identify the component in the list of scene components.
  44581. */
  44582. readonly name: string;
  44583. /**
  44584. * The scene the component belongs to.
  44585. */
  44586. scene: Scene;
  44587. /**
  44588. * Creates a new instance of the component for the given scene
  44589. * @param scene Defines the scene to register the component in
  44590. */
  44591. constructor(scene: Scene);
  44592. /**
  44593. * Registers the component in a given scene
  44594. */
  44595. register(): void;
  44596. /**
  44597. * Rebuilds the elements related to this component in case of
  44598. * context lost for instance.
  44599. */
  44600. rebuild(): void;
  44601. /**
  44602. * Disposes the component and the associated ressources
  44603. */
  44604. dispose(): void;
  44605. private _beforeCameraUpdate;
  44606. }
  44607. }
  44608. declare module BABYLON {
  44609. /**
  44610. * 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,
  44611. * which still works and will still be found in many Playgrounds.
  44612. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44613. */
  44614. export class UniversalCamera extends TouchCamera {
  44615. /**
  44616. * Defines the gamepad rotation sensiblity.
  44617. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44618. */
  44619. get gamepadAngularSensibility(): number;
  44620. set gamepadAngularSensibility(value: number);
  44621. /**
  44622. * Defines the gamepad move sensiblity.
  44623. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44624. */
  44625. get gamepadMoveSensibility(): number;
  44626. set gamepadMoveSensibility(value: number);
  44627. /**
  44628. * 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,
  44629. * which still works and will still be found in many Playgrounds.
  44630. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44631. * @param name Define the name of the camera in the scene
  44632. * @param position Define the start position of the camera in the scene
  44633. * @param scene Define the scene the camera belongs to
  44634. */
  44635. constructor(name: string, position: Vector3, scene: Scene);
  44636. /**
  44637. * Gets the current object class name.
  44638. * @return the class name
  44639. */
  44640. getClassName(): string;
  44641. }
  44642. }
  44643. declare module BABYLON {
  44644. /**
  44645. * This represents a FPS type of camera. This is only here for back compat purpose.
  44646. * Please use the UniversalCamera instead as both are identical.
  44647. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44648. */
  44649. export class GamepadCamera extends UniversalCamera {
  44650. /**
  44651. * Instantiates a new Gamepad Camera
  44652. * This represents a FPS type of camera. This is only here for back compat purpose.
  44653. * Please use the UniversalCamera instead as both are identical.
  44654. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44655. * @param name Define the name of the camera in the scene
  44656. * @param position Define the start position of the camera in the scene
  44657. * @param scene Define the scene the camera belongs to
  44658. */
  44659. constructor(name: string, position: Vector3, scene: Scene);
  44660. /**
  44661. * Gets the current object class name.
  44662. * @return the class name
  44663. */
  44664. getClassName(): string;
  44665. }
  44666. }
  44667. declare module BABYLON {
  44668. /** @hidden */
  44669. export var passPixelShader: {
  44670. name: string;
  44671. shader: string;
  44672. };
  44673. }
  44674. declare module BABYLON {
  44675. /** @hidden */
  44676. export var passCubePixelShader: {
  44677. name: string;
  44678. shader: string;
  44679. };
  44680. }
  44681. declare module BABYLON {
  44682. /**
  44683. * PassPostProcess which produces an output the same as it's input
  44684. */
  44685. export class PassPostProcess extends PostProcess {
  44686. /**
  44687. * Creates the PassPostProcess
  44688. * @param name The name of the effect.
  44689. * @param options The required width/height ratio to downsize to before computing the render pass.
  44690. * @param camera The camera to apply the render pass to.
  44691. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44692. * @param engine The engine which the post process will be applied. (default: current engine)
  44693. * @param reusable If the post process can be reused on the same frame. (default: false)
  44694. * @param textureType The type of texture to be used when performing the post processing.
  44695. * @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)
  44696. */
  44697. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44698. }
  44699. /**
  44700. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44701. */
  44702. export class PassCubePostProcess extends PostProcess {
  44703. private _face;
  44704. /**
  44705. * Gets or sets the cube face to display.
  44706. * * 0 is +X
  44707. * * 1 is -X
  44708. * * 2 is +Y
  44709. * * 3 is -Y
  44710. * * 4 is +Z
  44711. * * 5 is -Z
  44712. */
  44713. get face(): number;
  44714. set face(value: number);
  44715. /**
  44716. * Creates the PassCubePostProcess
  44717. * @param name The name of the effect.
  44718. * @param options The required width/height ratio to downsize to before computing the render pass.
  44719. * @param camera The camera to apply the render pass to.
  44720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44721. * @param engine The engine which the post process will be applied. (default: current engine)
  44722. * @param reusable If the post process can be reused on the same frame. (default: false)
  44723. * @param textureType The type of texture to be used when performing the post processing.
  44724. * @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)
  44725. */
  44726. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44727. }
  44728. }
  44729. declare module BABYLON {
  44730. /** @hidden */
  44731. export var anaglyphPixelShader: {
  44732. name: string;
  44733. shader: string;
  44734. };
  44735. }
  44736. declare module BABYLON {
  44737. /**
  44738. * Postprocess used to generate anaglyphic rendering
  44739. */
  44740. export class AnaglyphPostProcess extends PostProcess {
  44741. private _passedProcess;
  44742. /**
  44743. * Creates a new AnaglyphPostProcess
  44744. * @param name defines postprocess name
  44745. * @param options defines creation options or target ratio scale
  44746. * @param rigCameras defines cameras using this postprocess
  44747. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  44748. * @param engine defines hosting engine
  44749. * @param reusable defines if the postprocess will be reused multiple times per frame
  44750. */
  44751. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  44752. }
  44753. }
  44754. declare module BABYLON {
  44755. /**
  44756. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  44757. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44758. */
  44759. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  44760. /**
  44761. * Creates a new AnaglyphArcRotateCamera
  44762. * @param name defines camera name
  44763. * @param alpha defines alpha angle (in radians)
  44764. * @param beta defines beta angle (in radians)
  44765. * @param radius defines radius
  44766. * @param target defines camera target
  44767. * @param interaxialDistance defines distance between each color axis
  44768. * @param scene defines the hosting scene
  44769. */
  44770. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  44771. /**
  44772. * Gets camera class name
  44773. * @returns AnaglyphArcRotateCamera
  44774. */
  44775. getClassName(): string;
  44776. }
  44777. }
  44778. declare module BABYLON {
  44779. /**
  44780. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  44781. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44782. */
  44783. export class AnaglyphFreeCamera extends FreeCamera {
  44784. /**
  44785. * Creates a new AnaglyphFreeCamera
  44786. * @param name defines camera name
  44787. * @param position defines initial position
  44788. * @param interaxialDistance defines distance between each color axis
  44789. * @param scene defines the hosting scene
  44790. */
  44791. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44792. /**
  44793. * Gets camera class name
  44794. * @returns AnaglyphFreeCamera
  44795. */
  44796. getClassName(): string;
  44797. }
  44798. }
  44799. declare module BABYLON {
  44800. /**
  44801. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  44802. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44803. */
  44804. export class AnaglyphGamepadCamera extends GamepadCamera {
  44805. /**
  44806. * Creates a new AnaglyphGamepadCamera
  44807. * @param name defines camera name
  44808. * @param position defines initial position
  44809. * @param interaxialDistance defines distance between each color axis
  44810. * @param scene defines the hosting scene
  44811. */
  44812. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44813. /**
  44814. * Gets camera class name
  44815. * @returns AnaglyphGamepadCamera
  44816. */
  44817. getClassName(): string;
  44818. }
  44819. }
  44820. declare module BABYLON {
  44821. /**
  44822. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  44823. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44824. */
  44825. export class AnaglyphUniversalCamera extends UniversalCamera {
  44826. /**
  44827. * Creates a new AnaglyphUniversalCamera
  44828. * @param name defines camera name
  44829. * @param position defines initial position
  44830. * @param interaxialDistance defines distance between each color axis
  44831. * @param scene defines the hosting scene
  44832. */
  44833. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44834. /**
  44835. * Gets camera class name
  44836. * @returns AnaglyphUniversalCamera
  44837. */
  44838. getClassName(): string;
  44839. }
  44840. }
  44841. declare module BABYLON {
  44842. /**
  44843. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  44844. * @see http://doc.babylonjs.com/features/cameras
  44845. */
  44846. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  44847. /**
  44848. * Creates a new StereoscopicArcRotateCamera
  44849. * @param name defines camera name
  44850. * @param alpha defines alpha angle (in radians)
  44851. * @param beta defines beta angle (in radians)
  44852. * @param radius defines radius
  44853. * @param target defines camera target
  44854. * @param interaxialDistance defines distance between each color axis
  44855. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44856. * @param scene defines the hosting scene
  44857. */
  44858. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44859. /**
  44860. * Gets camera class name
  44861. * @returns StereoscopicArcRotateCamera
  44862. */
  44863. getClassName(): string;
  44864. }
  44865. }
  44866. declare module BABYLON {
  44867. /**
  44868. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  44869. * @see http://doc.babylonjs.com/features/cameras
  44870. */
  44871. export class StereoscopicFreeCamera extends FreeCamera {
  44872. /**
  44873. * Creates a new StereoscopicFreeCamera
  44874. * @param name defines camera name
  44875. * @param position defines initial position
  44876. * @param interaxialDistance defines distance between each color axis
  44877. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44878. * @param scene defines the hosting scene
  44879. */
  44880. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44881. /**
  44882. * Gets camera class name
  44883. * @returns StereoscopicFreeCamera
  44884. */
  44885. getClassName(): string;
  44886. }
  44887. }
  44888. declare module BABYLON {
  44889. /**
  44890. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  44891. * @see http://doc.babylonjs.com/features/cameras
  44892. */
  44893. export class StereoscopicGamepadCamera extends GamepadCamera {
  44894. /**
  44895. * Creates a new StereoscopicGamepadCamera
  44896. * @param name defines camera name
  44897. * @param position defines initial position
  44898. * @param interaxialDistance defines distance between each color axis
  44899. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44900. * @param scene defines the hosting scene
  44901. */
  44902. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44903. /**
  44904. * Gets camera class name
  44905. * @returns StereoscopicGamepadCamera
  44906. */
  44907. getClassName(): string;
  44908. }
  44909. }
  44910. declare module BABYLON {
  44911. /**
  44912. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  44913. * @see http://doc.babylonjs.com/features/cameras
  44914. */
  44915. export class StereoscopicUniversalCamera extends UniversalCamera {
  44916. /**
  44917. * Creates a new StereoscopicUniversalCamera
  44918. * @param name defines camera name
  44919. * @param position defines initial position
  44920. * @param interaxialDistance defines distance between each color axis
  44921. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44922. * @param scene defines the hosting scene
  44923. */
  44924. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44925. /**
  44926. * Gets camera class name
  44927. * @returns StereoscopicUniversalCamera
  44928. */
  44929. getClassName(): string;
  44930. }
  44931. }
  44932. declare module BABYLON {
  44933. /**
  44934. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  44935. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44936. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44937. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44938. */
  44939. export class VirtualJoysticksCamera extends FreeCamera {
  44940. /**
  44941. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  44942. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44943. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44944. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44945. * @param name Define the name of the camera in the scene
  44946. * @param position Define the start position of the camera in the scene
  44947. * @param scene Define the scene the camera belongs to
  44948. */
  44949. constructor(name: string, position: Vector3, scene: Scene);
  44950. /**
  44951. * Gets the current object class name.
  44952. * @return the class name
  44953. */
  44954. getClassName(): string;
  44955. }
  44956. }
  44957. declare module BABYLON {
  44958. /**
  44959. * This represents all the required metrics to create a VR camera.
  44960. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  44961. */
  44962. export class VRCameraMetrics {
  44963. /**
  44964. * Define the horizontal resolution off the screen.
  44965. */
  44966. hResolution: number;
  44967. /**
  44968. * Define the vertical resolution off the screen.
  44969. */
  44970. vResolution: number;
  44971. /**
  44972. * Define the horizontal screen size.
  44973. */
  44974. hScreenSize: number;
  44975. /**
  44976. * Define the vertical screen size.
  44977. */
  44978. vScreenSize: number;
  44979. /**
  44980. * Define the vertical screen center position.
  44981. */
  44982. vScreenCenter: number;
  44983. /**
  44984. * Define the distance of the eyes to the screen.
  44985. */
  44986. eyeToScreenDistance: number;
  44987. /**
  44988. * Define the distance between both lenses
  44989. */
  44990. lensSeparationDistance: number;
  44991. /**
  44992. * Define the distance between both viewer's eyes.
  44993. */
  44994. interpupillaryDistance: number;
  44995. /**
  44996. * Define the distortion factor of the VR postprocess.
  44997. * Please, touch with care.
  44998. */
  44999. distortionK: number[];
  45000. /**
  45001. * Define the chromatic aberration correction factors for the VR post process.
  45002. */
  45003. chromaAbCorrection: number[];
  45004. /**
  45005. * Define the scale factor of the post process.
  45006. * The smaller the better but the slower.
  45007. */
  45008. postProcessScaleFactor: number;
  45009. /**
  45010. * Define an offset for the lens center.
  45011. */
  45012. lensCenterOffset: number;
  45013. /**
  45014. * Define if the current vr camera should compensate the distortion of the lense or not.
  45015. */
  45016. compensateDistortion: boolean;
  45017. /**
  45018. * Defines if multiview should be enabled when rendering (Default: false)
  45019. */
  45020. multiviewEnabled: boolean;
  45021. /**
  45022. * Gets the rendering aspect ratio based on the provided resolutions.
  45023. */
  45024. get aspectRatio(): number;
  45025. /**
  45026. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45027. */
  45028. get aspectRatioFov(): number;
  45029. /**
  45030. * @hidden
  45031. */
  45032. get leftHMatrix(): Matrix;
  45033. /**
  45034. * @hidden
  45035. */
  45036. get rightHMatrix(): Matrix;
  45037. /**
  45038. * @hidden
  45039. */
  45040. get leftPreViewMatrix(): Matrix;
  45041. /**
  45042. * @hidden
  45043. */
  45044. get rightPreViewMatrix(): Matrix;
  45045. /**
  45046. * Get the default VRMetrics based on the most generic setup.
  45047. * @returns the default vr metrics
  45048. */
  45049. static GetDefault(): VRCameraMetrics;
  45050. }
  45051. }
  45052. declare module BABYLON {
  45053. /** @hidden */
  45054. export var vrDistortionCorrectionPixelShader: {
  45055. name: string;
  45056. shader: string;
  45057. };
  45058. }
  45059. declare module BABYLON {
  45060. /**
  45061. * VRDistortionCorrectionPostProcess used for mobile VR
  45062. */
  45063. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45064. private _isRightEye;
  45065. private _distortionFactors;
  45066. private _postProcessScaleFactor;
  45067. private _lensCenterOffset;
  45068. private _scaleIn;
  45069. private _scaleFactor;
  45070. private _lensCenter;
  45071. /**
  45072. * Initializes the VRDistortionCorrectionPostProcess
  45073. * @param name The name of the effect.
  45074. * @param camera The camera to apply the render pass to.
  45075. * @param isRightEye If this is for the right eye distortion
  45076. * @param vrMetrics All the required metrics for the VR camera
  45077. */
  45078. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45079. }
  45080. }
  45081. declare module BABYLON {
  45082. /**
  45083. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45084. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45085. */
  45086. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45087. /**
  45088. * Creates a new VRDeviceOrientationArcRotateCamera
  45089. * @param name defines camera name
  45090. * @param alpha defines the camera rotation along the logitudinal axis
  45091. * @param beta defines the camera rotation along the latitudinal axis
  45092. * @param radius defines the camera distance from its target
  45093. * @param target defines the camera target
  45094. * @param scene defines the scene the camera belongs to
  45095. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45096. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45097. */
  45098. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45099. /**
  45100. * Gets camera class name
  45101. * @returns VRDeviceOrientationArcRotateCamera
  45102. */
  45103. getClassName(): string;
  45104. }
  45105. }
  45106. declare module BABYLON {
  45107. /**
  45108. * Camera used to simulate VR rendering (based on FreeCamera)
  45109. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45110. */
  45111. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45112. /**
  45113. * Creates a new VRDeviceOrientationFreeCamera
  45114. * @param name defines camera name
  45115. * @param position defines the start position of the camera
  45116. * @param scene defines the scene the camera belongs to
  45117. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45118. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45119. */
  45120. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45121. /**
  45122. * Gets camera class name
  45123. * @returns VRDeviceOrientationFreeCamera
  45124. */
  45125. getClassName(): string;
  45126. }
  45127. }
  45128. declare module BABYLON {
  45129. /**
  45130. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45131. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45132. */
  45133. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45134. /**
  45135. * Creates a new VRDeviceOrientationGamepadCamera
  45136. * @param name defines camera name
  45137. * @param position defines the start position of the camera
  45138. * @param scene defines the scene the camera belongs to
  45139. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45140. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45141. */
  45142. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45143. /**
  45144. * Gets camera class name
  45145. * @returns VRDeviceOrientationGamepadCamera
  45146. */
  45147. getClassName(): string;
  45148. }
  45149. }
  45150. declare module BABYLON {
  45151. /** @hidden */
  45152. export var imageProcessingPixelShader: {
  45153. name: string;
  45154. shader: string;
  45155. };
  45156. }
  45157. declare module BABYLON {
  45158. /**
  45159. * ImageProcessingPostProcess
  45160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45161. */
  45162. export class ImageProcessingPostProcess extends PostProcess {
  45163. /**
  45164. * Default configuration related to image processing available in the PBR Material.
  45165. */
  45166. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45167. /**
  45168. * Gets the image processing configuration used either in this material.
  45169. */
  45170. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45171. /**
  45172. * Sets the Default image processing configuration used either in the this material.
  45173. *
  45174. * If sets to null, the scene one is in use.
  45175. */
  45176. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45177. /**
  45178. * Keep track of the image processing observer to allow dispose and replace.
  45179. */
  45180. private _imageProcessingObserver;
  45181. /**
  45182. * Attaches a new image processing configuration to the PBR Material.
  45183. * @param configuration
  45184. */
  45185. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45186. /**
  45187. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45188. */
  45189. get colorCurves(): Nullable<ColorCurves>;
  45190. /**
  45191. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45192. */
  45193. set colorCurves(value: Nullable<ColorCurves>);
  45194. /**
  45195. * Gets wether the color curves effect is enabled.
  45196. */
  45197. get colorCurvesEnabled(): boolean;
  45198. /**
  45199. * Sets wether the color curves effect is enabled.
  45200. */
  45201. set colorCurvesEnabled(value: boolean);
  45202. /**
  45203. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45204. */
  45205. get colorGradingTexture(): Nullable<BaseTexture>;
  45206. /**
  45207. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45208. */
  45209. set colorGradingTexture(value: Nullable<BaseTexture>);
  45210. /**
  45211. * Gets wether the color grading effect is enabled.
  45212. */
  45213. get colorGradingEnabled(): boolean;
  45214. /**
  45215. * Gets wether the color grading effect is enabled.
  45216. */
  45217. set colorGradingEnabled(value: boolean);
  45218. /**
  45219. * Gets exposure used in the effect.
  45220. */
  45221. get exposure(): number;
  45222. /**
  45223. * Sets exposure used in the effect.
  45224. */
  45225. set exposure(value: number);
  45226. /**
  45227. * Gets wether tonemapping is enabled or not.
  45228. */
  45229. get toneMappingEnabled(): boolean;
  45230. /**
  45231. * Sets wether tonemapping is enabled or not
  45232. */
  45233. set toneMappingEnabled(value: boolean);
  45234. /**
  45235. * Gets the type of tone mapping effect.
  45236. */
  45237. get toneMappingType(): number;
  45238. /**
  45239. * Sets the type of tone mapping effect.
  45240. */
  45241. set toneMappingType(value: number);
  45242. /**
  45243. * Gets contrast used in the effect.
  45244. */
  45245. get contrast(): number;
  45246. /**
  45247. * Sets contrast used in the effect.
  45248. */
  45249. set contrast(value: number);
  45250. /**
  45251. * Gets Vignette stretch size.
  45252. */
  45253. get vignetteStretch(): number;
  45254. /**
  45255. * Sets Vignette stretch size.
  45256. */
  45257. set vignetteStretch(value: number);
  45258. /**
  45259. * Gets Vignette centre X Offset.
  45260. */
  45261. get vignetteCentreX(): number;
  45262. /**
  45263. * Sets Vignette centre X Offset.
  45264. */
  45265. set vignetteCentreX(value: number);
  45266. /**
  45267. * Gets Vignette centre Y Offset.
  45268. */
  45269. get vignetteCentreY(): number;
  45270. /**
  45271. * Sets Vignette centre Y Offset.
  45272. */
  45273. set vignetteCentreY(value: number);
  45274. /**
  45275. * Gets Vignette weight or intensity of the vignette effect.
  45276. */
  45277. get vignetteWeight(): number;
  45278. /**
  45279. * Sets Vignette weight or intensity of the vignette effect.
  45280. */
  45281. set vignetteWeight(value: number);
  45282. /**
  45283. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45284. * if vignetteEnabled is set to true.
  45285. */
  45286. get vignetteColor(): Color4;
  45287. /**
  45288. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45289. * if vignetteEnabled is set to true.
  45290. */
  45291. set vignetteColor(value: Color4);
  45292. /**
  45293. * Gets Camera field of view used by the Vignette effect.
  45294. */
  45295. get vignetteCameraFov(): number;
  45296. /**
  45297. * Sets Camera field of view used by the Vignette effect.
  45298. */
  45299. set vignetteCameraFov(value: number);
  45300. /**
  45301. * Gets the vignette blend mode allowing different kind of effect.
  45302. */
  45303. get vignetteBlendMode(): number;
  45304. /**
  45305. * Sets the vignette blend mode allowing different kind of effect.
  45306. */
  45307. set vignetteBlendMode(value: number);
  45308. /**
  45309. * Gets wether the vignette effect is enabled.
  45310. */
  45311. get vignetteEnabled(): boolean;
  45312. /**
  45313. * Sets wether the vignette effect is enabled.
  45314. */
  45315. set vignetteEnabled(value: boolean);
  45316. private _fromLinearSpace;
  45317. /**
  45318. * Gets wether the input of the processing is in Gamma or Linear Space.
  45319. */
  45320. get fromLinearSpace(): boolean;
  45321. /**
  45322. * Sets wether the input of the processing is in Gamma or Linear Space.
  45323. */
  45324. set fromLinearSpace(value: boolean);
  45325. /**
  45326. * Defines cache preventing GC.
  45327. */
  45328. private _defines;
  45329. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45330. /**
  45331. * "ImageProcessingPostProcess"
  45332. * @returns "ImageProcessingPostProcess"
  45333. */
  45334. getClassName(): string;
  45335. protected _updateParameters(): void;
  45336. dispose(camera?: Camera): void;
  45337. }
  45338. }
  45339. declare module BABYLON {
  45340. /**
  45341. * Class containing static functions to help procedurally build meshes
  45342. */
  45343. export class GroundBuilder {
  45344. /**
  45345. * Creates a ground mesh
  45346. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45347. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45349. * @param name defines the name of the mesh
  45350. * @param options defines the options used to create the mesh
  45351. * @param scene defines the hosting scene
  45352. * @returns the ground mesh
  45353. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45354. */
  45355. static CreateGround(name: string, options: {
  45356. width?: number;
  45357. height?: number;
  45358. subdivisions?: number;
  45359. subdivisionsX?: number;
  45360. subdivisionsY?: number;
  45361. updatable?: boolean;
  45362. }, scene: any): Mesh;
  45363. /**
  45364. * Creates a tiled ground mesh
  45365. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45366. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45367. * * 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
  45368. * * 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
  45369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45370. * @param name defines the name of the mesh
  45371. * @param options defines the options used to create the mesh
  45372. * @param scene defines the hosting scene
  45373. * @returns the tiled ground mesh
  45374. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45375. */
  45376. static CreateTiledGround(name: string, options: {
  45377. xmin: number;
  45378. zmin: number;
  45379. xmax: number;
  45380. zmax: number;
  45381. subdivisions?: {
  45382. w: number;
  45383. h: number;
  45384. };
  45385. precision?: {
  45386. w: number;
  45387. h: number;
  45388. };
  45389. updatable?: boolean;
  45390. }, scene?: Nullable<Scene>): Mesh;
  45391. /**
  45392. * Creates a ground mesh from a height map
  45393. * * The parameter `url` sets the URL of the height map image resource.
  45394. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45395. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45396. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45397. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45398. * * 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.
  45399. * * 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).
  45400. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45402. * @param name defines the name of the mesh
  45403. * @param url defines the url to the height map
  45404. * @param options defines the options used to create the mesh
  45405. * @param scene defines the hosting scene
  45406. * @returns the ground mesh
  45407. * @see https://doc.babylonjs.com/babylon101/height_map
  45408. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45409. */
  45410. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45411. width?: number;
  45412. height?: number;
  45413. subdivisions?: number;
  45414. minHeight?: number;
  45415. maxHeight?: number;
  45416. colorFilter?: Color3;
  45417. alphaFilter?: number;
  45418. updatable?: boolean;
  45419. onReady?: (mesh: GroundMesh) => void;
  45420. }, scene?: Nullable<Scene>): GroundMesh;
  45421. }
  45422. }
  45423. declare module BABYLON {
  45424. /**
  45425. * Class containing static functions to help procedurally build meshes
  45426. */
  45427. export class TorusBuilder {
  45428. /**
  45429. * Creates a torus mesh
  45430. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45431. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45432. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45434. * * 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
  45435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45436. * @param name defines the name of the mesh
  45437. * @param options defines the options used to create the mesh
  45438. * @param scene defines the hosting scene
  45439. * @returns the torus mesh
  45440. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45441. */
  45442. static CreateTorus(name: string, options: {
  45443. diameter?: number;
  45444. thickness?: number;
  45445. tessellation?: number;
  45446. updatable?: boolean;
  45447. sideOrientation?: number;
  45448. frontUVs?: Vector4;
  45449. backUVs?: Vector4;
  45450. }, scene: any): Mesh;
  45451. }
  45452. }
  45453. declare module BABYLON {
  45454. /**
  45455. * Class containing static functions to help procedurally build meshes
  45456. */
  45457. export class CylinderBuilder {
  45458. /**
  45459. * Creates a cylinder or a cone mesh
  45460. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45461. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45462. * * 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.
  45463. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45464. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45465. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45466. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45467. * * 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).
  45468. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45469. * * 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).
  45470. * * 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
  45471. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45472. * * 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
  45473. * * 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.
  45474. * * If `enclose` is false, a ring surface is one element.
  45475. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45476. * * 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
  45477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45478. * * 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
  45479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45480. * @param name defines the name of the mesh
  45481. * @param options defines the options used to create the mesh
  45482. * @param scene defines the hosting scene
  45483. * @returns the cylinder mesh
  45484. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45485. */
  45486. static CreateCylinder(name: string, options: {
  45487. height?: number;
  45488. diameterTop?: number;
  45489. diameterBottom?: number;
  45490. diameter?: number;
  45491. tessellation?: number;
  45492. subdivisions?: number;
  45493. arc?: number;
  45494. faceColors?: Color4[];
  45495. faceUV?: Vector4[];
  45496. updatable?: boolean;
  45497. hasRings?: boolean;
  45498. enclose?: boolean;
  45499. cap?: number;
  45500. sideOrientation?: number;
  45501. frontUVs?: Vector4;
  45502. backUVs?: Vector4;
  45503. }, scene: any): Mesh;
  45504. }
  45505. }
  45506. declare module BABYLON {
  45507. /**
  45508. * States of the webXR experience
  45509. */
  45510. export enum WebXRState {
  45511. /**
  45512. * Transitioning to being in XR mode
  45513. */
  45514. ENTERING_XR = 0,
  45515. /**
  45516. * Transitioning to non XR mode
  45517. */
  45518. EXITING_XR = 1,
  45519. /**
  45520. * In XR mode and presenting
  45521. */
  45522. IN_XR = 2,
  45523. /**
  45524. * Not entered XR mode
  45525. */
  45526. NOT_IN_XR = 3
  45527. }
  45528. /**
  45529. * Abstraction of the XR render target
  45530. */
  45531. export interface WebXRRenderTarget extends IDisposable {
  45532. /**
  45533. * xrpresent context of the canvas which can be used to display/mirror xr content
  45534. */
  45535. canvasContext: WebGLRenderingContext;
  45536. /**
  45537. * xr layer for the canvas
  45538. */
  45539. xrLayer: Nullable<XRWebGLLayer>;
  45540. /**
  45541. * Initializes the xr layer for the session
  45542. * @param xrSession xr session
  45543. * @returns a promise that will resolve once the XR Layer has been created
  45544. */
  45545. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45546. }
  45547. }
  45548. declare module BABYLON {
  45549. /**
  45550. * COnfiguration object for WebXR output canvas
  45551. */
  45552. export class WebXRManagedOutputCanvasOptions {
  45553. /**
  45554. * An optional canvas in case you wish to create it yourself and provide it here.
  45555. * If not provided, a new canvas will be created
  45556. */
  45557. canvasElement?: HTMLCanvasElement;
  45558. /**
  45559. * Options for this XR Layer output
  45560. */
  45561. canvasOptions?: XRWebGLLayerOptions;
  45562. /**
  45563. * CSS styling for a newly created canvas (if not provided)
  45564. */
  45565. newCanvasCssStyle?: string;
  45566. /**
  45567. * Get the default values of the configuration object
  45568. * @returns default values of this configuration object
  45569. */
  45570. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45571. }
  45572. /**
  45573. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45574. */
  45575. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45576. private _options;
  45577. private _canvas;
  45578. private _engine;
  45579. /**
  45580. * Rendering context of the canvas which can be used to display/mirror xr content
  45581. */
  45582. canvasContext: WebGLRenderingContext;
  45583. /**
  45584. * xr layer for the canvas
  45585. */
  45586. xrLayer: Nullable<XRWebGLLayer>;
  45587. /**
  45588. * Initializes the canvas to be added/removed upon entering/exiting xr
  45589. * @param _xrSessionManager The XR Session manager
  45590. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45591. */
  45592. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45593. /**
  45594. * Disposes of the object
  45595. */
  45596. dispose(): void;
  45597. /**
  45598. * Initializes the xr layer for the session
  45599. * @param xrSession xr session
  45600. * @returns a promise that will resolve once the XR Layer has been created
  45601. */
  45602. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45603. private _addCanvas;
  45604. private _removeCanvas;
  45605. private _setManagedOutputCanvas;
  45606. }
  45607. }
  45608. declare module BABYLON {
  45609. /**
  45610. * Manages an XRSession to work with Babylon's engine
  45611. * @see https://doc.babylonjs.com/how_to/webxr
  45612. */
  45613. export class WebXRSessionManager implements IDisposable {
  45614. /** The scene which the session should be created for */
  45615. scene: Scene;
  45616. private _referenceSpace;
  45617. private _rttProvider;
  45618. private _sessionEnded;
  45619. private _xrNavigator;
  45620. private baseLayer;
  45621. /**
  45622. * The base reference space from which the session started. good if you want to reset your
  45623. * reference space
  45624. */
  45625. baseReferenceSpace: XRReferenceSpace;
  45626. /**
  45627. * Current XR frame
  45628. */
  45629. currentFrame: Nullable<XRFrame>;
  45630. /** WebXR timestamp updated every frame */
  45631. currentTimestamp: number;
  45632. /**
  45633. * Used just in case of a failure to initialize an immersive session.
  45634. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45635. */
  45636. defaultHeightCompensation: number;
  45637. /**
  45638. * Fires every time a new xrFrame arrives which can be used to update the camera
  45639. */
  45640. onXRFrameObservable: Observable<XRFrame>;
  45641. /**
  45642. * Fires when the reference space changed
  45643. */
  45644. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45645. /**
  45646. * Fires when the xr session is ended either by the device or manually done
  45647. */
  45648. onXRSessionEnded: Observable<any>;
  45649. /**
  45650. * Fires when the xr session is ended either by the device or manually done
  45651. */
  45652. onXRSessionInit: Observable<XRSession>;
  45653. /**
  45654. * Underlying xr session
  45655. */
  45656. session: XRSession;
  45657. /**
  45658. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45659. * or get the offset the player is currently at.
  45660. */
  45661. viewerReferenceSpace: XRReferenceSpace;
  45662. /**
  45663. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45664. * @param scene The scene which the session should be created for
  45665. */
  45666. constructor(
  45667. /** The scene which the session should be created for */
  45668. scene: Scene);
  45669. /**
  45670. * The current reference space used in this session. This reference space can constantly change!
  45671. * It is mainly used to offset the camera's position.
  45672. */
  45673. get referenceSpace(): XRReferenceSpace;
  45674. /**
  45675. * Set a new reference space and triggers the observable
  45676. */
  45677. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45678. /**
  45679. * Disposes of the session manager
  45680. */
  45681. dispose(): void;
  45682. /**
  45683. * Stops the xrSession and restores the render loop
  45684. * @returns Promise which resolves after it exits XR
  45685. */
  45686. exitXRAsync(): Promise<void>;
  45687. /**
  45688. * Gets the correct render target texture to be rendered this frame for this eye
  45689. * @param eye the eye for which to get the render target
  45690. * @returns the render target for the specified eye
  45691. */
  45692. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  45693. /**
  45694. * Creates a WebXRRenderTarget object for the XR session
  45695. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  45696. * @param options optional options to provide when creating a new render target
  45697. * @returns a WebXR render target to which the session can render
  45698. */
  45699. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  45700. /**
  45701. * Initializes the manager
  45702. * After initialization enterXR can be called to start an XR session
  45703. * @returns Promise which resolves after it is initialized
  45704. */
  45705. initializeAsync(): Promise<void>;
  45706. /**
  45707. * Initializes an xr session
  45708. * @param xrSessionMode mode to initialize
  45709. * @param xrSessionInit defines optional and required values to pass to the session builder
  45710. * @returns a promise which will resolve once the session has been initialized
  45711. */
  45712. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  45713. /**
  45714. * Checks if a session would be supported for the creation options specified
  45715. * @param sessionMode session mode to check if supported eg. immersive-vr
  45716. * @returns A Promise that resolves to true if supported and false if not
  45717. */
  45718. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45719. /**
  45720. * Resets the reference space to the one started the session
  45721. */
  45722. resetReferenceSpace(): void;
  45723. /**
  45724. * Starts rendering to the xr layer
  45725. */
  45726. runXRRenderLoop(): void;
  45727. /**
  45728. * Sets the reference space on the xr session
  45729. * @param referenceSpaceType space to set
  45730. * @returns a promise that will resolve once the reference space has been set
  45731. */
  45732. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  45733. /**
  45734. * Updates the render state of the session
  45735. * @param state state to set
  45736. * @returns a promise that resolves once the render state has been updated
  45737. */
  45738. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  45739. /**
  45740. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  45741. * @param sessionMode defines the session to test
  45742. * @returns a promise with boolean as final value
  45743. */
  45744. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45745. private _createRenderTargetTexture;
  45746. }
  45747. }
  45748. declare module BABYLON {
  45749. /**
  45750. * WebXR Camera which holds the views for the xrSession
  45751. * @see https://doc.babylonjs.com/how_to/webxr_camera
  45752. */
  45753. export class WebXRCamera extends FreeCamera {
  45754. private _xrSessionManager;
  45755. private _firstFrame;
  45756. private _referenceQuaternion;
  45757. private _referencedPosition;
  45758. private _xrInvPositionCache;
  45759. private _xrInvQuaternionCache;
  45760. /**
  45761. * Should position compensation execute on first frame.
  45762. * This is used when copying the position from a native (non XR) camera
  45763. */
  45764. compensateOnFirstFrame: boolean;
  45765. /**
  45766. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  45767. * @param name the name of the camera
  45768. * @param scene the scene to add the camera to
  45769. * @param _xrSessionManager a constructed xr session manager
  45770. */
  45771. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  45772. /**
  45773. * Return the user's height, unrelated to the current ground.
  45774. * This will be the y position of this camera, when ground level is 0.
  45775. */
  45776. get realWorldHeight(): number;
  45777. /** @hidden */
  45778. _updateForDualEyeDebugging(): void;
  45779. /**
  45780. * Sets this camera's transformation based on a non-vr camera
  45781. * @param otherCamera the non-vr camera to copy the transformation from
  45782. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  45783. */
  45784. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  45785. /**
  45786. * Gets the current instance class name ("WebXRCamera").
  45787. * @returns the class name
  45788. */
  45789. getClassName(): string;
  45790. /**
  45791. * Overriding the _getViewMatrix function, as it is computed by WebXR
  45792. */
  45793. _getViewMatrix(): Matrix;
  45794. private _updateFromXRSession;
  45795. private _updateNumberOfRigCameras;
  45796. private _updateReferenceSpace;
  45797. private _updateReferenceSpaceOffset;
  45798. }
  45799. }
  45800. declare module BABYLON {
  45801. /**
  45802. * Defining the interface required for a (webxr) feature
  45803. */
  45804. export interface IWebXRFeature extends IDisposable {
  45805. /**
  45806. * Is this feature attached
  45807. */
  45808. attached: boolean;
  45809. /**
  45810. * Should auto-attach be disabled?
  45811. */
  45812. disableAutoAttach: boolean;
  45813. /**
  45814. * Attach the feature to the session
  45815. * Will usually be called by the features manager
  45816. *
  45817. * @param force should attachment be forced (even when already attached)
  45818. * @returns true if successful.
  45819. */
  45820. attach(force?: boolean): boolean;
  45821. /**
  45822. * Detach the feature from the session
  45823. * Will usually be called by the features manager
  45824. *
  45825. * @returns true if successful.
  45826. */
  45827. detach(): boolean;
  45828. }
  45829. /**
  45830. * A list of the currently available features without referencing them
  45831. */
  45832. export class WebXRFeatureName {
  45833. /**
  45834. * The name of the anchor system feature
  45835. */
  45836. static ANCHOR_SYSTEM: string;
  45837. /**
  45838. * The name of the background remover feature
  45839. */
  45840. static BACKGROUND_REMOVER: string;
  45841. /**
  45842. * The name of the hit test feature
  45843. */
  45844. static HIT_TEST: string;
  45845. /**
  45846. * physics impostors for xr controllers feature
  45847. */
  45848. static PHYSICS_CONTROLLERS: string;
  45849. /**
  45850. * The name of the plane detection feature
  45851. */
  45852. static PLANE_DETECTION: string;
  45853. /**
  45854. * The name of the pointer selection feature
  45855. */
  45856. static POINTER_SELECTION: string;
  45857. /**
  45858. * The name of the teleportation feature
  45859. */
  45860. static TELEPORTATION: string;
  45861. }
  45862. /**
  45863. * Defining the constructor of a feature. Used to register the modules.
  45864. */
  45865. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  45866. /**
  45867. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  45868. * It is mainly used in AR sessions.
  45869. *
  45870. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  45871. */
  45872. export class WebXRFeaturesManager implements IDisposable {
  45873. private _xrSessionManager;
  45874. private static readonly _AvailableFeatures;
  45875. private _features;
  45876. /**
  45877. * constructs a new features manages.
  45878. *
  45879. * @param _xrSessionManager an instance of WebXRSessionManager
  45880. */
  45881. constructor(_xrSessionManager: WebXRSessionManager);
  45882. /**
  45883. * Used to register a module. After calling this function a developer can use this feature in the scene.
  45884. * Mainly used internally.
  45885. *
  45886. * @param featureName the name of the feature to register
  45887. * @param constructorFunction the function used to construct the module
  45888. * @param version the (babylon) version of the module
  45889. * @param stable is that a stable version of this module
  45890. */
  45891. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  45892. /**
  45893. * Returns a constructor of a specific feature.
  45894. *
  45895. * @param featureName the name of the feature to construct
  45896. * @param version the version of the feature to load
  45897. * @param xrSessionManager the xrSessionManager. Used to construct the module
  45898. * @param options optional options provided to the module.
  45899. * @returns a function that, when called, will return a new instance of this feature
  45900. */
  45901. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  45902. /**
  45903. * Can be used to return the list of features currently registered
  45904. *
  45905. * @returns an Array of available features
  45906. */
  45907. static GetAvailableFeatures(): string[];
  45908. /**
  45909. * Gets the versions available for a specific feature
  45910. * @param featureName the name of the feature
  45911. * @returns an array with the available versions
  45912. */
  45913. static GetAvailableVersions(featureName: string): string[];
  45914. /**
  45915. * Return the latest unstable version of this feature
  45916. * @param featureName the name of the feature to search
  45917. * @returns the version number. if not found will return -1
  45918. */
  45919. static GetLatestVersionOfFeature(featureName: string): number;
  45920. /**
  45921. * Return the latest stable version of this feature
  45922. * @param featureName the name of the feature to search
  45923. * @returns the version number. if not found will return -1
  45924. */
  45925. static GetStableVersionOfFeature(featureName: string): number;
  45926. /**
  45927. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  45928. * Can be used during a session to start a feature
  45929. * @param featureName the name of feature to attach
  45930. */
  45931. attachFeature(featureName: string): void;
  45932. /**
  45933. * Can be used inside a session or when the session ends to detach a specific feature
  45934. * @param featureName the name of the feature to detach
  45935. */
  45936. detachFeature(featureName: string): void;
  45937. /**
  45938. * Used to disable an already-enabled feature
  45939. * The feature will be disposed and will be recreated once enabled.
  45940. * @param featureName the feature to disable
  45941. * @returns true if disable was successful
  45942. */
  45943. disableFeature(featureName: string | {
  45944. Name: string;
  45945. }): boolean;
  45946. /**
  45947. * dispose this features manager
  45948. */
  45949. dispose(): void;
  45950. /**
  45951. * 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.
  45952. * 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.
  45953. *
  45954. * @param featureName the name of the feature to load or the class of the feature
  45955. * @param version optional version to load. if not provided the latest version will be enabled
  45956. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  45957. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  45958. * @returns a new constructed feature or throws an error if feature not found.
  45959. */
  45960. enableFeature(featureName: string | {
  45961. Name: string;
  45962. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  45963. /**
  45964. * get the implementation of an enabled feature.
  45965. * @param featureName the name of the feature to load
  45966. * @returns the feature class, if found
  45967. */
  45968. getEnabledFeature(featureName: string): IWebXRFeature;
  45969. /**
  45970. * Get the list of enabled features
  45971. * @returns an array of enabled features
  45972. */
  45973. getEnabledFeatures(): string[];
  45974. }
  45975. }
  45976. declare module BABYLON {
  45977. /**
  45978. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  45979. * @see https://doc.babylonjs.com/how_to/webxr
  45980. */
  45981. export class WebXRExperienceHelper implements IDisposable {
  45982. private scene;
  45983. private _nonVRCamera;
  45984. private _originalSceneAutoClear;
  45985. private _supported;
  45986. /**
  45987. * Camera used to render xr content
  45988. */
  45989. camera: WebXRCamera;
  45990. /** A features manager for this xr session */
  45991. featuresManager: WebXRFeaturesManager;
  45992. /**
  45993. * Observers registered here will be triggered after the camera's initial transformation is set
  45994. * This can be used to set a different ground level or an extra rotation.
  45995. *
  45996. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  45997. * to the position set after this observable is done executing.
  45998. */
  45999. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46000. /**
  46001. * Fires when the state of the experience helper has changed
  46002. */
  46003. onStateChangedObservable: Observable<WebXRState>;
  46004. /** Session manager used to keep track of xr session */
  46005. sessionManager: WebXRSessionManager;
  46006. /**
  46007. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46008. */
  46009. state: WebXRState;
  46010. /**
  46011. * Creates a WebXRExperienceHelper
  46012. * @param scene The scene the helper should be created in
  46013. */
  46014. private constructor();
  46015. /**
  46016. * Creates the experience helper
  46017. * @param scene the scene to attach the experience helper to
  46018. * @returns a promise for the experience helper
  46019. */
  46020. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46021. /**
  46022. * Disposes of the experience helper
  46023. */
  46024. dispose(): void;
  46025. /**
  46026. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46027. * @param sessionMode options for the XR session
  46028. * @param referenceSpaceType frame of reference of the XR session
  46029. * @param renderTarget the output canvas that will be used to enter XR mode
  46030. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46031. * @returns promise that resolves after xr mode has entered
  46032. */
  46033. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46034. /**
  46035. * Exits XR mode and returns the scene to its original state
  46036. * @returns promise that resolves after xr mode has exited
  46037. */
  46038. exitXRAsync(): Promise<void>;
  46039. private _nonXRToXRCamera;
  46040. private _setState;
  46041. }
  46042. }
  46043. declare module BABYLON {
  46044. /**
  46045. * X-Y values for axes in WebXR
  46046. */
  46047. export interface IWebXRMotionControllerAxesValue {
  46048. /**
  46049. * The value of the x axis
  46050. */
  46051. x: number;
  46052. /**
  46053. * The value of the y-axis
  46054. */
  46055. y: number;
  46056. }
  46057. /**
  46058. * changed / previous values for the values of this component
  46059. */
  46060. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46061. /**
  46062. * current (this frame) value
  46063. */
  46064. current: T;
  46065. /**
  46066. * previous (last change) value
  46067. */
  46068. previous: T;
  46069. }
  46070. /**
  46071. * Represents changes in the component between current frame and last values recorded
  46072. */
  46073. export interface IWebXRMotionControllerComponentChanges {
  46074. /**
  46075. * will be populated with previous and current values if axes changed
  46076. */
  46077. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46078. /**
  46079. * will be populated with previous and current values if pressed changed
  46080. */
  46081. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46082. /**
  46083. * will be populated with previous and current values if touched changed
  46084. */
  46085. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46086. /**
  46087. * will be populated with previous and current values if value changed
  46088. */
  46089. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46090. }
  46091. /**
  46092. * This class represents a single component (for example button or thumbstick) of a motion controller
  46093. */
  46094. export class WebXRControllerComponent implements IDisposable {
  46095. /**
  46096. * the id of this component
  46097. */
  46098. id: string;
  46099. /**
  46100. * the type of the component
  46101. */
  46102. type: MotionControllerComponentType;
  46103. private _buttonIndex;
  46104. private _axesIndices;
  46105. private _axes;
  46106. private _changes;
  46107. private _currentValue;
  46108. private _hasChanges;
  46109. private _pressed;
  46110. private _touched;
  46111. /**
  46112. * button component type
  46113. */
  46114. static BUTTON_TYPE: MotionControllerComponentType;
  46115. /**
  46116. * squeeze component type
  46117. */
  46118. static SQUEEZE_TYPE: MotionControllerComponentType;
  46119. /**
  46120. * Thumbstick component type
  46121. */
  46122. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46123. /**
  46124. * Touchpad component type
  46125. */
  46126. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46127. /**
  46128. * trigger component type
  46129. */
  46130. static TRIGGER_TYPE: MotionControllerComponentType;
  46131. /**
  46132. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46133. * the axes data changes
  46134. */
  46135. onAxisValueChangedObservable: Observable<{
  46136. x: number;
  46137. y: number;
  46138. }>;
  46139. /**
  46140. * Observers registered here will be triggered when the state of a button changes
  46141. * State change is either pressed / touched / value
  46142. */
  46143. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46144. /**
  46145. * Creates a new component for a motion controller.
  46146. * It is created by the motion controller itself
  46147. *
  46148. * @param id the id of this component
  46149. * @param type the type of the component
  46150. * @param _buttonIndex index in the buttons array of the gamepad
  46151. * @param _axesIndices indices of the values in the axes array of the gamepad
  46152. */
  46153. constructor(
  46154. /**
  46155. * the id of this component
  46156. */
  46157. id: string,
  46158. /**
  46159. * the type of the component
  46160. */
  46161. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46162. /**
  46163. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46164. */
  46165. get axes(): IWebXRMotionControllerAxesValue;
  46166. /**
  46167. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46168. */
  46169. get changes(): IWebXRMotionControllerComponentChanges;
  46170. /**
  46171. * Return whether or not the component changed the last frame
  46172. */
  46173. get hasChanges(): boolean;
  46174. /**
  46175. * is the button currently pressed
  46176. */
  46177. get pressed(): boolean;
  46178. /**
  46179. * is the button currently touched
  46180. */
  46181. get touched(): boolean;
  46182. /**
  46183. * Get the current value of this component
  46184. */
  46185. get value(): number;
  46186. /**
  46187. * Dispose this component
  46188. */
  46189. dispose(): void;
  46190. /**
  46191. * Are there axes correlating to this component
  46192. * @return true is axes data is available
  46193. */
  46194. isAxes(): boolean;
  46195. /**
  46196. * Is this component a button (hence - pressable)
  46197. * @returns true if can be pressed
  46198. */
  46199. isButton(): boolean;
  46200. /**
  46201. * update this component using the gamepad object it is in. Called on every frame
  46202. * @param nativeController the native gamepad controller object
  46203. */
  46204. update(nativeController: IMinimalMotionControllerObject): void;
  46205. }
  46206. }
  46207. declare module BABYLON {
  46208. /**
  46209. * Class used to represent data loading progression
  46210. */
  46211. export class SceneLoaderProgressEvent {
  46212. /** defines if data length to load can be evaluated */
  46213. readonly lengthComputable: boolean;
  46214. /** defines the loaded data length */
  46215. readonly loaded: number;
  46216. /** defines the data length to load */
  46217. readonly total: number;
  46218. /**
  46219. * Create a new progress event
  46220. * @param lengthComputable defines if data length to load can be evaluated
  46221. * @param loaded defines the loaded data length
  46222. * @param total defines the data length to load
  46223. */
  46224. constructor(
  46225. /** defines if data length to load can be evaluated */
  46226. lengthComputable: boolean,
  46227. /** defines the loaded data length */
  46228. loaded: number,
  46229. /** defines the data length to load */
  46230. total: number);
  46231. /**
  46232. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46233. * @param event defines the source event
  46234. * @returns a new SceneLoaderProgressEvent
  46235. */
  46236. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46237. }
  46238. /**
  46239. * Interface used by SceneLoader plugins to define supported file extensions
  46240. */
  46241. export interface ISceneLoaderPluginExtensions {
  46242. /**
  46243. * Defines the list of supported extensions
  46244. */
  46245. [extension: string]: {
  46246. isBinary: boolean;
  46247. };
  46248. }
  46249. /**
  46250. * Interface used by SceneLoader plugin factory
  46251. */
  46252. export interface ISceneLoaderPluginFactory {
  46253. /**
  46254. * Defines the name of the factory
  46255. */
  46256. name: string;
  46257. /**
  46258. * Function called to create a new plugin
  46259. * @return the new plugin
  46260. */
  46261. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46262. /**
  46263. * The callback that returns true if the data can be directly loaded.
  46264. * @param data string containing the file data
  46265. * @returns if the data can be loaded directly
  46266. */
  46267. canDirectLoad?(data: string): boolean;
  46268. }
  46269. /**
  46270. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46271. */
  46272. export interface ISceneLoaderPluginBase {
  46273. /**
  46274. * The friendly name of this plugin.
  46275. */
  46276. name: string;
  46277. /**
  46278. * The file extensions supported by this plugin.
  46279. */
  46280. extensions: string | ISceneLoaderPluginExtensions;
  46281. /**
  46282. * The callback called when loading from a url.
  46283. * @param scene scene loading this url
  46284. * @param url url to load
  46285. * @param onSuccess callback called when the file successfully loads
  46286. * @param onProgress callback called while file is loading (if the server supports this mode)
  46287. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46288. * @param onError callback called when the file fails to load
  46289. * @returns a file request object
  46290. */
  46291. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46292. /**
  46293. * The callback called when loading from a file object.
  46294. * @param scene scene loading this file
  46295. * @param file defines the file to load
  46296. * @param onSuccess defines the callback to call when data is loaded
  46297. * @param onProgress defines the callback to call during loading process
  46298. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46299. * @param onError defines the callback to call when an error occurs
  46300. * @returns a file request object
  46301. */
  46302. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46303. /**
  46304. * The callback that returns true if the data can be directly loaded.
  46305. * @param data string containing the file data
  46306. * @returns if the data can be loaded directly
  46307. */
  46308. canDirectLoad?(data: string): boolean;
  46309. /**
  46310. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46311. * @param scene scene loading this data
  46312. * @param data string containing the data
  46313. * @returns data to pass to the plugin
  46314. */
  46315. directLoad?(scene: Scene, data: string): any;
  46316. /**
  46317. * The callback that allows custom handling of the root url based on the response url.
  46318. * @param rootUrl the original root url
  46319. * @param responseURL the response url if available
  46320. * @returns the new root url
  46321. */
  46322. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46323. }
  46324. /**
  46325. * Interface used to define a SceneLoader plugin
  46326. */
  46327. export interface ISceneLoaderPlugin 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 meshes The meshes array to import into
  46335. * @param particleSystems The particle systems array to import into
  46336. * @param skeletons The skeletons array to import into
  46337. * @param onError The callback when import fails
  46338. * @returns True if successful or false otherwise
  46339. */
  46340. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46341. /**
  46342. * Load into a scene.
  46343. * @param scene The scene to load into
  46344. * @param data The data to import
  46345. * @param rootUrl The root url for scene and resources
  46346. * @param onError The callback when import fails
  46347. * @returns True if successful or false otherwise
  46348. */
  46349. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46350. /**
  46351. * Load into an asset container.
  46352. * @param scene The scene to load into
  46353. * @param data The data to import
  46354. * @param rootUrl The root url for scene and resources
  46355. * @param onError The callback when import fails
  46356. * @returns The loaded asset container
  46357. */
  46358. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46359. }
  46360. /**
  46361. * Interface used to define an async SceneLoader plugin
  46362. */
  46363. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46364. /**
  46365. * Import meshes into a scene.
  46366. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46367. * @param scene The scene to import into
  46368. * @param data The data to import
  46369. * @param rootUrl The root url for scene and resources
  46370. * @param onProgress The callback when the load progresses
  46371. * @param fileName Defines the name of the file to load
  46372. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46373. */
  46374. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46375. meshes: AbstractMesh[];
  46376. particleSystems: IParticleSystem[];
  46377. skeletons: Skeleton[];
  46378. animationGroups: AnimationGroup[];
  46379. }>;
  46380. /**
  46381. * Load into a scene.
  46382. * @param scene The scene to load into
  46383. * @param data The data to import
  46384. * @param rootUrl The root url for scene and resources
  46385. * @param onProgress The callback when the load progresses
  46386. * @param fileName Defines the name of the file to load
  46387. * @returns Nothing
  46388. */
  46389. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46390. /**
  46391. * Load into an asset container.
  46392. * @param scene The scene to load into
  46393. * @param data The data to import
  46394. * @param rootUrl The root url for scene and resources
  46395. * @param onProgress The callback when the load progresses
  46396. * @param fileName Defines the name of the file to load
  46397. * @returns The loaded asset container
  46398. */
  46399. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46400. }
  46401. /**
  46402. * Mode that determines how to handle old animation groups before loading new ones.
  46403. */
  46404. export enum SceneLoaderAnimationGroupLoadingMode {
  46405. /**
  46406. * Reset all old animations to initial state then dispose them.
  46407. */
  46408. Clean = 0,
  46409. /**
  46410. * Stop all old animations.
  46411. */
  46412. Stop = 1,
  46413. /**
  46414. * Restart old animations from first frame.
  46415. */
  46416. Sync = 2,
  46417. /**
  46418. * Old animations remains untouched.
  46419. */
  46420. NoSync = 3
  46421. }
  46422. /**
  46423. * Class used to load scene from various file formats using registered plugins
  46424. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46425. */
  46426. export class SceneLoader {
  46427. /**
  46428. * No logging while loading
  46429. */
  46430. static readonly NO_LOGGING: number;
  46431. /**
  46432. * Minimal logging while loading
  46433. */
  46434. static readonly MINIMAL_LOGGING: number;
  46435. /**
  46436. * Summary logging while loading
  46437. */
  46438. static readonly SUMMARY_LOGGING: number;
  46439. /**
  46440. * Detailled logging while loading
  46441. */
  46442. static readonly DETAILED_LOGGING: number;
  46443. /**
  46444. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46445. */
  46446. static get ForceFullSceneLoadingForIncremental(): boolean;
  46447. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46448. /**
  46449. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46450. */
  46451. static get ShowLoadingScreen(): boolean;
  46452. static set ShowLoadingScreen(value: boolean);
  46453. /**
  46454. * Defines the current logging level (while loading the scene)
  46455. * @ignorenaming
  46456. */
  46457. static get loggingLevel(): number;
  46458. static set loggingLevel(value: number);
  46459. /**
  46460. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46461. */
  46462. static get CleanBoneMatrixWeights(): boolean;
  46463. static set CleanBoneMatrixWeights(value: boolean);
  46464. /**
  46465. * Event raised when a plugin is used to load a scene
  46466. */
  46467. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46468. private static _registeredPlugins;
  46469. private static _getDefaultPlugin;
  46470. private static _getPluginForExtension;
  46471. private static _getPluginForDirectLoad;
  46472. private static _getPluginForFilename;
  46473. private static _getDirectLoad;
  46474. private static _loadData;
  46475. private static _getFileInfo;
  46476. /**
  46477. * Gets a plugin that can load the given extension
  46478. * @param extension defines the extension to load
  46479. * @returns a plugin or null if none works
  46480. */
  46481. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46482. /**
  46483. * Gets a boolean indicating that the given extension can be loaded
  46484. * @param extension defines the extension to load
  46485. * @returns true if the extension is supported
  46486. */
  46487. static IsPluginForExtensionAvailable(extension: string): boolean;
  46488. /**
  46489. * Adds a new plugin to the list of registered plugins
  46490. * @param plugin defines the plugin to add
  46491. */
  46492. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46493. /**
  46494. * Import meshes into a scene
  46495. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46496. * @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)
  46497. * @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)
  46498. * @param scene the instance of BABYLON.Scene to append to
  46499. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46500. * @param onProgress a callback with a progress event for each file being loaded
  46501. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46502. * @param pluginExtension the extension used to determine the plugin
  46503. * @returns The loaded plugin
  46504. */
  46505. 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>;
  46506. /**
  46507. * Import meshes into a scene
  46508. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46509. * @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)
  46510. * @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)
  46511. * @param scene the instance of BABYLON.Scene to append to
  46512. * @param onProgress a callback with a progress event for each file being loaded
  46513. * @param pluginExtension the extension used to determine the plugin
  46514. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46515. */
  46516. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46517. meshes: AbstractMesh[];
  46518. particleSystems: IParticleSystem[];
  46519. skeletons: Skeleton[];
  46520. animationGroups: AnimationGroup[];
  46521. }>;
  46522. /**
  46523. * Load a scene
  46524. * @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)
  46525. * @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)
  46526. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46527. * @param onSuccess a callback with the scene when import succeeds
  46528. * @param onProgress a callback with a progress event for each file being loaded
  46529. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46530. * @param pluginExtension the extension used to determine the plugin
  46531. * @returns The loaded plugin
  46532. */
  46533. 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>;
  46534. /**
  46535. * Load a scene
  46536. * @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)
  46537. * @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)
  46538. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46539. * @param onProgress a callback with a progress event for each file being loaded
  46540. * @param pluginExtension the extension used to determine the plugin
  46541. * @returns The loaded scene
  46542. */
  46543. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46544. /**
  46545. * Append a scene
  46546. * @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)
  46547. * @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)
  46548. * @param scene is the instance of BABYLON.Scene to append to
  46549. * @param onSuccess a callback with the scene when import succeeds
  46550. * @param onProgress a callback with a progress event for each file being loaded
  46551. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46552. * @param pluginExtension the extension used to determine the plugin
  46553. * @returns The loaded plugin
  46554. */
  46555. 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>;
  46556. /**
  46557. * Append a scene
  46558. * @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)
  46559. * @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)
  46560. * @param scene is the instance of BABYLON.Scene to append to
  46561. * @param onProgress a callback with a progress event for each file being loaded
  46562. * @param pluginExtension the extension used to determine the plugin
  46563. * @returns The given scene
  46564. */
  46565. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46566. /**
  46567. * Load a scene into an asset container
  46568. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  46569. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  46570. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46571. * @param onSuccess a callback with the scene when import succeeds
  46572. * @param onProgress a callback with a progress event for each file being loaded
  46573. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46574. * @param pluginExtension the extension used to determine the plugin
  46575. * @returns The loaded plugin
  46576. */
  46577. 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>;
  46578. /**
  46579. * Load a scene into an asset container
  46580. * @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)
  46581. * @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)
  46582. * @param scene is the instance of Scene to append to
  46583. * @param onProgress a callback with a progress event for each file being loaded
  46584. * @param pluginExtension the extension used to determine the plugin
  46585. * @returns The loaded asset container
  46586. */
  46587. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46588. /**
  46589. * Import animations from a file into a scene
  46590. * @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)
  46591. * @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)
  46592. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46593. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46594. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46595. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46596. * @param onSuccess a callback with the scene when import succeeds
  46597. * @param onProgress a callback with a progress event for each file being loaded
  46598. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46599. */
  46600. 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;
  46601. /**
  46602. * Import animations from a file into a scene
  46603. * @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)
  46604. * @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)
  46605. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46606. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46607. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46608. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46609. * @param onSuccess a callback with the scene when import succeeds
  46610. * @param onProgress a callback with a progress event for each file being loaded
  46611. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46612. * @returns the updated scene with imported animations
  46613. */
  46614. 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>;
  46615. }
  46616. }
  46617. declare module BABYLON {
  46618. /**
  46619. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46620. */
  46621. export type MotionControllerHandedness = "none" | "left" | "right";
  46622. /**
  46623. * The type of components available in motion controllers.
  46624. * This is not the name of the component.
  46625. */
  46626. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46627. /**
  46628. * The state of a controller component
  46629. */
  46630. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46631. /**
  46632. * The schema of motion controller layout.
  46633. * No object will be initialized using this interface
  46634. * This is used just to define the profile.
  46635. */
  46636. export interface IMotionControllerLayout {
  46637. /**
  46638. * Path to load the assets. Usually relative to the base path
  46639. */
  46640. assetPath: string;
  46641. /**
  46642. * Available components (unsorted)
  46643. */
  46644. components: {
  46645. /**
  46646. * A map of component Ids
  46647. */
  46648. [componentId: string]: {
  46649. /**
  46650. * The type of input the component outputs
  46651. */
  46652. type: MotionControllerComponentType;
  46653. /**
  46654. * The indices of this component in the gamepad object
  46655. */
  46656. gamepadIndices: {
  46657. /**
  46658. * Index of button
  46659. */
  46660. button?: number;
  46661. /**
  46662. * If available, index of x-axis
  46663. */
  46664. xAxis?: number;
  46665. /**
  46666. * If available, index of y-axis
  46667. */
  46668. yAxis?: number;
  46669. };
  46670. /**
  46671. * The mesh's root node name
  46672. */
  46673. rootNodeName: string;
  46674. /**
  46675. * Animation definitions for this model
  46676. */
  46677. visualResponses: {
  46678. [stateKey: string]: {
  46679. /**
  46680. * What property will be animated
  46681. */
  46682. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46683. /**
  46684. * What states influence this visual response
  46685. */
  46686. states: MotionControllerComponentStateType[];
  46687. /**
  46688. * Type of animation - movement or visibility
  46689. */
  46690. valueNodeProperty: "transform" | "visibility";
  46691. /**
  46692. * Base node name to move. Its position will be calculated according to the min and max nodes
  46693. */
  46694. valueNodeName?: string;
  46695. /**
  46696. * Minimum movement node
  46697. */
  46698. minNodeName?: string;
  46699. /**
  46700. * Max movement node
  46701. */
  46702. maxNodeName?: string;
  46703. };
  46704. };
  46705. /**
  46706. * If touch enabled, what is the name of node to display user feedback
  46707. */
  46708. touchPointNodeName?: string;
  46709. };
  46710. };
  46711. /**
  46712. * Is it xr standard mapping or not
  46713. */
  46714. gamepadMapping: "" | "xr-standard";
  46715. /**
  46716. * Base root node of this entire model
  46717. */
  46718. rootNodeName: string;
  46719. /**
  46720. * Defines the main button component id
  46721. */
  46722. selectComponentId: string;
  46723. }
  46724. /**
  46725. * A definition for the layout map in the input profile
  46726. */
  46727. export interface IMotionControllerLayoutMap {
  46728. /**
  46729. * Layouts with handedness type as a key
  46730. */
  46731. [handedness: string]: IMotionControllerLayout;
  46732. }
  46733. /**
  46734. * The XR Input profile schema
  46735. * Profiles can be found here:
  46736. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  46737. */
  46738. export interface IMotionControllerProfile {
  46739. /**
  46740. * fallback profiles for this profileId
  46741. */
  46742. fallbackProfileIds: string[];
  46743. /**
  46744. * The layout map, with handedness as key
  46745. */
  46746. layouts: IMotionControllerLayoutMap;
  46747. /**
  46748. * The id of this profile
  46749. * correlates to the profile(s) in the xrInput.profiles array
  46750. */
  46751. profileId: string;
  46752. }
  46753. /**
  46754. * A helper-interface for the 3 meshes needed for controller button animation
  46755. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  46756. */
  46757. export interface IMotionControllerButtonMeshMap {
  46758. /**
  46759. * the mesh that defines the pressed value mesh position.
  46760. * This is used to find the max-position of this button
  46761. */
  46762. pressedMesh: AbstractMesh;
  46763. /**
  46764. * the mesh that defines the unpressed value mesh position.
  46765. * This is used to find the min (or initial) position of this button
  46766. */
  46767. unpressedMesh: AbstractMesh;
  46768. /**
  46769. * The mesh that will be changed when value changes
  46770. */
  46771. valueMesh: AbstractMesh;
  46772. }
  46773. /**
  46774. * A helper-interface for the 3 meshes needed for controller axis animation.
  46775. * This will be expanded when touchpad animations are fully supported
  46776. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  46777. */
  46778. export interface IMotionControllerMeshMap {
  46779. /**
  46780. * the mesh that defines the maximum value mesh position.
  46781. */
  46782. maxMesh?: AbstractMesh;
  46783. /**
  46784. * the mesh that defines the minimum value mesh position.
  46785. */
  46786. minMesh?: AbstractMesh;
  46787. /**
  46788. * The mesh that will be changed when axis value changes
  46789. */
  46790. valueMesh: AbstractMesh;
  46791. }
  46792. /**
  46793. * The elements needed for change-detection of the gamepad objects in motion controllers
  46794. */
  46795. export interface IMinimalMotionControllerObject {
  46796. /**
  46797. * Available axes of this controller
  46798. */
  46799. axes: number[];
  46800. /**
  46801. * An array of available buttons
  46802. */
  46803. buttons: Array<{
  46804. /**
  46805. * Value of the button/trigger
  46806. */
  46807. value: number;
  46808. /**
  46809. * If the button/trigger is currently touched
  46810. */
  46811. touched: boolean;
  46812. /**
  46813. * If the button/trigger is currently pressed
  46814. */
  46815. pressed: boolean;
  46816. }>;
  46817. /**
  46818. * EXPERIMENTAL haptic support.
  46819. */
  46820. hapticActuators?: Array<{
  46821. pulse: (value: number, duration: number) => Promise<boolean>;
  46822. }>;
  46823. }
  46824. /**
  46825. * An Abstract Motion controller
  46826. * This class receives an xrInput and a profile layout and uses those to initialize the components
  46827. * Each component has an observable to check for changes in value and state
  46828. */
  46829. export abstract class WebXRAbstractMotionController implements IDisposable {
  46830. protected scene: Scene;
  46831. protected layout: IMotionControllerLayout;
  46832. /**
  46833. * The gamepad object correlating to this controller
  46834. */
  46835. gamepadObject: IMinimalMotionControllerObject;
  46836. /**
  46837. * handedness (left/right/none) of this controller
  46838. */
  46839. handedness: MotionControllerHandedness;
  46840. private _initComponent;
  46841. private _modelReady;
  46842. /**
  46843. * A map of components (WebXRControllerComponent) in this motion controller
  46844. * Components have a ComponentType and can also have both button and axis definitions
  46845. */
  46846. readonly components: {
  46847. [id: string]: WebXRControllerComponent;
  46848. };
  46849. /**
  46850. * Disable the model's animation. Can be set at any time.
  46851. */
  46852. disableAnimation: boolean;
  46853. /**
  46854. * Observers registered here will be triggered when the model of this controller is done loading
  46855. */
  46856. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  46857. /**
  46858. * The profile id of this motion controller
  46859. */
  46860. abstract profileId: string;
  46861. /**
  46862. * The root mesh of the model. It is null if the model was not yet initialized
  46863. */
  46864. rootMesh: Nullable<AbstractMesh>;
  46865. /**
  46866. * constructs a new abstract motion controller
  46867. * @param scene the scene to which the model of the controller will be added
  46868. * @param layout The profile layout to load
  46869. * @param gamepadObject The gamepad object correlating to this controller
  46870. * @param handedness handedness (left/right/none) of this controller
  46871. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  46872. */
  46873. constructor(scene: Scene, layout: IMotionControllerLayout,
  46874. /**
  46875. * The gamepad object correlating to this controller
  46876. */
  46877. gamepadObject: IMinimalMotionControllerObject,
  46878. /**
  46879. * handedness (left/right/none) of this controller
  46880. */
  46881. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  46882. /**
  46883. * Dispose this controller, the model mesh and all its components
  46884. */
  46885. dispose(): void;
  46886. /**
  46887. * Returns all components of specific type
  46888. * @param type the type to search for
  46889. * @return an array of components with this type
  46890. */
  46891. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  46892. /**
  46893. * get a component based an its component id as defined in layout.components
  46894. * @param id the id of the component
  46895. * @returns the component correlates to the id or undefined if not found
  46896. */
  46897. getComponent(id: string): WebXRControllerComponent;
  46898. /**
  46899. * Get the list of components available in this motion controller
  46900. * @returns an array of strings correlating to available components
  46901. */
  46902. getComponentIds(): string[];
  46903. /**
  46904. * Get the first component of specific type
  46905. * @param type type of component to find
  46906. * @return a controller component or null if not found
  46907. */
  46908. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  46909. /**
  46910. * Get the main (Select) component of this controller as defined in the layout
  46911. * @returns the main component of this controller
  46912. */
  46913. getMainComponent(): WebXRControllerComponent;
  46914. /**
  46915. * Loads the model correlating to this controller
  46916. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  46917. * @returns A promise fulfilled with the result of the model loading
  46918. */
  46919. loadModel(): Promise<boolean>;
  46920. /**
  46921. * Update this model using the current XRFrame
  46922. * @param xrFrame the current xr frame to use and update the model
  46923. */
  46924. updateFromXRFrame(xrFrame: XRFrame): void;
  46925. /**
  46926. * Backwards compatibility due to a deeply-integrated typo
  46927. */
  46928. get handness(): XREye;
  46929. /**
  46930. * Pulse (vibrate) this controller
  46931. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  46932. * Consecutive calls to this function will cancel the last pulse call
  46933. *
  46934. * @param value the strength of the pulse in 0.0...1.0 range
  46935. * @param duration Duration of the pulse in milliseconds
  46936. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  46937. * @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
  46938. */
  46939. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  46940. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46941. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46942. /**
  46943. * Moves the axis on the controller mesh based on its current state
  46944. * @param axis the index of the axis
  46945. * @param axisValue the value of the axis which determines the meshes new position
  46946. * @hidden
  46947. */
  46948. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  46949. /**
  46950. * Update the model itself with the current frame data
  46951. * @param xrFrame the frame to use for updating the model mesh
  46952. */
  46953. protected updateModel(xrFrame: XRFrame): void;
  46954. /**
  46955. * Get the filename and path for this controller's model
  46956. * @returns a map of filename and path
  46957. */
  46958. protected abstract _getFilenameAndPath(): {
  46959. filename: string;
  46960. path: string;
  46961. };
  46962. /**
  46963. * This function is called before the mesh is loaded. It checks for loading constraints.
  46964. * For example, this function can check if the GLB loader is available
  46965. * If this function returns false, the generic controller will be loaded instead
  46966. * @returns Is the client ready to load the mesh
  46967. */
  46968. protected abstract _getModelLoadingConstraints(): boolean;
  46969. /**
  46970. * This function will be called after the model was successfully loaded and can be used
  46971. * for mesh transformations before it is available for the user
  46972. * @param meshes the loaded meshes
  46973. */
  46974. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  46975. /**
  46976. * Set the root mesh for this controller. Important for the WebXR controller class
  46977. * @param meshes the loaded meshes
  46978. */
  46979. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  46980. /**
  46981. * A function executed each frame that updates the mesh (if needed)
  46982. * @param xrFrame the current xrFrame
  46983. */
  46984. protected abstract _updateModel(xrFrame: XRFrame): void;
  46985. private _getGenericFilenameAndPath;
  46986. private _getGenericParentMesh;
  46987. }
  46988. }
  46989. declare module BABYLON {
  46990. /**
  46991. * A generic trigger-only motion controller for WebXR
  46992. */
  46993. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  46994. /**
  46995. * Static version of the profile id of this controller
  46996. */
  46997. static ProfileId: string;
  46998. profileId: string;
  46999. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47000. protected _getFilenameAndPath(): {
  47001. filename: string;
  47002. path: string;
  47003. };
  47004. protected _getModelLoadingConstraints(): boolean;
  47005. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47006. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47007. protected _updateModel(): void;
  47008. }
  47009. }
  47010. declare module BABYLON {
  47011. /**
  47012. * Class containing static functions to help procedurally build meshes
  47013. */
  47014. export class SphereBuilder {
  47015. /**
  47016. * Creates a sphere mesh
  47017. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47018. * * 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`)
  47019. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47020. * * 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
  47021. * * 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)
  47022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47023. * * 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
  47024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47025. * @param name defines the name of the mesh
  47026. * @param options defines the options used to create the mesh
  47027. * @param scene defines the hosting scene
  47028. * @returns the sphere mesh
  47029. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47030. */
  47031. static CreateSphere(name: string, options: {
  47032. segments?: number;
  47033. diameter?: number;
  47034. diameterX?: number;
  47035. diameterY?: number;
  47036. diameterZ?: number;
  47037. arc?: number;
  47038. slice?: number;
  47039. sideOrientation?: number;
  47040. frontUVs?: Vector4;
  47041. backUVs?: Vector4;
  47042. updatable?: boolean;
  47043. }, scene?: Nullable<Scene>): Mesh;
  47044. }
  47045. }
  47046. declare module BABYLON {
  47047. /**
  47048. * A profiled motion controller has its profile loaded from an online repository.
  47049. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47050. */
  47051. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47052. private _repositoryUrl;
  47053. private _buttonMeshMapping;
  47054. private _touchDots;
  47055. /**
  47056. * The profile ID of this controller. Will be populated when the controller initializes.
  47057. */
  47058. profileId: string;
  47059. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47060. dispose(): void;
  47061. protected _getFilenameAndPath(): {
  47062. filename: string;
  47063. path: string;
  47064. };
  47065. protected _getModelLoadingConstraints(): boolean;
  47066. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47067. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47068. protected _updateModel(_xrFrame: XRFrame): void;
  47069. }
  47070. }
  47071. declare module BABYLON {
  47072. /**
  47073. * A construction function type to create a new controller based on an xrInput object
  47074. */
  47075. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47076. /**
  47077. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47078. *
  47079. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47080. * it should be replaced with auto-loaded controllers.
  47081. *
  47082. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47083. */
  47084. export class WebXRMotionControllerManager {
  47085. private static _AvailableControllers;
  47086. private static _Fallbacks;
  47087. private static _ProfileLoadingPromises;
  47088. private static _ProfilesList;
  47089. /**
  47090. * The base URL of the online controller repository. Can be changed at any time.
  47091. */
  47092. static BaseRepositoryUrl: string;
  47093. /**
  47094. * Which repository gets priority - local or online
  47095. */
  47096. static PrioritizeOnlineRepository: boolean;
  47097. /**
  47098. * Use the online repository, or use only locally-defined controllers
  47099. */
  47100. static UseOnlineRepository: boolean;
  47101. /**
  47102. * Clear the cache used for profile loading and reload when requested again
  47103. */
  47104. static ClearProfilesCache(): void;
  47105. /**
  47106. * Register the default fallbacks.
  47107. * This function is called automatically when this file is imported.
  47108. */
  47109. static DefaultFallbacks(): void;
  47110. /**
  47111. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47112. * @param profileId the profile to which a fallback needs to be found
  47113. * @return an array with corresponding fallback profiles
  47114. */
  47115. static FindFallbackWithProfileId(profileId: string): string[];
  47116. /**
  47117. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47118. * The order of search:
  47119. *
  47120. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47121. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47122. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47123. * 4) return the generic trigger controller if none were found
  47124. *
  47125. * @param xrInput the xrInput to which a new controller is initialized
  47126. * @param scene the scene to which the model will be added
  47127. * @param forceProfile force a certain profile for this controller
  47128. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47129. */
  47130. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47131. /**
  47132. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47133. *
  47134. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47135. *
  47136. * @param type the profile type to register
  47137. * @param constructFunction the function to be called when loading this profile
  47138. */
  47139. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47140. /**
  47141. * Register a fallback to a specific profile.
  47142. * @param profileId the profileId that will receive the fallbacks
  47143. * @param fallbacks A list of fallback profiles
  47144. */
  47145. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47146. /**
  47147. * Will update the list of profiles available in the repository
  47148. * @return a promise that resolves to a map of profiles available online
  47149. */
  47150. static UpdateProfilesList(): Promise<{
  47151. [profile: string]: string;
  47152. }>;
  47153. private static _LoadProfileFromRepository;
  47154. private static _LoadProfilesFromAvailableControllers;
  47155. }
  47156. }
  47157. declare module BABYLON {
  47158. /**
  47159. * Configuration options for the WebXR controller creation
  47160. */
  47161. export interface IWebXRControllerOptions {
  47162. /**
  47163. * Should the controller mesh be animated when a user interacts with it
  47164. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47165. */
  47166. disableMotionControllerAnimation?: boolean;
  47167. /**
  47168. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47169. */
  47170. doNotLoadControllerMesh?: boolean;
  47171. /**
  47172. * Force a specific controller type for this controller.
  47173. * This can be used when creating your own profile or when testing different controllers
  47174. */
  47175. forceControllerProfile?: string;
  47176. /**
  47177. * Defines a rendering group ID for meshes that will be loaded.
  47178. * This is for the default controllers only.
  47179. */
  47180. renderingGroupId?: number;
  47181. }
  47182. /**
  47183. * Represents an XR controller
  47184. */
  47185. export class WebXRInputSource {
  47186. private _scene;
  47187. /** The underlying input source for the controller */
  47188. inputSource: XRInputSource;
  47189. private _options;
  47190. private _tmpVector;
  47191. private _uniqueId;
  47192. /**
  47193. * 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
  47194. */
  47195. grip?: AbstractMesh;
  47196. /**
  47197. * If available, this is the gamepad object related to this controller.
  47198. * Using this object it is possible to get click events and trackpad changes of the
  47199. * webxr controller that is currently being used.
  47200. */
  47201. motionController?: WebXRAbstractMotionController;
  47202. /**
  47203. * Event that fires when the controller is removed/disposed.
  47204. * The object provided as event data is this controller, after associated assets were disposed.
  47205. * uniqueId is still available.
  47206. */
  47207. onDisposeObservable: Observable<WebXRInputSource>;
  47208. /**
  47209. * Will be triggered when the mesh associated with the motion controller is done loading.
  47210. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47211. * A shortened version of controller -> motion controller -> on mesh loaded.
  47212. */
  47213. onMeshLoadedObservable: Observable<AbstractMesh>;
  47214. /**
  47215. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47216. */
  47217. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47218. /**
  47219. * Pointer which can be used to select objects or attach a visible laser to
  47220. */
  47221. pointer: AbstractMesh;
  47222. /**
  47223. * Creates the controller
  47224. * @see https://doc.babylonjs.com/how_to/webxr
  47225. * @param _scene the scene which the controller should be associated to
  47226. * @param inputSource the underlying input source for the controller
  47227. * @param _options options for this controller creation
  47228. */
  47229. constructor(_scene: Scene,
  47230. /** The underlying input source for the controller */
  47231. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47232. /**
  47233. * Get this controllers unique id
  47234. */
  47235. get uniqueId(): string;
  47236. /**
  47237. * Disposes of the object
  47238. */
  47239. dispose(): void;
  47240. /**
  47241. * Gets a world space ray coming from the pointer or grip
  47242. * @param result the resulting ray
  47243. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47244. */
  47245. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47246. /**
  47247. * Updates the controller pose based on the given XRFrame
  47248. * @param xrFrame xr frame to update the pose with
  47249. * @param referenceSpace reference space to use
  47250. */
  47251. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47252. }
  47253. }
  47254. declare module BABYLON {
  47255. /**
  47256. * The schema for initialization options of the XR Input class
  47257. */
  47258. export interface IWebXRInputOptions {
  47259. /**
  47260. * If set to true no model will be automatically loaded
  47261. */
  47262. doNotLoadControllerMeshes?: boolean;
  47263. /**
  47264. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47265. * If not found, the xr input profile data will be used.
  47266. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47267. */
  47268. forceInputProfile?: string;
  47269. /**
  47270. * Do not send a request to the controller repository to load the profile.
  47271. *
  47272. * Instead, use the controllers available in babylon itself.
  47273. */
  47274. disableOnlineControllerRepository?: boolean;
  47275. /**
  47276. * A custom URL for the controllers repository
  47277. */
  47278. customControllersRepositoryURL?: string;
  47279. /**
  47280. * Should the controller model's components not move according to the user input
  47281. */
  47282. disableControllerAnimation?: boolean;
  47283. /**
  47284. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47285. */
  47286. controllerOptions?: IWebXRControllerOptions;
  47287. }
  47288. /**
  47289. * XR input used to track XR inputs such as controllers/rays
  47290. */
  47291. export class WebXRInput implements IDisposable {
  47292. /**
  47293. * the xr session manager for this session
  47294. */
  47295. xrSessionManager: WebXRSessionManager;
  47296. /**
  47297. * the WebXR camera for this session. Mainly used for teleportation
  47298. */
  47299. xrCamera: WebXRCamera;
  47300. private readonly options;
  47301. /**
  47302. * XR controllers being tracked
  47303. */
  47304. controllers: Array<WebXRInputSource>;
  47305. private _frameObserver;
  47306. private _sessionEndedObserver;
  47307. private _sessionInitObserver;
  47308. /**
  47309. * Event when a controller has been connected/added
  47310. */
  47311. onControllerAddedObservable: Observable<WebXRInputSource>;
  47312. /**
  47313. * Event when a controller has been removed/disconnected
  47314. */
  47315. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47316. /**
  47317. * Initializes the WebXRInput
  47318. * @param xrSessionManager the xr session manager for this session
  47319. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47320. * @param options = initialization options for this xr input
  47321. */
  47322. constructor(
  47323. /**
  47324. * the xr session manager for this session
  47325. */
  47326. xrSessionManager: WebXRSessionManager,
  47327. /**
  47328. * the WebXR camera for this session. Mainly used for teleportation
  47329. */
  47330. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47331. private _onInputSourcesChange;
  47332. private _addAndRemoveControllers;
  47333. /**
  47334. * Disposes of the object
  47335. */
  47336. dispose(): void;
  47337. }
  47338. }
  47339. declare module BABYLON {
  47340. /**
  47341. * This is the base class for all WebXR features.
  47342. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47343. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47344. */
  47345. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47346. protected _xrSessionManager: WebXRSessionManager;
  47347. private _attached;
  47348. private _removeOnDetach;
  47349. /**
  47350. * Should auto-attach be disabled?
  47351. */
  47352. disableAutoAttach: boolean;
  47353. /**
  47354. * Construct a new (abstract) WebXR feature
  47355. * @param _xrSessionManager the xr session manager for this feature
  47356. */
  47357. constructor(_xrSessionManager: WebXRSessionManager);
  47358. /**
  47359. * Is this feature attached
  47360. */
  47361. get attached(): boolean;
  47362. /**
  47363. * attach this feature
  47364. *
  47365. * @param force should attachment be forced (even when already attached)
  47366. * @returns true if successful, false is failed or already attached
  47367. */
  47368. attach(force?: boolean): boolean;
  47369. /**
  47370. * detach this feature.
  47371. *
  47372. * @returns true if successful, false if failed or already detached
  47373. */
  47374. detach(): boolean;
  47375. /**
  47376. * Dispose this feature and all of the resources attached
  47377. */
  47378. dispose(): void;
  47379. /**
  47380. * This is used to register callbacks that will automatically be removed when detach is called.
  47381. * @param observable the observable to which the observer will be attached
  47382. * @param callback the callback to register
  47383. */
  47384. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47385. /**
  47386. * Code in this function will be executed on each xrFrame received from the browser.
  47387. * This function will not execute after the feature is detached.
  47388. * @param _xrFrame the current frame
  47389. */
  47390. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47391. }
  47392. }
  47393. declare module BABYLON {
  47394. /**
  47395. * Renders a layer on top of an existing scene
  47396. */
  47397. export class UtilityLayerRenderer implements IDisposable {
  47398. /** the original scene that will be rendered on top of */
  47399. originalScene: Scene;
  47400. private _pointerCaptures;
  47401. private _lastPointerEvents;
  47402. private static _DefaultUtilityLayer;
  47403. private static _DefaultKeepDepthUtilityLayer;
  47404. private _sharedGizmoLight;
  47405. private _renderCamera;
  47406. /**
  47407. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47408. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47409. * @returns the camera that is used when rendering the utility layer
  47410. */
  47411. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47412. /**
  47413. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47414. * @param cam the camera that should be used when rendering the utility layer
  47415. */
  47416. setRenderCamera(cam: Nullable<Camera>): void;
  47417. /**
  47418. * @hidden
  47419. * Light which used by gizmos to get light shading
  47420. */
  47421. _getSharedGizmoLight(): HemisphericLight;
  47422. /**
  47423. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47424. */
  47425. pickUtilitySceneFirst: boolean;
  47426. /**
  47427. * 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)
  47428. */
  47429. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47430. /**
  47431. * 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)
  47432. */
  47433. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47434. /**
  47435. * The scene that is rendered on top of the original scene
  47436. */
  47437. utilityLayerScene: Scene;
  47438. /**
  47439. * If the utility layer should automatically be rendered on top of existing scene
  47440. */
  47441. shouldRender: boolean;
  47442. /**
  47443. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47444. */
  47445. onlyCheckPointerDownEvents: boolean;
  47446. /**
  47447. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47448. */
  47449. processAllEvents: boolean;
  47450. /**
  47451. * Observable raised when the pointer move from the utility layer scene to the main scene
  47452. */
  47453. onPointerOutObservable: Observable<number>;
  47454. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47455. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47456. private _afterRenderObserver;
  47457. private _sceneDisposeObserver;
  47458. private _originalPointerObserver;
  47459. /**
  47460. * Instantiates a UtilityLayerRenderer
  47461. * @param originalScene the original scene that will be rendered on top of
  47462. * @param handleEvents boolean indicating if the utility layer should handle events
  47463. */
  47464. constructor(
  47465. /** the original scene that will be rendered on top of */
  47466. originalScene: Scene, handleEvents?: boolean);
  47467. private _notifyObservers;
  47468. /**
  47469. * Renders the utility layers scene on top of the original scene
  47470. */
  47471. render(): void;
  47472. /**
  47473. * Disposes of the renderer
  47474. */
  47475. dispose(): void;
  47476. private _updateCamera;
  47477. }
  47478. }
  47479. declare module BABYLON {
  47480. /**
  47481. * Options interface for the pointer selection module
  47482. */
  47483. export interface IWebXRControllerPointerSelectionOptions {
  47484. /**
  47485. * if provided, this scene will be used to render meshes.
  47486. */
  47487. customUtilityLayerScene?: Scene;
  47488. /**
  47489. * 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)
  47490. * If not disabled, the last picked point will be used to execute a pointer up event
  47491. * If disabled, pointer up event will be triggered right after the pointer down event.
  47492. * Used in screen and gaze target ray mode only
  47493. */
  47494. disablePointerUpOnTouchOut: boolean;
  47495. /**
  47496. * For gaze mode (time to select instead of press)
  47497. */
  47498. forceGazeMode: boolean;
  47499. /**
  47500. * 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
  47501. * to start a new countdown to the pointer down event.
  47502. * Defaults to 1.
  47503. */
  47504. gazeModePointerMovedFactor?: number;
  47505. /**
  47506. * Different button type to use instead of the main component
  47507. */
  47508. overrideButtonId?: string;
  47509. /**
  47510. * use this rendering group id for the meshes (optional)
  47511. */
  47512. renderingGroupId?: number;
  47513. /**
  47514. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47515. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47516. * 3000 means 3 seconds between pointing at something and selecting it
  47517. */
  47518. timeToSelect?: number;
  47519. /**
  47520. * Should meshes created here be added to a utility layer or the main scene
  47521. */
  47522. useUtilityLayer?: boolean;
  47523. /**
  47524. * the xr input to use with this pointer selection
  47525. */
  47526. xrInput: WebXRInput;
  47527. }
  47528. /**
  47529. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47530. */
  47531. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47532. private readonly _options;
  47533. private static _idCounter;
  47534. private _attachController;
  47535. private _controllers;
  47536. private _scene;
  47537. private _tmpVectorForPickCompare;
  47538. /**
  47539. * The module's name
  47540. */
  47541. static readonly Name: string;
  47542. /**
  47543. * The (Babylon) version of this module.
  47544. * This is an integer representing the implementation version.
  47545. * This number does not correspond to the WebXR specs version
  47546. */
  47547. static readonly Version: number;
  47548. /**
  47549. * Disable lighting on the laser pointer (so it will always be visible)
  47550. */
  47551. disablePointerLighting: boolean;
  47552. /**
  47553. * Disable lighting on the selection mesh (so it will always be visible)
  47554. */
  47555. disableSelectionMeshLighting: boolean;
  47556. /**
  47557. * Should the laser pointer be displayed
  47558. */
  47559. displayLaserPointer: boolean;
  47560. /**
  47561. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47562. */
  47563. displaySelectionMesh: boolean;
  47564. /**
  47565. * This color will be set to the laser pointer when selection is triggered
  47566. */
  47567. laserPointerPickedColor: Color3;
  47568. /**
  47569. * Default color of the laser pointer
  47570. */
  47571. lasterPointerDefaultColor: Color3;
  47572. /**
  47573. * default color of the selection ring
  47574. */
  47575. selectionMeshDefaultColor: Color3;
  47576. /**
  47577. * This color will be applied to the selection ring when selection is triggered
  47578. */
  47579. selectionMeshPickedColor: Color3;
  47580. /**
  47581. * Optional filter to be used for ray selection. This predicate shares behavior with
  47582. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47583. */
  47584. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47585. /**
  47586. * constructs a new background remover module
  47587. * @param _xrSessionManager the session manager for this module
  47588. * @param _options read-only options to be used in this module
  47589. */
  47590. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47591. /**
  47592. * attach this feature
  47593. * Will usually be called by the features manager
  47594. *
  47595. * @returns true if successful.
  47596. */
  47597. attach(): boolean;
  47598. /**
  47599. * detach this feature.
  47600. * Will usually be called by the features manager
  47601. *
  47602. * @returns true if successful.
  47603. */
  47604. detach(): boolean;
  47605. /**
  47606. * Will get the mesh under a specific pointer.
  47607. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47608. * @param controllerId the controllerId to check
  47609. * @returns The mesh under pointer or null if no mesh is under the pointer
  47610. */
  47611. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47612. /**
  47613. * Get the xr controller that correlates to the pointer id in the pointer event
  47614. *
  47615. * @param id the pointer id to search for
  47616. * @returns the controller that correlates to this id or null if not found
  47617. */
  47618. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47619. protected _onXRFrame(_xrFrame: XRFrame): void;
  47620. private _attachGazeMode;
  47621. private _attachScreenRayMode;
  47622. private _attachTrackedPointerRayMode;
  47623. private _convertNormalToDirectionOfRay;
  47624. private _detachController;
  47625. private _generateNewMeshPair;
  47626. private _pickingMoved;
  47627. private _updatePointerDistance;
  47628. }
  47629. }
  47630. declare module BABYLON {
  47631. /**
  47632. * Button which can be used to enter a different mode of XR
  47633. */
  47634. export class WebXREnterExitUIButton {
  47635. /** button element */
  47636. element: HTMLElement;
  47637. /** XR initialization options for the button */
  47638. sessionMode: XRSessionMode;
  47639. /** Reference space type */
  47640. referenceSpaceType: XRReferenceSpaceType;
  47641. /**
  47642. * Creates a WebXREnterExitUIButton
  47643. * @param element button element
  47644. * @param sessionMode XR initialization session mode
  47645. * @param referenceSpaceType the type of reference space to be used
  47646. */
  47647. constructor(
  47648. /** button element */
  47649. element: HTMLElement,
  47650. /** XR initialization options for the button */
  47651. sessionMode: XRSessionMode,
  47652. /** Reference space type */
  47653. referenceSpaceType: XRReferenceSpaceType);
  47654. /**
  47655. * Extendable function which can be used to update the button's visuals when the state changes
  47656. * @param activeButton the current active button in the UI
  47657. */
  47658. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47659. }
  47660. /**
  47661. * Options to create the webXR UI
  47662. */
  47663. export class WebXREnterExitUIOptions {
  47664. /**
  47665. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47666. */
  47667. customButtons?: Array<WebXREnterExitUIButton>;
  47668. /**
  47669. * A reference space type to use when creating the default button.
  47670. * Default is local-floor
  47671. */
  47672. referenceSpaceType?: XRReferenceSpaceType;
  47673. /**
  47674. * Context to enter xr with
  47675. */
  47676. renderTarget?: Nullable<WebXRRenderTarget>;
  47677. /**
  47678. * A session mode to use when creating the default button.
  47679. * Default is immersive-vr
  47680. */
  47681. sessionMode?: XRSessionMode;
  47682. /**
  47683. * A list of optional features to init the session with
  47684. */
  47685. optionalFeatures?: string[];
  47686. }
  47687. /**
  47688. * UI to allow the user to enter/exit XR mode
  47689. */
  47690. export class WebXREnterExitUI implements IDisposable {
  47691. private scene;
  47692. /** version of the options passed to this UI */
  47693. options: WebXREnterExitUIOptions;
  47694. private _activeButton;
  47695. private _buttons;
  47696. private _overlay;
  47697. /**
  47698. * Fired every time the active button is changed.
  47699. *
  47700. * When xr is entered via a button that launches xr that button will be the callback parameter
  47701. *
  47702. * When exiting xr the callback parameter will be null)
  47703. */
  47704. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  47705. /**
  47706. *
  47707. * @param scene babylon scene object to use
  47708. * @param options (read-only) version of the options passed to this UI
  47709. */
  47710. private constructor();
  47711. /**
  47712. * Creates UI to allow the user to enter/exit XR mode
  47713. * @param scene the scene to add the ui to
  47714. * @param helper the xr experience helper to enter/exit xr with
  47715. * @param options options to configure the UI
  47716. * @returns the created ui
  47717. */
  47718. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  47719. /**
  47720. * Disposes of the XR UI component
  47721. */
  47722. dispose(): void;
  47723. private _updateButtons;
  47724. }
  47725. }
  47726. declare module BABYLON {
  47727. /**
  47728. * Class containing static functions to help procedurally build meshes
  47729. */
  47730. export class LinesBuilder {
  47731. /**
  47732. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47733. * * 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
  47734. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47735. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47736. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47737. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47738. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47739. * * 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
  47740. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47742. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47743. * @param name defines the name of the new line system
  47744. * @param options defines the options used to create the line system
  47745. * @param scene defines the hosting scene
  47746. * @returns a new line system mesh
  47747. */
  47748. static CreateLineSystem(name: string, options: {
  47749. lines: Vector3[][];
  47750. updatable?: boolean;
  47751. instance?: Nullable<LinesMesh>;
  47752. colors?: Nullable<Color4[][]>;
  47753. useVertexAlpha?: boolean;
  47754. }, scene: Nullable<Scene>): LinesMesh;
  47755. /**
  47756. * Creates a line mesh
  47757. * 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
  47758. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47759. * * The parameter `points` is an array successive Vector3
  47760. * * 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
  47761. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47762. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47763. * * When updating an instance, remember that only point positions can change, not the number of points
  47764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47765. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47766. * @param name defines the name of the new line system
  47767. * @param options defines the options used to create the line system
  47768. * @param scene defines the hosting scene
  47769. * @returns a new line mesh
  47770. */
  47771. static CreateLines(name: string, options: {
  47772. points: Vector3[];
  47773. updatable?: boolean;
  47774. instance?: Nullable<LinesMesh>;
  47775. colors?: Color4[];
  47776. useVertexAlpha?: boolean;
  47777. }, scene?: Nullable<Scene>): LinesMesh;
  47778. /**
  47779. * Creates a dashed line mesh
  47780. * * 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
  47781. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47782. * * The parameter `points` is an array successive Vector3
  47783. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47784. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47785. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47786. * * 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
  47787. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47788. * * When updating an instance, remember that only point positions can change, not the number of points
  47789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47790. * @param name defines the name of the mesh
  47791. * @param options defines the options used to create the mesh
  47792. * @param scene defines the hosting scene
  47793. * @returns the dashed line mesh
  47794. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47795. */
  47796. static CreateDashedLines(name: string, options: {
  47797. points: Vector3[];
  47798. dashSize?: number;
  47799. gapSize?: number;
  47800. dashNb?: number;
  47801. updatable?: boolean;
  47802. instance?: LinesMesh;
  47803. useVertexAlpha?: boolean;
  47804. }, scene?: Nullable<Scene>): LinesMesh;
  47805. }
  47806. }
  47807. declare module BABYLON {
  47808. /**
  47809. * The options container for the teleportation module
  47810. */
  47811. export interface IWebXRTeleportationOptions {
  47812. /**
  47813. * if provided, this scene will be used to render meshes.
  47814. */
  47815. customUtilityLayerScene?: Scene;
  47816. /**
  47817. * Values to configure the default target mesh
  47818. */
  47819. defaultTargetMeshOptions?: {
  47820. /**
  47821. * Fill color of the teleportation area
  47822. */
  47823. teleportationFillColor?: string;
  47824. /**
  47825. * Border color for the teleportation area
  47826. */
  47827. teleportationBorderColor?: string;
  47828. /**
  47829. * Disable the mesh's animation sequence
  47830. */
  47831. disableAnimation?: boolean;
  47832. /**
  47833. * Disable lighting on the material or the ring and arrow
  47834. */
  47835. disableLighting?: boolean;
  47836. /**
  47837. * Override the default material of the torus and arrow
  47838. */
  47839. torusArrowMaterial?: Material;
  47840. };
  47841. /**
  47842. * A list of meshes to use as floor meshes.
  47843. * Meshes can be added and removed after initializing the feature using the
  47844. * addFloorMesh and removeFloorMesh functions
  47845. * If empty, rotation will still work
  47846. */
  47847. floorMeshes?: AbstractMesh[];
  47848. /**
  47849. * use this rendering group id for the meshes (optional)
  47850. */
  47851. renderingGroupId?: number;
  47852. /**
  47853. * Should teleportation move only to snap points
  47854. */
  47855. snapPointsOnly?: boolean;
  47856. /**
  47857. * An array of points to which the teleportation will snap to.
  47858. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  47859. */
  47860. snapPositions?: Vector3[];
  47861. /**
  47862. * How close should the teleportation ray be in order to snap to position.
  47863. * Default to 0.8 units (meters)
  47864. */
  47865. snapToPositionRadius?: number;
  47866. /**
  47867. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  47868. * If you want to support rotation, make sure your mesh has a direction indicator.
  47869. *
  47870. * When left untouched, the default mesh will be initialized.
  47871. */
  47872. teleportationTargetMesh?: AbstractMesh;
  47873. /**
  47874. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  47875. */
  47876. timeToTeleport?: number;
  47877. /**
  47878. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  47879. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  47880. */
  47881. useMainComponentOnly?: boolean;
  47882. /**
  47883. * Should meshes created here be added to a utility layer or the main scene
  47884. */
  47885. useUtilityLayer?: boolean;
  47886. /**
  47887. * Babylon XR Input class for controller
  47888. */
  47889. xrInput: WebXRInput;
  47890. }
  47891. /**
  47892. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47893. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47894. * the input of the attached controllers.
  47895. */
  47896. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47897. private _options;
  47898. private _controllers;
  47899. private _currentTeleportationControllerId;
  47900. private _floorMeshes;
  47901. private _quadraticBezierCurve;
  47902. private _selectionFeature;
  47903. private _snapToPositions;
  47904. private _snappedToPoint;
  47905. private _teleportationRingMaterial?;
  47906. private _tmpRay;
  47907. private _tmpVector;
  47908. /**
  47909. * The module's name
  47910. */
  47911. static readonly Name: string;
  47912. /**
  47913. * The (Babylon) version of this module.
  47914. * This is an integer representing the implementation version.
  47915. * This number does not correspond to the webxr specs version
  47916. */
  47917. static readonly Version: number;
  47918. /**
  47919. * Is movement backwards enabled
  47920. */
  47921. backwardsMovementEnabled: boolean;
  47922. /**
  47923. * Distance to travel when moving backwards
  47924. */
  47925. backwardsTeleportationDistance: number;
  47926. /**
  47927. * The distance from the user to the inspection point in the direction of the controller
  47928. * A higher number will allow the user to move further
  47929. * defaults to 5 (meters, in xr units)
  47930. */
  47931. parabolicCheckRadius: number;
  47932. /**
  47933. * Should the module support parabolic ray on top of direct ray
  47934. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  47935. * Very helpful when moving between floors / different heights
  47936. */
  47937. parabolicRayEnabled: boolean;
  47938. /**
  47939. * How much rotation should be applied when rotating right and left
  47940. */
  47941. rotationAngle: number;
  47942. /**
  47943. * Is rotation enabled when moving forward?
  47944. * Disabling this feature will prevent the user from deciding the direction when teleporting
  47945. */
  47946. rotationEnabled: boolean;
  47947. /**
  47948. * constructs a new anchor system
  47949. * @param _xrSessionManager an instance of WebXRSessionManager
  47950. * @param _options configuration object for this feature
  47951. */
  47952. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  47953. /**
  47954. * Get the snapPointsOnly flag
  47955. */
  47956. get snapPointsOnly(): boolean;
  47957. /**
  47958. * Sets the snapPointsOnly flag
  47959. * @param snapToPoints should teleportation be exclusively to snap points
  47960. */
  47961. set snapPointsOnly(snapToPoints: boolean);
  47962. /**
  47963. * Add a new mesh to the floor meshes array
  47964. * @param mesh the mesh to use as floor mesh
  47965. */
  47966. addFloorMesh(mesh: AbstractMesh): void;
  47967. /**
  47968. * Add a new snap-to point to fix teleportation to this position
  47969. * @param newSnapPoint The new Snap-To point
  47970. */
  47971. addSnapPoint(newSnapPoint: Vector3): void;
  47972. attach(): boolean;
  47973. detach(): boolean;
  47974. dispose(): void;
  47975. /**
  47976. * Remove a mesh from the floor meshes array
  47977. * @param mesh the mesh to remove
  47978. */
  47979. removeFloorMesh(mesh: AbstractMesh): void;
  47980. /**
  47981. * Remove a mesh from the floor meshes array using its name
  47982. * @param name the mesh name to remove
  47983. */
  47984. removeFloorMeshByName(name: string): void;
  47985. /**
  47986. * 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
  47987. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  47988. * @returns was the point found and removed or not
  47989. */
  47990. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  47991. /**
  47992. * This function sets a selection feature that will be disabled when
  47993. * the forward ray is shown and will be reattached when hidden.
  47994. * This is used to remove the selection rays when moving.
  47995. * @param selectionFeature the feature to disable when forward movement is enabled
  47996. */
  47997. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  47998. protected _onXRFrame(_xrFrame: XRFrame): void;
  47999. private _attachController;
  48000. private _createDefaultTargetMesh;
  48001. private _detachController;
  48002. private _findClosestSnapPointWithRadius;
  48003. private _setTargetMeshPosition;
  48004. private _setTargetMeshVisibility;
  48005. private _showParabolicPath;
  48006. private _teleportForward;
  48007. }
  48008. }
  48009. declare module BABYLON {
  48010. /**
  48011. * Options for the default xr helper
  48012. */
  48013. export class WebXRDefaultExperienceOptions {
  48014. /**
  48015. * Enable or disable default UI to enter XR
  48016. */
  48017. disableDefaultUI?: boolean;
  48018. /**
  48019. * Should teleportation not initialize. defaults to false.
  48020. */
  48021. disableTeleportation?: boolean;
  48022. /**
  48023. * Floor meshes that will be used for teleport
  48024. */
  48025. floorMeshes?: Array<AbstractMesh>;
  48026. /**
  48027. * If set to true, the first frame will not be used to reset position
  48028. * The first frame is mainly used when copying transformation from the old camera
  48029. * Mainly used in AR
  48030. */
  48031. ignoreNativeCameraTransformation?: boolean;
  48032. /**
  48033. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48034. */
  48035. inputOptions?: IWebXRInputOptions;
  48036. /**
  48037. * optional configuration for the output canvas
  48038. */
  48039. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48040. /**
  48041. * optional UI options. This can be used among other to change session mode and reference space type
  48042. */
  48043. uiOptions?: WebXREnterExitUIOptions;
  48044. /**
  48045. * When loading teleportation and pointer select, use stable versions instead of latest.
  48046. */
  48047. useStablePlugins?: boolean;
  48048. /**
  48049. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48050. */
  48051. renderingGroupId?: number;
  48052. /**
  48053. * A list of optional features to init the session with
  48054. * If set to true, all features we support will be added
  48055. */
  48056. optionalFeatures?: boolean | string[];
  48057. }
  48058. /**
  48059. * Default experience which provides a similar setup to the previous webVRExperience
  48060. */
  48061. export class WebXRDefaultExperience {
  48062. /**
  48063. * Base experience
  48064. */
  48065. baseExperience: WebXRExperienceHelper;
  48066. /**
  48067. * Enables ui for entering/exiting xr
  48068. */
  48069. enterExitUI: WebXREnterExitUI;
  48070. /**
  48071. * Input experience extension
  48072. */
  48073. input: WebXRInput;
  48074. /**
  48075. * Enables laser pointer and selection
  48076. */
  48077. pointerSelection: WebXRControllerPointerSelection;
  48078. /**
  48079. * Default target xr should render to
  48080. */
  48081. renderTarget: WebXRRenderTarget;
  48082. /**
  48083. * Enables teleportation
  48084. */
  48085. teleportation: WebXRMotionControllerTeleportation;
  48086. private constructor();
  48087. /**
  48088. * Creates the default xr experience
  48089. * @param scene scene
  48090. * @param options options for basic configuration
  48091. * @returns resulting WebXRDefaultExperience
  48092. */
  48093. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48094. /**
  48095. * DIsposes of the experience helper
  48096. */
  48097. dispose(): void;
  48098. }
  48099. }
  48100. declare module BABYLON {
  48101. /**
  48102. * Options to modify the vr teleportation behavior.
  48103. */
  48104. export interface VRTeleportationOptions {
  48105. /**
  48106. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48107. */
  48108. floorMeshName?: string;
  48109. /**
  48110. * A list of meshes to be used as the teleportation floor. (default: empty)
  48111. */
  48112. floorMeshes?: Mesh[];
  48113. /**
  48114. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48115. */
  48116. teleportationMode?: number;
  48117. /**
  48118. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48119. */
  48120. teleportationTime?: number;
  48121. /**
  48122. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48123. */
  48124. teleportationSpeed?: number;
  48125. /**
  48126. * The easing function used in the animation or null for Linear. (default CircleEase)
  48127. */
  48128. easingFunction?: EasingFunction;
  48129. }
  48130. /**
  48131. * Options to modify the vr experience helper's behavior.
  48132. */
  48133. export interface VRExperienceHelperOptions extends WebVROptions {
  48134. /**
  48135. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48136. */
  48137. createDeviceOrientationCamera?: boolean;
  48138. /**
  48139. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48140. */
  48141. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48142. /**
  48143. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48144. */
  48145. laserToggle?: boolean;
  48146. /**
  48147. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48148. */
  48149. floorMeshes?: Mesh[];
  48150. /**
  48151. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48152. */
  48153. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48154. /**
  48155. * Defines if WebXR should be used instead of WebVR (if available)
  48156. */
  48157. useXR?: boolean;
  48158. }
  48159. /**
  48160. * Event containing information after VR has been entered
  48161. */
  48162. export class OnAfterEnteringVRObservableEvent {
  48163. /**
  48164. * If entering vr was successful
  48165. */
  48166. success: boolean;
  48167. }
  48168. /**
  48169. * Helps to quickly add VR support to an existing scene.
  48170. * See http://doc.babylonjs.com/how_to/webvr_helper
  48171. */
  48172. export class VRExperienceHelper {
  48173. /** Options to modify the vr experience helper's behavior. */
  48174. webVROptions: VRExperienceHelperOptions;
  48175. private _scene;
  48176. private _position;
  48177. private _btnVR;
  48178. private _btnVRDisplayed;
  48179. private _webVRsupported;
  48180. private _webVRready;
  48181. private _webVRrequesting;
  48182. private _webVRpresenting;
  48183. private _hasEnteredVR;
  48184. private _fullscreenVRpresenting;
  48185. private _inputElement;
  48186. private _webVRCamera;
  48187. private _vrDeviceOrientationCamera;
  48188. private _deviceOrientationCamera;
  48189. private _existingCamera;
  48190. private _onKeyDown;
  48191. private _onVrDisplayPresentChange;
  48192. private _onVRDisplayChanged;
  48193. private _onVRRequestPresentStart;
  48194. private _onVRRequestPresentComplete;
  48195. /**
  48196. * 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)
  48197. */
  48198. enableGazeEvenWhenNoPointerLock: boolean;
  48199. /**
  48200. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48201. */
  48202. exitVROnDoubleTap: boolean;
  48203. /**
  48204. * Observable raised right before entering VR.
  48205. */
  48206. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48207. /**
  48208. * Observable raised when entering VR has completed.
  48209. */
  48210. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48211. /**
  48212. * Observable raised when exiting VR.
  48213. */
  48214. onExitingVRObservable: Observable<VRExperienceHelper>;
  48215. /**
  48216. * Observable raised when controller mesh is loaded.
  48217. */
  48218. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48219. /** Return this.onEnteringVRObservable
  48220. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48221. */
  48222. get onEnteringVR(): Observable<VRExperienceHelper>;
  48223. /** Return this.onExitingVRObservable
  48224. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48225. */
  48226. get onExitingVR(): Observable<VRExperienceHelper>;
  48227. /** Return this.onControllerMeshLoadedObservable
  48228. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48229. */
  48230. get onControllerMeshLoaded(): Observable<WebVRController>;
  48231. private _rayLength;
  48232. private _useCustomVRButton;
  48233. private _teleportationRequested;
  48234. private _teleportActive;
  48235. private _floorMeshName;
  48236. private _floorMeshesCollection;
  48237. private _teleportationMode;
  48238. private _teleportationTime;
  48239. private _teleportationSpeed;
  48240. private _teleportationEasing;
  48241. private _rotationAllowed;
  48242. private _teleportBackwardsVector;
  48243. private _teleportationTarget;
  48244. private _isDefaultTeleportationTarget;
  48245. private _postProcessMove;
  48246. private _teleportationFillColor;
  48247. private _teleportationBorderColor;
  48248. private _rotationAngle;
  48249. private _haloCenter;
  48250. private _cameraGazer;
  48251. private _padSensibilityUp;
  48252. private _padSensibilityDown;
  48253. private _leftController;
  48254. private _rightController;
  48255. private _gazeColor;
  48256. private _laserColor;
  48257. private _pickedLaserColor;
  48258. private _pickedGazeColor;
  48259. /**
  48260. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48261. */
  48262. onNewMeshSelected: Observable<AbstractMesh>;
  48263. /**
  48264. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48265. * This observable will provide the mesh and the controller used to select the mesh
  48266. */
  48267. onMeshSelectedWithController: Observable<{
  48268. mesh: AbstractMesh;
  48269. controller: WebVRController;
  48270. }>;
  48271. /**
  48272. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48273. */
  48274. onNewMeshPicked: Observable<PickingInfo>;
  48275. private _circleEase;
  48276. /**
  48277. * Observable raised before camera teleportation
  48278. */
  48279. onBeforeCameraTeleport: Observable<Vector3>;
  48280. /**
  48281. * Observable raised after camera teleportation
  48282. */
  48283. onAfterCameraTeleport: Observable<Vector3>;
  48284. /**
  48285. * Observable raised when current selected mesh gets unselected
  48286. */
  48287. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48288. private _raySelectionPredicate;
  48289. /**
  48290. * To be optionaly changed by user to define custom ray selection
  48291. */
  48292. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48293. /**
  48294. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48295. */
  48296. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48297. /**
  48298. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48299. */
  48300. teleportationEnabled: boolean;
  48301. private _defaultHeight;
  48302. private _teleportationInitialized;
  48303. private _interactionsEnabled;
  48304. private _interactionsRequested;
  48305. private _displayGaze;
  48306. private _displayLaserPointer;
  48307. /**
  48308. * The mesh used to display where the user is going to teleport.
  48309. */
  48310. get teleportationTarget(): Mesh;
  48311. /**
  48312. * Sets the mesh to be used to display where the user is going to teleport.
  48313. */
  48314. set teleportationTarget(value: Mesh);
  48315. /**
  48316. * 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
  48317. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48318. * See http://doc.babylonjs.com/resources/baking_transformations
  48319. */
  48320. get gazeTrackerMesh(): Mesh;
  48321. set gazeTrackerMesh(value: Mesh);
  48322. /**
  48323. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48324. */
  48325. updateGazeTrackerScale: boolean;
  48326. /**
  48327. * If the gaze trackers color should be updated when selecting meshes
  48328. */
  48329. updateGazeTrackerColor: boolean;
  48330. /**
  48331. * If the controller laser color should be updated when selecting meshes
  48332. */
  48333. updateControllerLaserColor: boolean;
  48334. /**
  48335. * The gaze tracking mesh corresponding to the left controller
  48336. */
  48337. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48338. /**
  48339. * The gaze tracking mesh corresponding to the right controller
  48340. */
  48341. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48342. /**
  48343. * If the ray of the gaze should be displayed.
  48344. */
  48345. get displayGaze(): boolean;
  48346. /**
  48347. * Sets if the ray of the gaze should be displayed.
  48348. */
  48349. set displayGaze(value: boolean);
  48350. /**
  48351. * If the ray of the LaserPointer should be displayed.
  48352. */
  48353. get displayLaserPointer(): boolean;
  48354. /**
  48355. * Sets if the ray of the LaserPointer should be displayed.
  48356. */
  48357. set displayLaserPointer(value: boolean);
  48358. /**
  48359. * The deviceOrientationCamera used as the camera when not in VR.
  48360. */
  48361. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48362. /**
  48363. * Based on the current WebVR support, returns the current VR camera used.
  48364. */
  48365. get currentVRCamera(): Nullable<Camera>;
  48366. /**
  48367. * The webVRCamera which is used when in VR.
  48368. */
  48369. get webVRCamera(): WebVRFreeCamera;
  48370. /**
  48371. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48372. */
  48373. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48374. /**
  48375. * The html button that is used to trigger entering into VR.
  48376. */
  48377. get vrButton(): Nullable<HTMLButtonElement>;
  48378. private get _teleportationRequestInitiated();
  48379. /**
  48380. * Defines whether or not Pointer lock should be requested when switching to
  48381. * full screen.
  48382. */
  48383. requestPointerLockOnFullScreen: boolean;
  48384. /**
  48385. * If asking to force XR, this will be populated with the default xr experience
  48386. */
  48387. xr: WebXRDefaultExperience;
  48388. /**
  48389. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48390. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48391. */
  48392. xrTestDone: boolean;
  48393. /**
  48394. * Instantiates a VRExperienceHelper.
  48395. * Helps to quickly add VR support to an existing scene.
  48396. * @param scene The scene the VRExperienceHelper belongs to.
  48397. * @param webVROptions Options to modify the vr experience helper's behavior.
  48398. */
  48399. constructor(scene: Scene,
  48400. /** Options to modify the vr experience helper's behavior. */
  48401. webVROptions?: VRExperienceHelperOptions);
  48402. private completeVRInit;
  48403. private _onDefaultMeshLoaded;
  48404. private _onResize;
  48405. private _onFullscreenChange;
  48406. /**
  48407. * Gets a value indicating if we are currently in VR mode.
  48408. */
  48409. get isInVRMode(): boolean;
  48410. private onVrDisplayPresentChange;
  48411. private onVRDisplayChanged;
  48412. private moveButtonToBottomRight;
  48413. private displayVRButton;
  48414. private updateButtonVisibility;
  48415. private _cachedAngularSensibility;
  48416. /**
  48417. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48418. * Otherwise, will use the fullscreen API.
  48419. */
  48420. enterVR(): void;
  48421. /**
  48422. * Attempt to exit VR, or fullscreen.
  48423. */
  48424. exitVR(): void;
  48425. /**
  48426. * The position of the vr experience helper.
  48427. */
  48428. get position(): Vector3;
  48429. /**
  48430. * Sets the position of the vr experience helper.
  48431. */
  48432. set position(value: Vector3);
  48433. /**
  48434. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48435. */
  48436. enableInteractions(): void;
  48437. private get _noControllerIsActive();
  48438. private beforeRender;
  48439. private _isTeleportationFloor;
  48440. /**
  48441. * Adds a floor mesh to be used for teleportation.
  48442. * @param floorMesh the mesh to be used for teleportation.
  48443. */
  48444. addFloorMesh(floorMesh: Mesh): void;
  48445. /**
  48446. * Removes a floor mesh from being used for teleportation.
  48447. * @param floorMesh the mesh to be removed.
  48448. */
  48449. removeFloorMesh(floorMesh: Mesh): void;
  48450. /**
  48451. * Enables interactions and teleportation using the VR controllers and gaze.
  48452. * @param vrTeleportationOptions options to modify teleportation behavior.
  48453. */
  48454. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48455. private _onNewGamepadConnected;
  48456. private _tryEnableInteractionOnController;
  48457. private _onNewGamepadDisconnected;
  48458. private _enableInteractionOnController;
  48459. private _checkTeleportWithRay;
  48460. private _checkRotate;
  48461. private _checkTeleportBackwards;
  48462. private _enableTeleportationOnController;
  48463. private _createTeleportationCircles;
  48464. private _displayTeleportationTarget;
  48465. private _hideTeleportationTarget;
  48466. private _rotateCamera;
  48467. private _moveTeleportationSelectorTo;
  48468. private _workingVector;
  48469. private _workingQuaternion;
  48470. private _workingMatrix;
  48471. /**
  48472. * Time Constant Teleportation Mode
  48473. */
  48474. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48475. /**
  48476. * Speed Constant Teleportation Mode
  48477. */
  48478. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48479. /**
  48480. * Teleports the users feet to the desired location
  48481. * @param location The location where the user's feet should be placed
  48482. */
  48483. teleportCamera(location: Vector3): void;
  48484. private _convertNormalToDirectionOfRay;
  48485. private _castRayAndSelectObject;
  48486. private _notifySelectedMeshUnselected;
  48487. /**
  48488. * Permanently set new colors for the laser pointer
  48489. * @param color the new laser color
  48490. * @param pickedColor the new laser color when picked mesh detected
  48491. */
  48492. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48493. /**
  48494. * Set lighting enabled / disabled on the laser pointer of both controllers
  48495. * @param enabled should the lighting be enabled on the laser pointer
  48496. */
  48497. setLaserLightingState(enabled?: boolean): void;
  48498. /**
  48499. * Permanently set new colors for the gaze pointer
  48500. * @param color the new gaze color
  48501. * @param pickedColor the new gaze color when picked mesh detected
  48502. */
  48503. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48504. /**
  48505. * Sets the color of the laser ray from the vr controllers.
  48506. * @param color new color for the ray.
  48507. */
  48508. changeLaserColor(color: Color3): void;
  48509. /**
  48510. * Sets the color of the ray from the vr headsets gaze.
  48511. * @param color new color for the ray.
  48512. */
  48513. changeGazeColor(color: Color3): void;
  48514. /**
  48515. * Exits VR and disposes of the vr experience helper
  48516. */
  48517. dispose(): void;
  48518. /**
  48519. * Gets the name of the VRExperienceHelper class
  48520. * @returns "VRExperienceHelper"
  48521. */
  48522. getClassName(): string;
  48523. }
  48524. }
  48525. declare module BABYLON {
  48526. /**
  48527. * Contains an array of blocks representing the octree
  48528. */
  48529. export interface IOctreeContainer<T> {
  48530. /**
  48531. * Blocks within the octree
  48532. */
  48533. blocks: Array<OctreeBlock<T>>;
  48534. }
  48535. /**
  48536. * Class used to store a cell in an octree
  48537. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48538. */
  48539. export class OctreeBlock<T> {
  48540. /**
  48541. * Gets the content of the current block
  48542. */
  48543. entries: T[];
  48544. /**
  48545. * Gets the list of block children
  48546. */
  48547. blocks: Array<OctreeBlock<T>>;
  48548. private _depth;
  48549. private _maxDepth;
  48550. private _capacity;
  48551. private _minPoint;
  48552. private _maxPoint;
  48553. private _boundingVectors;
  48554. private _creationFunc;
  48555. /**
  48556. * Creates a new block
  48557. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  48558. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  48559. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48560. * @param depth defines the current depth of this block in the octree
  48561. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  48562. * @param creationFunc defines a callback to call when an element is added to the block
  48563. */
  48564. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  48565. /**
  48566. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48567. */
  48568. get capacity(): number;
  48569. /**
  48570. * Gets the minimum vector (in world space) of the block's bounding box
  48571. */
  48572. get minPoint(): Vector3;
  48573. /**
  48574. * Gets the maximum vector (in world space) of the block's bounding box
  48575. */
  48576. get maxPoint(): Vector3;
  48577. /**
  48578. * Add a new element to this block
  48579. * @param entry defines the element to add
  48580. */
  48581. addEntry(entry: T): void;
  48582. /**
  48583. * Remove an element from this block
  48584. * @param entry defines the element to remove
  48585. */
  48586. removeEntry(entry: T): void;
  48587. /**
  48588. * Add an array of elements to this block
  48589. * @param entries defines the array of elements to add
  48590. */
  48591. addEntries(entries: T[]): void;
  48592. /**
  48593. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  48594. * @param frustumPlanes defines the frustum planes to test
  48595. * @param selection defines the array to store current content if selection is positive
  48596. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48597. */
  48598. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48599. /**
  48600. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  48601. * @param sphereCenter defines the bounding sphere center
  48602. * @param sphereRadius defines the bounding sphere radius
  48603. * @param selection defines the array to store current content if selection is positive
  48604. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48605. */
  48606. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48607. /**
  48608. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  48609. * @param ray defines the ray to test with
  48610. * @param selection defines the array to store current content if selection is positive
  48611. */
  48612. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  48613. /**
  48614. * Subdivide the content into child blocks (this block will then be empty)
  48615. */
  48616. createInnerBlocks(): void;
  48617. /**
  48618. * @hidden
  48619. */
  48620. 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;
  48621. }
  48622. }
  48623. declare module BABYLON {
  48624. /**
  48625. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  48626. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48627. */
  48628. export class Octree<T> {
  48629. /** 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.) */
  48630. maxDepth: number;
  48631. /**
  48632. * Blocks within the octree containing objects
  48633. */
  48634. blocks: Array<OctreeBlock<T>>;
  48635. /**
  48636. * Content stored in the octree
  48637. */
  48638. dynamicContent: T[];
  48639. private _maxBlockCapacity;
  48640. private _selectionContent;
  48641. private _creationFunc;
  48642. /**
  48643. * Creates a octree
  48644. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48645. * @param creationFunc function to be used to instatiate the octree
  48646. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  48647. * @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.)
  48648. */
  48649. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  48650. /** 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.) */
  48651. maxDepth?: number);
  48652. /**
  48653. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  48654. * @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);
  48655. * @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);
  48656. * @param entries meshes to be added to the octree blocks
  48657. */
  48658. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  48659. /**
  48660. * Adds a mesh to the octree
  48661. * @param entry Mesh to add to the octree
  48662. */
  48663. addMesh(entry: T): void;
  48664. /**
  48665. * Remove an element from the octree
  48666. * @param entry defines the element to remove
  48667. */
  48668. removeMesh(entry: T): void;
  48669. /**
  48670. * Selects an array of meshes within the frustum
  48671. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  48672. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  48673. * @returns array of meshes within the frustum
  48674. */
  48675. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  48676. /**
  48677. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  48678. * @param sphereCenter defines the bounding sphere center
  48679. * @param sphereRadius defines the bounding sphere radius
  48680. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48681. * @returns an array of objects that intersect the sphere
  48682. */
  48683. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  48684. /**
  48685. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  48686. * @param ray defines the ray to test with
  48687. * @returns array of intersected objects
  48688. */
  48689. intersectsRay(ray: Ray): SmartArray<T>;
  48690. /**
  48691. * Adds a mesh into the octree block if it intersects the block
  48692. */
  48693. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  48694. /**
  48695. * Adds a submesh into the octree block if it intersects the block
  48696. */
  48697. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  48698. }
  48699. }
  48700. declare module BABYLON {
  48701. interface Scene {
  48702. /**
  48703. * @hidden
  48704. * Backing Filed
  48705. */
  48706. _selectionOctree: Octree<AbstractMesh>;
  48707. /**
  48708. * Gets the octree used to boost mesh selection (picking)
  48709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48710. */
  48711. selectionOctree: Octree<AbstractMesh>;
  48712. /**
  48713. * Creates or updates the octree used to boost selection (picking)
  48714. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48715. * @param maxCapacity defines the maximum capacity per leaf
  48716. * @param maxDepth defines the maximum depth of the octree
  48717. * @returns an octree of AbstractMesh
  48718. */
  48719. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  48720. }
  48721. interface AbstractMesh {
  48722. /**
  48723. * @hidden
  48724. * Backing Field
  48725. */
  48726. _submeshesOctree: Octree<SubMesh>;
  48727. /**
  48728. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  48729. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  48730. * @param maxCapacity defines the maximum size of each block (64 by default)
  48731. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  48732. * @returns the new octree
  48733. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  48734. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48735. */
  48736. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  48737. }
  48738. /**
  48739. * Defines the octree scene component responsible to manage any octrees
  48740. * in a given scene.
  48741. */
  48742. export class OctreeSceneComponent {
  48743. /**
  48744. * The component name help to identify the component in the list of scene components.
  48745. */
  48746. readonly name: string;
  48747. /**
  48748. * The scene the component belongs to.
  48749. */
  48750. scene: Scene;
  48751. /**
  48752. * Indicates if the meshes have been checked to make sure they are isEnabled()
  48753. */
  48754. readonly checksIsEnabled: boolean;
  48755. /**
  48756. * Creates a new instance of the component for the given scene
  48757. * @param scene Defines the scene to register the component in
  48758. */
  48759. constructor(scene: Scene);
  48760. /**
  48761. * Registers the component in a given scene
  48762. */
  48763. register(): void;
  48764. /**
  48765. * Return the list of active meshes
  48766. * @returns the list of active meshes
  48767. */
  48768. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48769. /**
  48770. * Return the list of active sub meshes
  48771. * @param mesh The mesh to get the candidates sub meshes from
  48772. * @returns the list of active sub meshes
  48773. */
  48774. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48775. private _tempRay;
  48776. /**
  48777. * Return the list of sub meshes intersecting with a given local ray
  48778. * @param mesh defines the mesh to find the submesh for
  48779. * @param localRay defines the ray in local space
  48780. * @returns the list of intersecting sub meshes
  48781. */
  48782. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  48783. /**
  48784. * Return the list of sub meshes colliding with a collider
  48785. * @param mesh defines the mesh to find the submesh for
  48786. * @param collider defines the collider to evaluate the collision against
  48787. * @returns the list of colliding sub meshes
  48788. */
  48789. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  48790. /**
  48791. * Rebuilds the elements related to this component in case of
  48792. * context lost for instance.
  48793. */
  48794. rebuild(): void;
  48795. /**
  48796. * Disposes the component and the associated ressources.
  48797. */
  48798. dispose(): void;
  48799. }
  48800. }
  48801. declare module BABYLON {
  48802. /**
  48803. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48804. */
  48805. export class Gizmo implements IDisposable {
  48806. /** The utility layer the gizmo will be added to */
  48807. gizmoLayer: UtilityLayerRenderer;
  48808. /**
  48809. * The root mesh of the gizmo
  48810. */
  48811. _rootMesh: Mesh;
  48812. private _attachedMesh;
  48813. /**
  48814. * Ratio for the scale of the gizmo (Default: 1)
  48815. */
  48816. scaleRatio: number;
  48817. /**
  48818. * If a custom mesh has been set (Default: false)
  48819. */
  48820. protected _customMeshSet: boolean;
  48821. /**
  48822. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48823. * * When set, interactions will be enabled
  48824. */
  48825. get attachedMesh(): Nullable<AbstractMesh>;
  48826. set attachedMesh(value: Nullable<AbstractMesh>);
  48827. /**
  48828. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48829. * @param mesh The mesh to replace the default mesh of the gizmo
  48830. */
  48831. setCustomMesh(mesh: Mesh): void;
  48832. /**
  48833. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48834. */
  48835. updateGizmoRotationToMatchAttachedMesh: boolean;
  48836. /**
  48837. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48838. */
  48839. updateGizmoPositionToMatchAttachedMesh: boolean;
  48840. /**
  48841. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48842. */
  48843. updateScale: boolean;
  48844. protected _interactionsEnabled: boolean;
  48845. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48846. private _beforeRenderObserver;
  48847. private _tempVector;
  48848. /**
  48849. * Creates a gizmo
  48850. * @param gizmoLayer The utility layer the gizmo will be added to
  48851. */
  48852. constructor(
  48853. /** The utility layer the gizmo will be added to */
  48854. gizmoLayer?: UtilityLayerRenderer);
  48855. /**
  48856. * Updates the gizmo to match the attached mesh's position/rotation
  48857. */
  48858. protected _update(): void;
  48859. /**
  48860. * Disposes of the gizmo
  48861. */
  48862. dispose(): void;
  48863. }
  48864. }
  48865. declare module BABYLON {
  48866. /**
  48867. * Single plane drag gizmo
  48868. */
  48869. export class PlaneDragGizmo extends Gizmo {
  48870. /**
  48871. * Drag behavior responsible for the gizmos dragging interactions
  48872. */
  48873. dragBehavior: PointerDragBehavior;
  48874. private _pointerObserver;
  48875. /**
  48876. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48877. */
  48878. snapDistance: number;
  48879. /**
  48880. * Event that fires each time the gizmo snaps to a new location.
  48881. * * snapDistance is the the change in distance
  48882. */
  48883. onSnapObservable: Observable<{
  48884. snapDistance: number;
  48885. }>;
  48886. private _plane;
  48887. private _coloredMaterial;
  48888. private _hoverMaterial;
  48889. private _isEnabled;
  48890. private _parent;
  48891. /** @hidden */
  48892. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48893. /** @hidden */
  48894. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48895. /**
  48896. * Creates a PlaneDragGizmo
  48897. * @param gizmoLayer The utility layer the gizmo will be added to
  48898. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48899. * @param color The color of the gizmo
  48900. */
  48901. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48902. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48903. /**
  48904. * If the gizmo is enabled
  48905. */
  48906. set isEnabled(value: boolean);
  48907. get isEnabled(): boolean;
  48908. /**
  48909. * Disposes of the gizmo
  48910. */
  48911. dispose(): void;
  48912. }
  48913. }
  48914. declare module BABYLON {
  48915. /**
  48916. * Gizmo that enables dragging a mesh along 3 axis
  48917. */
  48918. export class PositionGizmo extends Gizmo {
  48919. /**
  48920. * Internal gizmo used for interactions on the x axis
  48921. */
  48922. xGizmo: AxisDragGizmo;
  48923. /**
  48924. * Internal gizmo used for interactions on the y axis
  48925. */
  48926. yGizmo: AxisDragGizmo;
  48927. /**
  48928. * Internal gizmo used for interactions on the z axis
  48929. */
  48930. zGizmo: AxisDragGizmo;
  48931. /**
  48932. * Internal gizmo used for interactions on the yz plane
  48933. */
  48934. xPlaneGizmo: PlaneDragGizmo;
  48935. /**
  48936. * Internal gizmo used for interactions on the xz plane
  48937. */
  48938. yPlaneGizmo: PlaneDragGizmo;
  48939. /**
  48940. * Internal gizmo used for interactions on the xy plane
  48941. */
  48942. zPlaneGizmo: PlaneDragGizmo;
  48943. /**
  48944. * private variables
  48945. */
  48946. private _meshAttached;
  48947. private _updateGizmoRotationToMatchAttachedMesh;
  48948. private _snapDistance;
  48949. private _scaleRatio;
  48950. /** Fires an event when any of it's sub gizmos are dragged */
  48951. onDragStartObservable: Observable<unknown>;
  48952. /** Fires an event when any of it's sub gizmos are released from dragging */
  48953. onDragEndObservable: Observable<unknown>;
  48954. /**
  48955. * If set to true, planar drag is enabled
  48956. */
  48957. private _planarGizmoEnabled;
  48958. get attachedMesh(): Nullable<AbstractMesh>;
  48959. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48960. /**
  48961. * Creates a PositionGizmo
  48962. * @param gizmoLayer The utility layer the gizmo will be added to
  48963. */
  48964. constructor(gizmoLayer?: UtilityLayerRenderer);
  48965. /**
  48966. * If the planar drag gizmo is enabled
  48967. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48968. */
  48969. set planarGizmoEnabled(value: boolean);
  48970. get planarGizmoEnabled(): boolean;
  48971. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48972. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48973. /**
  48974. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48975. */
  48976. set snapDistance(value: number);
  48977. get snapDistance(): number;
  48978. /**
  48979. * Ratio for the scale of the gizmo (Default: 1)
  48980. */
  48981. set scaleRatio(value: number);
  48982. get scaleRatio(): number;
  48983. /**
  48984. * Disposes of the gizmo
  48985. */
  48986. dispose(): void;
  48987. /**
  48988. * CustomMeshes are not supported by this gizmo
  48989. * @param mesh The mesh to replace the default mesh of the gizmo
  48990. */
  48991. setCustomMesh(mesh: Mesh): void;
  48992. }
  48993. }
  48994. declare module BABYLON {
  48995. /**
  48996. * Single axis drag gizmo
  48997. */
  48998. export class AxisDragGizmo extends Gizmo {
  48999. /**
  49000. * Drag behavior responsible for the gizmos dragging interactions
  49001. */
  49002. dragBehavior: PointerDragBehavior;
  49003. private _pointerObserver;
  49004. /**
  49005. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49006. */
  49007. snapDistance: number;
  49008. /**
  49009. * Event that fires each time the gizmo snaps to a new location.
  49010. * * snapDistance is the the change in distance
  49011. */
  49012. onSnapObservable: Observable<{
  49013. snapDistance: number;
  49014. }>;
  49015. private _isEnabled;
  49016. private _parent;
  49017. private _arrow;
  49018. private _coloredMaterial;
  49019. private _hoverMaterial;
  49020. /** @hidden */
  49021. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49022. /** @hidden */
  49023. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49024. /**
  49025. * Creates an AxisDragGizmo
  49026. * @param gizmoLayer The utility layer the gizmo will be added to
  49027. * @param dragAxis The axis which the gizmo will be able to drag on
  49028. * @param color The color of the gizmo
  49029. */
  49030. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49031. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49032. /**
  49033. * If the gizmo is enabled
  49034. */
  49035. set isEnabled(value: boolean);
  49036. get isEnabled(): boolean;
  49037. /**
  49038. * Disposes of the gizmo
  49039. */
  49040. dispose(): void;
  49041. }
  49042. }
  49043. declare module BABYLON.Debug {
  49044. /**
  49045. * The Axes viewer will show 3 axes in a specific point in space
  49046. */
  49047. export class AxesViewer {
  49048. private _xAxis;
  49049. private _yAxis;
  49050. private _zAxis;
  49051. private _scaleLinesFactor;
  49052. private _instanced;
  49053. /**
  49054. * Gets the hosting scene
  49055. */
  49056. scene: Scene;
  49057. /**
  49058. * Gets or sets a number used to scale line length
  49059. */
  49060. scaleLines: number;
  49061. /** Gets the node hierarchy used to render x-axis */
  49062. get xAxis(): TransformNode;
  49063. /** Gets the node hierarchy used to render y-axis */
  49064. get yAxis(): TransformNode;
  49065. /** Gets the node hierarchy used to render z-axis */
  49066. get zAxis(): TransformNode;
  49067. /**
  49068. * Creates a new AxesViewer
  49069. * @param scene defines the hosting scene
  49070. * @param scaleLines defines a number used to scale line length (1 by default)
  49071. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49072. * @param xAxis defines the node hierarchy used to render the x-axis
  49073. * @param yAxis defines the node hierarchy used to render the y-axis
  49074. * @param zAxis defines the node hierarchy used to render the z-axis
  49075. */
  49076. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49077. /**
  49078. * Force the viewer to update
  49079. * @param position defines the position of the viewer
  49080. * @param xaxis defines the x axis of the viewer
  49081. * @param yaxis defines the y axis of the viewer
  49082. * @param zaxis defines the z axis of the viewer
  49083. */
  49084. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49085. /**
  49086. * Creates an instance of this axes viewer.
  49087. * @returns a new axes viewer with instanced meshes
  49088. */
  49089. createInstance(): AxesViewer;
  49090. /** Releases resources */
  49091. dispose(): void;
  49092. private static _SetRenderingGroupId;
  49093. }
  49094. }
  49095. declare module BABYLON.Debug {
  49096. /**
  49097. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49098. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49099. */
  49100. export class BoneAxesViewer extends AxesViewer {
  49101. /**
  49102. * Gets or sets the target mesh where to display the axes viewer
  49103. */
  49104. mesh: Nullable<Mesh>;
  49105. /**
  49106. * Gets or sets the target bone where to display the axes viewer
  49107. */
  49108. bone: Nullable<Bone>;
  49109. /** Gets current position */
  49110. pos: Vector3;
  49111. /** Gets direction of X axis */
  49112. xaxis: Vector3;
  49113. /** Gets direction of Y axis */
  49114. yaxis: Vector3;
  49115. /** Gets direction of Z axis */
  49116. zaxis: Vector3;
  49117. /**
  49118. * Creates a new BoneAxesViewer
  49119. * @param scene defines the hosting scene
  49120. * @param bone defines the target bone
  49121. * @param mesh defines the target mesh
  49122. * @param scaleLines defines a scaling factor for line length (1 by default)
  49123. */
  49124. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49125. /**
  49126. * Force the viewer to update
  49127. */
  49128. update(): void;
  49129. /** Releases resources */
  49130. dispose(): void;
  49131. }
  49132. }
  49133. declare module BABYLON {
  49134. /**
  49135. * Interface used to define scene explorer extensibility option
  49136. */
  49137. export interface IExplorerExtensibilityOption {
  49138. /**
  49139. * Define the option label
  49140. */
  49141. label: string;
  49142. /**
  49143. * Defines the action to execute on click
  49144. */
  49145. action: (entity: any) => void;
  49146. }
  49147. /**
  49148. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49149. */
  49150. export interface IExplorerExtensibilityGroup {
  49151. /**
  49152. * Defines a predicate to test if a given type mut be extended
  49153. */
  49154. predicate: (entity: any) => boolean;
  49155. /**
  49156. * Gets the list of options added to a type
  49157. */
  49158. entries: IExplorerExtensibilityOption[];
  49159. }
  49160. /**
  49161. * Interface used to define the options to use to create the Inspector
  49162. */
  49163. export interface IInspectorOptions {
  49164. /**
  49165. * Display in overlay mode (default: false)
  49166. */
  49167. overlay?: boolean;
  49168. /**
  49169. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49170. */
  49171. globalRoot?: HTMLElement;
  49172. /**
  49173. * Display the Scene explorer
  49174. */
  49175. showExplorer?: boolean;
  49176. /**
  49177. * Display the property inspector
  49178. */
  49179. showInspector?: boolean;
  49180. /**
  49181. * Display in embed mode (both panes on the right)
  49182. */
  49183. embedMode?: boolean;
  49184. /**
  49185. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49186. */
  49187. handleResize?: boolean;
  49188. /**
  49189. * Allow the panes to popup (default: true)
  49190. */
  49191. enablePopup?: boolean;
  49192. /**
  49193. * Allow the panes to be closed by users (default: true)
  49194. */
  49195. enableClose?: boolean;
  49196. /**
  49197. * Optional list of extensibility entries
  49198. */
  49199. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49200. /**
  49201. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49202. */
  49203. inspectorURL?: string;
  49204. /**
  49205. * Optional initial tab (default to DebugLayerTab.Properties)
  49206. */
  49207. initialTab?: DebugLayerTab;
  49208. }
  49209. interface Scene {
  49210. /**
  49211. * @hidden
  49212. * Backing field
  49213. */
  49214. _debugLayer: DebugLayer;
  49215. /**
  49216. * Gets the debug layer (aka Inspector) associated with the scene
  49217. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49218. */
  49219. debugLayer: DebugLayer;
  49220. }
  49221. /**
  49222. * Enum of inspector action tab
  49223. */
  49224. export enum DebugLayerTab {
  49225. /**
  49226. * Properties tag (default)
  49227. */
  49228. Properties = 0,
  49229. /**
  49230. * Debug tab
  49231. */
  49232. Debug = 1,
  49233. /**
  49234. * Statistics tab
  49235. */
  49236. Statistics = 2,
  49237. /**
  49238. * Tools tab
  49239. */
  49240. Tools = 3,
  49241. /**
  49242. * Settings tab
  49243. */
  49244. Settings = 4
  49245. }
  49246. /**
  49247. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49248. * what is happening in your scene
  49249. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49250. */
  49251. export class DebugLayer {
  49252. /**
  49253. * Define the url to get the inspector script from.
  49254. * By default it uses the babylonjs CDN.
  49255. * @ignoreNaming
  49256. */
  49257. static InspectorURL: string;
  49258. private _scene;
  49259. private BJSINSPECTOR;
  49260. private _onPropertyChangedObservable?;
  49261. /**
  49262. * Observable triggered when a property is changed through the inspector.
  49263. */
  49264. get onPropertyChangedObservable(): any;
  49265. /**
  49266. * Instantiates a new debug layer.
  49267. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49268. * what is happening in your scene
  49269. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49270. * @param scene Defines the scene to inspect
  49271. */
  49272. constructor(scene: Scene);
  49273. /** Creates the inspector window. */
  49274. private _createInspector;
  49275. /**
  49276. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49277. * @param entity defines the entity to select
  49278. * @param lineContainerTitle defines the specific block to highlight
  49279. */
  49280. select(entity: any, lineContainerTitle?: string): void;
  49281. /** Get the inspector from bundle or global */
  49282. private _getGlobalInspector;
  49283. /**
  49284. * Get if the inspector is visible or not.
  49285. * @returns true if visible otherwise, false
  49286. */
  49287. isVisible(): boolean;
  49288. /**
  49289. * Hide the inspector and close its window.
  49290. */
  49291. hide(): void;
  49292. /**
  49293. * Update the scene in the inspector
  49294. */
  49295. setAsActiveScene(): void;
  49296. /**
  49297. * Launch the debugLayer.
  49298. * @param config Define the configuration of the inspector
  49299. * @return a promise fulfilled when the debug layer is visible
  49300. */
  49301. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49302. }
  49303. }
  49304. declare module BABYLON {
  49305. /**
  49306. * Class containing static functions to help procedurally build meshes
  49307. */
  49308. export class BoxBuilder {
  49309. /**
  49310. * Creates a box mesh
  49311. * * The parameter `size` sets the size (float) of each box side (default 1)
  49312. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49313. * * 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)
  49314. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49316. * * 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
  49317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49318. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49319. * @param name defines the name of the mesh
  49320. * @param options defines the options used to create the mesh
  49321. * @param scene defines the hosting scene
  49322. * @returns the box mesh
  49323. */
  49324. static CreateBox(name: string, options: {
  49325. size?: number;
  49326. width?: number;
  49327. height?: number;
  49328. depth?: number;
  49329. faceUV?: Vector4[];
  49330. faceColors?: Color4[];
  49331. sideOrientation?: number;
  49332. frontUVs?: Vector4;
  49333. backUVs?: Vector4;
  49334. wrap?: boolean;
  49335. topBaseAt?: number;
  49336. bottomBaseAt?: number;
  49337. updatable?: boolean;
  49338. }, scene?: Nullable<Scene>): Mesh;
  49339. }
  49340. }
  49341. declare module BABYLON.Debug {
  49342. /**
  49343. * Used to show the physics impostor around the specific mesh
  49344. */
  49345. export class PhysicsViewer {
  49346. /** @hidden */
  49347. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49348. /** @hidden */
  49349. protected _meshes: Array<Nullable<AbstractMesh>>;
  49350. /** @hidden */
  49351. protected _scene: Nullable<Scene>;
  49352. /** @hidden */
  49353. protected _numMeshes: number;
  49354. /** @hidden */
  49355. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49356. private _renderFunction;
  49357. private _utilityLayer;
  49358. private _debugBoxMesh;
  49359. private _debugSphereMesh;
  49360. private _debugCylinderMesh;
  49361. private _debugMaterial;
  49362. private _debugMeshMeshes;
  49363. /**
  49364. * Creates a new PhysicsViewer
  49365. * @param scene defines the hosting scene
  49366. */
  49367. constructor(scene: Scene);
  49368. /** @hidden */
  49369. protected _updateDebugMeshes(): void;
  49370. /**
  49371. * Renders a specified physic impostor
  49372. * @param impostor defines the impostor to render
  49373. * @param targetMesh defines the mesh represented by the impostor
  49374. * @returns the new debug mesh used to render the impostor
  49375. */
  49376. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49377. /**
  49378. * Hides a specified physic impostor
  49379. * @param impostor defines the impostor to hide
  49380. */
  49381. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49382. private _getDebugMaterial;
  49383. private _getDebugBoxMesh;
  49384. private _getDebugSphereMesh;
  49385. private _getDebugCylinderMesh;
  49386. private _getDebugMeshMesh;
  49387. private _getDebugMesh;
  49388. /** Releases all resources */
  49389. dispose(): void;
  49390. }
  49391. }
  49392. declare module BABYLON {
  49393. /**
  49394. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49395. * in order to better appreciate the issue one might have.
  49396. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49397. */
  49398. export class RayHelper {
  49399. /**
  49400. * Defines the ray we are currently tryin to visualize.
  49401. */
  49402. ray: Nullable<Ray>;
  49403. private _renderPoints;
  49404. private _renderLine;
  49405. private _renderFunction;
  49406. private _scene;
  49407. private _updateToMeshFunction;
  49408. private _attachedToMesh;
  49409. private _meshSpaceDirection;
  49410. private _meshSpaceOrigin;
  49411. /**
  49412. * Helper function to create a colored helper in a scene in one line.
  49413. * @param ray Defines the ray we are currently tryin to visualize
  49414. * @param scene Defines the scene the ray is used in
  49415. * @param color Defines the color we want to see the ray in
  49416. * @returns The newly created ray helper.
  49417. */
  49418. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49419. /**
  49420. * Instantiate a new ray helper.
  49421. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49422. * in order to better appreciate the issue one might have.
  49423. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49424. * @param ray Defines the ray we are currently tryin to visualize
  49425. */
  49426. constructor(ray: Ray);
  49427. /**
  49428. * Shows the ray we are willing to debug.
  49429. * @param scene Defines the scene the ray needs to be rendered in
  49430. * @param color Defines the color the ray needs to be rendered in
  49431. */
  49432. show(scene: Scene, color?: Color3): void;
  49433. /**
  49434. * Hides the ray we are debugging.
  49435. */
  49436. hide(): void;
  49437. private _render;
  49438. /**
  49439. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49440. * @param mesh Defines the mesh we want the helper attached to
  49441. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49442. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49443. * @param length Defines the length of the ray
  49444. */
  49445. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49446. /**
  49447. * Detach the ray helper from the mesh it has previously been attached to.
  49448. */
  49449. detachFromMesh(): void;
  49450. private _updateToMesh;
  49451. /**
  49452. * Dispose the helper and release its associated resources.
  49453. */
  49454. dispose(): void;
  49455. }
  49456. }
  49457. declare module BABYLON.Debug {
  49458. /**
  49459. * Class used to render a debug view of a given skeleton
  49460. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49461. */
  49462. export class SkeletonViewer {
  49463. /** defines the skeleton to render */
  49464. skeleton: Skeleton;
  49465. /** defines the mesh attached to the skeleton */
  49466. mesh: AbstractMesh;
  49467. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49468. autoUpdateBonesMatrices: boolean;
  49469. /** defines the rendering group id to use with the viewer */
  49470. renderingGroupId: number;
  49471. /** Gets or sets the color used to render the skeleton */
  49472. color: Color3;
  49473. private _scene;
  49474. private _debugLines;
  49475. private _debugMesh;
  49476. private _isEnabled;
  49477. private _renderFunction;
  49478. private _utilityLayer;
  49479. /**
  49480. * Returns the mesh used to render the bones
  49481. */
  49482. get debugMesh(): Nullable<LinesMesh>;
  49483. /**
  49484. * Creates a new SkeletonViewer
  49485. * @param skeleton defines the skeleton to render
  49486. * @param mesh defines the mesh attached to the skeleton
  49487. * @param scene defines the hosting scene
  49488. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49489. * @param renderingGroupId defines the rendering group id to use with the viewer
  49490. */
  49491. constructor(
  49492. /** defines the skeleton to render */
  49493. skeleton: Skeleton,
  49494. /** defines the mesh attached to the skeleton */
  49495. mesh: AbstractMesh, scene: Scene,
  49496. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49497. autoUpdateBonesMatrices?: boolean,
  49498. /** defines the rendering group id to use with the viewer */
  49499. renderingGroupId?: number);
  49500. /** Gets or sets a boolean indicating if the viewer is enabled */
  49501. set isEnabled(value: boolean);
  49502. get isEnabled(): boolean;
  49503. private _getBonePosition;
  49504. private _getLinesForBonesWithLength;
  49505. private _getLinesForBonesNoLength;
  49506. /** Update the viewer to sync with current skeleton state */
  49507. update(): void;
  49508. /** Release associated resources */
  49509. dispose(): void;
  49510. }
  49511. }
  49512. declare module BABYLON {
  49513. /**
  49514. * Enum for Device Types
  49515. */
  49516. export enum DeviceType {
  49517. /** Generic */
  49518. Generic = 0,
  49519. /** Keyboard */
  49520. Keyboard = 1,
  49521. /** Mouse */
  49522. Mouse = 2,
  49523. /** Touch Pointers */
  49524. Touch = 3,
  49525. /** PS4 Dual Shock */
  49526. DualShock = 4,
  49527. /** Xbox */
  49528. Xbox = 5,
  49529. /** Switch Controller */
  49530. Switch = 6
  49531. }
  49532. /**
  49533. * Enum for All Pointers (Touch/Mouse)
  49534. */
  49535. export enum PointerInput {
  49536. /** Horizontal Axis */
  49537. Horizontal = 0,
  49538. /** Vertical Axis */
  49539. Vertical = 1,
  49540. /** Left Click or Touch */
  49541. LeftClick = 2,
  49542. /** Middle Click */
  49543. MiddleClick = 3,
  49544. /** Right Click */
  49545. RightClick = 4,
  49546. /** Browser Back */
  49547. BrowserBack = 5,
  49548. /** Browser Forward */
  49549. BrowserForward = 6
  49550. }
  49551. /**
  49552. * Enum for Dual Shock Gamepad
  49553. */
  49554. export enum DualShockInput {
  49555. /** Cross */
  49556. Cross = 0,
  49557. /** Circle */
  49558. Circle = 1,
  49559. /** Square */
  49560. Square = 2,
  49561. /** Triangle */
  49562. Triangle = 3,
  49563. /** L1 */
  49564. L1 = 4,
  49565. /** R1 */
  49566. R1 = 5,
  49567. /** L2 */
  49568. L2 = 6,
  49569. /** R2 */
  49570. R2 = 7,
  49571. /** Share */
  49572. Share = 8,
  49573. /** Options */
  49574. Options = 9,
  49575. /** L3 */
  49576. L3 = 10,
  49577. /** R3 */
  49578. R3 = 11,
  49579. /** DPadUp */
  49580. DPadUp = 12,
  49581. /** DPadDown */
  49582. DPadDown = 13,
  49583. /** DPadLeft */
  49584. DPadLeft = 14,
  49585. /** DRight */
  49586. DPadRight = 15,
  49587. /** Home */
  49588. Home = 16,
  49589. /** TouchPad */
  49590. TouchPad = 17,
  49591. /** LStickXAxis */
  49592. LStickXAxis = 18,
  49593. /** LStickYAxis */
  49594. LStickYAxis = 19,
  49595. /** RStickXAxis */
  49596. RStickXAxis = 20,
  49597. /** RStickYAxis */
  49598. RStickYAxis = 21
  49599. }
  49600. /**
  49601. * Enum for Xbox Gamepad
  49602. */
  49603. export enum XboxInput {
  49604. /** A */
  49605. A = 0,
  49606. /** B */
  49607. B = 1,
  49608. /** X */
  49609. X = 2,
  49610. /** Y */
  49611. Y = 3,
  49612. /** LB */
  49613. LB = 4,
  49614. /** RB */
  49615. RB = 5,
  49616. /** LT */
  49617. LT = 6,
  49618. /** RT */
  49619. RT = 7,
  49620. /** Back */
  49621. Back = 8,
  49622. /** Start */
  49623. Start = 9,
  49624. /** LS */
  49625. LS = 10,
  49626. /** RS */
  49627. RS = 11,
  49628. /** DPadUp */
  49629. DPadUp = 12,
  49630. /** DPadDown */
  49631. DPadDown = 13,
  49632. /** DPadLeft */
  49633. DPadLeft = 14,
  49634. /** DRight */
  49635. DPadRight = 15,
  49636. /** Home */
  49637. Home = 16,
  49638. /** LStickXAxis */
  49639. LStickXAxis = 17,
  49640. /** LStickYAxis */
  49641. LStickYAxis = 18,
  49642. /** RStickXAxis */
  49643. RStickXAxis = 19,
  49644. /** RStickYAxis */
  49645. RStickYAxis = 20
  49646. }
  49647. /**
  49648. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  49649. */
  49650. export enum SwitchInput {
  49651. /** B */
  49652. B = 0,
  49653. /** A */
  49654. A = 1,
  49655. /** Y */
  49656. Y = 2,
  49657. /** X */
  49658. X = 3,
  49659. /** L */
  49660. L = 4,
  49661. /** R */
  49662. R = 5,
  49663. /** ZL */
  49664. ZL = 6,
  49665. /** ZR */
  49666. ZR = 7,
  49667. /** Minus */
  49668. Minus = 8,
  49669. /** Plus */
  49670. Plus = 9,
  49671. /** LS */
  49672. LS = 10,
  49673. /** RS */
  49674. RS = 11,
  49675. /** DPadUp */
  49676. DPadUp = 12,
  49677. /** DPadDown */
  49678. DPadDown = 13,
  49679. /** DPadLeft */
  49680. DPadLeft = 14,
  49681. /** DRight */
  49682. DPadRight = 15,
  49683. /** Home */
  49684. Home = 16,
  49685. /** Capture */
  49686. Capture = 17,
  49687. /** LStickXAxis */
  49688. LStickXAxis = 18,
  49689. /** LStickYAxis */
  49690. LStickYAxis = 19,
  49691. /** RStickXAxis */
  49692. RStickXAxis = 20,
  49693. /** RStickYAxis */
  49694. RStickYAxis = 21
  49695. }
  49696. }
  49697. declare module BABYLON {
  49698. /**
  49699. * This class will take all inputs from Keyboard, Pointer, and
  49700. * any Gamepads and provide a polling system that all devices
  49701. * will use. This class assumes that there will only be one
  49702. * pointer device and one keyboard.
  49703. */
  49704. export class DeviceInputSystem implements IDisposable {
  49705. /**
  49706. * Callback to be triggered when a device is connected
  49707. */
  49708. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49709. /**
  49710. * Callback to be triggered when a device is disconnected
  49711. */
  49712. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49713. /**
  49714. * Callback to be triggered when event driven input is updated
  49715. */
  49716. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  49717. private _inputs;
  49718. private _gamepads;
  49719. private _keyboardActive;
  49720. private _pointerActive;
  49721. private _elementToAttachTo;
  49722. private _keyboardDownEvent;
  49723. private _keyboardUpEvent;
  49724. private _pointerMoveEvent;
  49725. private _pointerDownEvent;
  49726. private _pointerUpEvent;
  49727. private _gamepadConnectedEvent;
  49728. private _gamepadDisconnectedEvent;
  49729. private static _MAX_KEYCODES;
  49730. private static _MAX_POINTER_INPUTS;
  49731. /**
  49732. * Default Constructor
  49733. * @param engine - engine to pull input element from
  49734. */
  49735. constructor(engine: Engine);
  49736. /**
  49737. * Checks for current device input value, given an id and input index
  49738. * @param deviceName Id of connected device
  49739. * @param inputIndex Index of device input
  49740. * @returns Current value of input
  49741. */
  49742. /**
  49743. * Checks for current device input value, given an id and input index
  49744. * @param deviceType Enum specifiying device type
  49745. * @param deviceSlot "Slot" or index that device is referenced in
  49746. * @param inputIndex Id of input to be checked
  49747. * @returns Current value of input
  49748. */
  49749. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  49750. /**
  49751. * Dispose of all the eventlisteners
  49752. */
  49753. dispose(): void;
  49754. /**
  49755. * Add device and inputs to device array
  49756. * @param deviceType Enum specifiying device type
  49757. * @param deviceSlot "Slot" or index that device is referenced in
  49758. * @param numberOfInputs Number of input entries to create for given device
  49759. */
  49760. private _registerDevice;
  49761. /**
  49762. * Given a specific device name, remove that device from the device map
  49763. * @param deviceType Enum specifiying device type
  49764. * @param deviceSlot "Slot" or index that device is referenced in
  49765. */
  49766. private _unregisterDevice;
  49767. /**
  49768. * Handle all actions that come from keyboard interaction
  49769. */
  49770. private _handleKeyActions;
  49771. /**
  49772. * Handle all actions that come from pointer interaction
  49773. */
  49774. private _handlePointerActions;
  49775. /**
  49776. * Handle all actions that come from gamepad interaction
  49777. */
  49778. private _handleGamepadActions;
  49779. /**
  49780. * Update all non-event based devices with each frame
  49781. * @param deviceType Enum specifiying device type
  49782. * @param deviceSlot "Slot" or index that device is referenced in
  49783. * @param inputIndex Id of input to be checked
  49784. */
  49785. private _updateDevice;
  49786. /**
  49787. * Gets DeviceType from the device name
  49788. * @param deviceName Name of Device from DeviceInputSystem
  49789. * @returns DeviceType enum value
  49790. */
  49791. private _getGamepadDeviceType;
  49792. }
  49793. }
  49794. declare module BABYLON {
  49795. /**
  49796. * Type to handle enforcement of inputs
  49797. */
  49798. 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;
  49799. }
  49800. declare module BABYLON {
  49801. /**
  49802. * Class that handles all input for a specific device
  49803. */
  49804. export class DeviceSource<T extends DeviceType> {
  49805. /** Type of device */
  49806. readonly deviceType: DeviceType;
  49807. /** "Slot" or index that device is referenced in */
  49808. readonly deviceSlot: number;
  49809. /**
  49810. * Observable to handle device input changes per device
  49811. */
  49812. readonly onInputChangedObservable: Observable<{
  49813. inputIndex: DeviceInput<T>;
  49814. previousState: Nullable<number>;
  49815. currentState: Nullable<number>;
  49816. }>;
  49817. private readonly _deviceInputSystem;
  49818. /**
  49819. * Default Constructor
  49820. * @param deviceInputSystem Reference to DeviceInputSystem
  49821. * @param deviceType Type of device
  49822. * @param deviceSlot "Slot" or index that device is referenced in
  49823. */
  49824. constructor(deviceInputSystem: DeviceInputSystem,
  49825. /** Type of device */
  49826. deviceType: DeviceType,
  49827. /** "Slot" or index that device is referenced in */
  49828. deviceSlot?: number);
  49829. /**
  49830. * Get input for specific input
  49831. * @param inputIndex index of specific input on device
  49832. * @returns Input value from DeviceInputSystem
  49833. */
  49834. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  49835. }
  49836. /**
  49837. * Class to keep track of devices
  49838. */
  49839. export class DeviceSourceManager implements IDisposable {
  49840. /**
  49841. * Observable to be triggered when before a device is connected
  49842. */
  49843. readonly onBeforeDeviceConnectedObservable: Observable<{
  49844. deviceType: DeviceType;
  49845. deviceSlot: number;
  49846. }>;
  49847. /**
  49848. * Observable to be triggered when before a device is disconnected
  49849. */
  49850. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  49851. deviceType: DeviceType;
  49852. deviceSlot: number;
  49853. }>;
  49854. /**
  49855. * Observable to be triggered when after a device is connected
  49856. */
  49857. readonly onAfterDeviceConnectedObservable: Observable<{
  49858. deviceType: DeviceType;
  49859. deviceSlot: number;
  49860. }>;
  49861. /**
  49862. * Observable to be triggered when after a device is disconnected
  49863. */
  49864. readonly onAfterDeviceDisconnectedObservable: Observable<{
  49865. deviceType: DeviceType;
  49866. deviceSlot: number;
  49867. }>;
  49868. private readonly _devices;
  49869. private readonly _firstDevice;
  49870. private readonly _deviceInputSystem;
  49871. /**
  49872. * Default Constructor
  49873. * @param engine engine to pull input element from
  49874. */
  49875. constructor(engine: Engine);
  49876. /**
  49877. * Gets a DeviceSource, given a type and slot
  49878. * @param deviceType Enum specifying device type
  49879. * @param deviceSlot "Slot" or index that device is referenced in
  49880. * @returns DeviceSource object
  49881. */
  49882. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  49883. /**
  49884. * Gets an array of DeviceSource objects for a given device type
  49885. * @param deviceType Enum specifying device type
  49886. * @returns Array of DeviceSource objects
  49887. */
  49888. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  49889. /**
  49890. * Dispose of DeviceInputSystem and other parts
  49891. */
  49892. dispose(): void;
  49893. /**
  49894. * Function to add device name to device list
  49895. * @param deviceType Enum specifying device type
  49896. * @param deviceSlot "Slot" or index that device is referenced in
  49897. */
  49898. private _addDevice;
  49899. /**
  49900. * Function to remove device name to device list
  49901. * @param deviceType Enum specifying device type
  49902. * @param deviceSlot "Slot" or index that device is referenced in
  49903. */
  49904. private _removeDevice;
  49905. /**
  49906. * Updates array storing first connected device of each type
  49907. * @param type Type of Device
  49908. */
  49909. private _updateFirstDevices;
  49910. }
  49911. }
  49912. declare module BABYLON {
  49913. /**
  49914. * Options to create the null engine
  49915. */
  49916. export class NullEngineOptions {
  49917. /**
  49918. * Render width (Default: 512)
  49919. */
  49920. renderWidth: number;
  49921. /**
  49922. * Render height (Default: 256)
  49923. */
  49924. renderHeight: number;
  49925. /**
  49926. * Texture size (Default: 512)
  49927. */
  49928. textureSize: number;
  49929. /**
  49930. * If delta time between frames should be constant
  49931. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49932. */
  49933. deterministicLockstep: boolean;
  49934. /**
  49935. * Maximum about of steps between frames (Default: 4)
  49936. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49937. */
  49938. lockstepMaxSteps: number;
  49939. }
  49940. /**
  49941. * The null engine class provides support for headless version of babylon.js.
  49942. * This can be used in server side scenario or for testing purposes
  49943. */
  49944. export class NullEngine extends Engine {
  49945. private _options;
  49946. /**
  49947. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  49948. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49949. * @returns true if engine is in deterministic lock step mode
  49950. */
  49951. isDeterministicLockStep(): boolean;
  49952. /**
  49953. * Gets the max steps when engine is running in deterministic lock step
  49954. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49955. * @returns the max steps
  49956. */
  49957. getLockstepMaxSteps(): number;
  49958. /**
  49959. * Gets the current hardware scaling level.
  49960. * By default the hardware scaling level is computed from the window device ratio.
  49961. * 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.
  49962. * @returns a number indicating the current hardware scaling level
  49963. */
  49964. getHardwareScalingLevel(): number;
  49965. constructor(options?: NullEngineOptions);
  49966. /**
  49967. * Creates a vertex buffer
  49968. * @param vertices the data for the vertex buffer
  49969. * @returns the new WebGL static buffer
  49970. */
  49971. createVertexBuffer(vertices: FloatArray): DataBuffer;
  49972. /**
  49973. * Creates a new index buffer
  49974. * @param indices defines the content of the index buffer
  49975. * @param updatable defines if the index buffer must be updatable
  49976. * @returns a new webGL buffer
  49977. */
  49978. createIndexBuffer(indices: IndicesArray): DataBuffer;
  49979. /**
  49980. * Clear the current render buffer or the current render target (if any is set up)
  49981. * @param color defines the color to use
  49982. * @param backBuffer defines if the back buffer must be cleared
  49983. * @param depth defines if the depth buffer must be cleared
  49984. * @param stencil defines if the stencil buffer must be cleared
  49985. */
  49986. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49987. /**
  49988. * Gets the current render width
  49989. * @param useScreen defines if screen size must be used (or the current render target if any)
  49990. * @returns a number defining the current render width
  49991. */
  49992. getRenderWidth(useScreen?: boolean): number;
  49993. /**
  49994. * Gets the current render height
  49995. * @param useScreen defines if screen size must be used (or the current render target if any)
  49996. * @returns a number defining the current render height
  49997. */
  49998. getRenderHeight(useScreen?: boolean): number;
  49999. /**
  50000. * Set the WebGL's viewport
  50001. * @param viewport defines the viewport element to be used
  50002. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50003. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50004. */
  50005. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50006. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50007. /**
  50008. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50009. * @param pipelineContext defines the pipeline context to use
  50010. * @param uniformsNames defines the list of uniform names
  50011. * @returns an array of webGL uniform locations
  50012. */
  50013. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50014. /**
  50015. * Gets the lsit of active attributes for a given webGL program
  50016. * @param pipelineContext defines the pipeline context to use
  50017. * @param attributesNames defines the list of attribute names to get
  50018. * @returns an array of indices indicating the offset of each attribute
  50019. */
  50020. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50021. /**
  50022. * Binds an effect to the webGL context
  50023. * @param effect defines the effect to bind
  50024. */
  50025. bindSamplers(effect: Effect): void;
  50026. /**
  50027. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50028. * @param effect defines the effect to activate
  50029. */
  50030. enableEffect(effect: Effect): void;
  50031. /**
  50032. * Set various states to the webGL context
  50033. * @param culling defines backface culling state
  50034. * @param zOffset defines the value to apply to zOffset (0 by default)
  50035. * @param force defines if states must be applied even if cache is up to date
  50036. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50037. */
  50038. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50039. /**
  50040. * Set the value of an uniform to an array of int32
  50041. * @param uniform defines the webGL uniform location where to store the value
  50042. * @param array defines the array of int32 to store
  50043. */
  50044. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50045. /**
  50046. * Set the value of an uniform to an array of int32 (stored as vec2)
  50047. * @param uniform defines the webGL uniform location where to store the value
  50048. * @param array defines the array of int32 to store
  50049. */
  50050. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50051. /**
  50052. * Set the value of an uniform to an array of int32 (stored as vec3)
  50053. * @param uniform defines the webGL uniform location where to store the value
  50054. * @param array defines the array of int32 to store
  50055. */
  50056. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50057. /**
  50058. * Set the value of an uniform to an array of int32 (stored as vec4)
  50059. * @param uniform defines the webGL uniform location where to store the value
  50060. * @param array defines the array of int32 to store
  50061. */
  50062. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50063. /**
  50064. * Set the value of an uniform to an array of float32
  50065. * @param uniform defines the webGL uniform location where to store the value
  50066. * @param array defines the array of float32 to store
  50067. */
  50068. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50069. /**
  50070. * Set the value of an uniform to an array of float32 (stored as vec2)
  50071. * @param uniform defines the webGL uniform location where to store the value
  50072. * @param array defines the array of float32 to store
  50073. */
  50074. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50075. /**
  50076. * Set the value of an uniform to an array of float32 (stored as vec3)
  50077. * @param uniform defines the webGL uniform location where to store the value
  50078. * @param array defines the array of float32 to store
  50079. */
  50080. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50081. /**
  50082. * Set the value of an uniform to an array of float32 (stored as vec4)
  50083. * @param uniform defines the webGL uniform location where to store the value
  50084. * @param array defines the array of float32 to store
  50085. */
  50086. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50087. /**
  50088. * Set the value of an uniform to an array of number
  50089. * @param uniform defines the webGL uniform location where to store the value
  50090. * @param array defines the array of number to store
  50091. */
  50092. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50093. /**
  50094. * Set the value of an uniform to an array of number (stored as vec2)
  50095. * @param uniform defines the webGL uniform location where to store the value
  50096. * @param array defines the array of number to store
  50097. */
  50098. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50099. /**
  50100. * Set the value of an uniform to an array of number (stored as vec3)
  50101. * @param uniform defines the webGL uniform location where to store the value
  50102. * @param array defines the array of number to store
  50103. */
  50104. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50105. /**
  50106. * Set the value of an uniform to an array of number (stored as vec4)
  50107. * @param uniform defines the webGL uniform location where to store the value
  50108. * @param array defines the array of number to store
  50109. */
  50110. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50111. /**
  50112. * Set the value of an uniform to an array of float32 (stored as matrices)
  50113. * @param uniform defines the webGL uniform location where to store the value
  50114. * @param matrices defines the array of float32 to store
  50115. */
  50116. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50117. /**
  50118. * Set the value of an uniform to a matrix (3x3)
  50119. * @param uniform defines the webGL uniform location where to store the value
  50120. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50121. */
  50122. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50123. /**
  50124. * Set the value of an uniform to a matrix (2x2)
  50125. * @param uniform defines the webGL uniform location where to store the value
  50126. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50127. */
  50128. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50129. /**
  50130. * Set the value of an uniform to a number (float)
  50131. * @param uniform defines the webGL uniform location where to store the value
  50132. * @param value defines the float number to store
  50133. */
  50134. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50135. /**
  50136. * Set the value of an uniform to a vec2
  50137. * @param uniform defines the webGL uniform location where to store the value
  50138. * @param x defines the 1st component of the value
  50139. * @param y defines the 2nd component of the value
  50140. */
  50141. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50142. /**
  50143. * Set the value of an uniform to a vec3
  50144. * @param uniform defines the webGL uniform location where to store the value
  50145. * @param x defines the 1st component of the value
  50146. * @param y defines the 2nd component of the value
  50147. * @param z defines the 3rd component of the value
  50148. */
  50149. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50150. /**
  50151. * Set the value of an uniform to a boolean
  50152. * @param uniform defines the webGL uniform location where to store the value
  50153. * @param bool defines the boolean to store
  50154. */
  50155. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50156. /**
  50157. * Set the value of an uniform to a vec4
  50158. * @param uniform defines the webGL uniform location where to store the value
  50159. * @param x defines the 1st component of the value
  50160. * @param y defines the 2nd component of the value
  50161. * @param z defines the 3rd component of the value
  50162. * @param w defines the 4th component of the value
  50163. */
  50164. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50165. /**
  50166. * Sets the current alpha mode
  50167. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50168. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50169. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50170. */
  50171. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50172. /**
  50173. * Bind webGl buffers directly to the webGL context
  50174. * @param vertexBuffers defines the vertex buffer to bind
  50175. * @param indexBuffer defines the index buffer to bind
  50176. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50177. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50178. * @param effect defines the effect associated with the vertex buffer
  50179. */
  50180. bindBuffers(vertexBuffers: {
  50181. [key: string]: VertexBuffer;
  50182. }, indexBuffer: DataBuffer, effect: Effect): void;
  50183. /**
  50184. * Force the entire cache to be cleared
  50185. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50186. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50187. */
  50188. wipeCaches(bruteForce?: boolean): void;
  50189. /**
  50190. * Send a draw order
  50191. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50192. * @param indexStart defines the starting index
  50193. * @param indexCount defines the number of index to draw
  50194. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50195. */
  50196. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50197. /**
  50198. * Draw a list of indexed primitives
  50199. * @param fillMode defines the primitive to use
  50200. * @param indexStart defines the starting index
  50201. * @param indexCount defines the number of index to draw
  50202. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50203. */
  50204. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50205. /**
  50206. * Draw a list of unindexed primitives
  50207. * @param fillMode defines the primitive to use
  50208. * @param verticesStart defines the index of first vertex to draw
  50209. * @param verticesCount defines the count of vertices to draw
  50210. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50211. */
  50212. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50213. /** @hidden */
  50214. _createTexture(): WebGLTexture;
  50215. /** @hidden */
  50216. _releaseTexture(texture: InternalTexture): void;
  50217. /**
  50218. * Usually called from Texture.ts.
  50219. * Passed information to create a WebGLTexture
  50220. * @param urlArg defines a value which contains one of the following:
  50221. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50222. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50223. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50224. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50225. * @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)
  50226. * @param scene needed for loading to the correct scene
  50227. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50228. * @param onLoad optional callback to be called upon successful completion
  50229. * @param onError optional callback to be called upon failure
  50230. * @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
  50231. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50232. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50233. * @param forcedExtension defines the extension to use to pick the right loader
  50234. * @param mimeType defines an optional mime type
  50235. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50236. */
  50237. 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;
  50238. /**
  50239. * Creates a new render target texture
  50240. * @param size defines the size of the texture
  50241. * @param options defines the options used to create the texture
  50242. * @returns a new render target texture stored in an InternalTexture
  50243. */
  50244. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50245. /**
  50246. * Update the sampling mode of a given texture
  50247. * @param samplingMode defines the required sampling mode
  50248. * @param texture defines the texture to update
  50249. */
  50250. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50251. /**
  50252. * Binds the frame buffer to the specified texture.
  50253. * @param texture The texture to render to or null for the default canvas
  50254. * @param faceIndex The face of the texture to render to in case of cube texture
  50255. * @param requiredWidth The width of the target to render to
  50256. * @param requiredHeight The height of the target to render to
  50257. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50258. * @param lodLevel defines le lod level to bind to the frame buffer
  50259. */
  50260. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50261. /**
  50262. * Unbind the current render target texture from the webGL context
  50263. * @param texture defines the render target texture to unbind
  50264. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50265. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50266. */
  50267. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50268. /**
  50269. * Creates a dynamic vertex buffer
  50270. * @param vertices the data for the dynamic vertex buffer
  50271. * @returns the new WebGL dynamic buffer
  50272. */
  50273. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50274. /**
  50275. * Update the content of a dynamic texture
  50276. * @param texture defines the texture to update
  50277. * @param canvas defines the canvas containing the source
  50278. * @param invertY defines if data must be stored with Y axis inverted
  50279. * @param premulAlpha defines if alpha is stored as premultiplied
  50280. * @param format defines the format of the data
  50281. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50282. */
  50283. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50284. /**
  50285. * Gets a boolean indicating if all created effects are ready
  50286. * @returns true if all effects are ready
  50287. */
  50288. areAllEffectsReady(): boolean;
  50289. /**
  50290. * @hidden
  50291. * Get the current error code of the webGL context
  50292. * @returns the error code
  50293. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50294. */
  50295. getError(): number;
  50296. /** @hidden */
  50297. _getUnpackAlignement(): number;
  50298. /** @hidden */
  50299. _unpackFlipY(value: boolean): void;
  50300. /**
  50301. * Update a dynamic index buffer
  50302. * @param indexBuffer defines the target index buffer
  50303. * @param indices defines the data to update
  50304. * @param offset defines the offset in the target index buffer where update should start
  50305. */
  50306. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50307. /**
  50308. * Updates a dynamic vertex buffer.
  50309. * @param vertexBuffer the vertex buffer to update
  50310. * @param vertices the data used to update the vertex buffer
  50311. * @param byteOffset the byte offset of the data (optional)
  50312. * @param byteLength the byte length of the data (optional)
  50313. */
  50314. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50315. /** @hidden */
  50316. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50317. /** @hidden */
  50318. _bindTexture(channel: number, texture: InternalTexture): void;
  50319. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50320. /**
  50321. * 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
  50322. */
  50323. releaseEffects(): void;
  50324. displayLoadingUI(): void;
  50325. hideLoadingUI(): void;
  50326. /** @hidden */
  50327. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50328. /** @hidden */
  50329. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50330. /** @hidden */
  50331. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50332. /** @hidden */
  50333. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50334. }
  50335. }
  50336. declare module BABYLON {
  50337. /**
  50338. * @hidden
  50339. **/
  50340. export class _TimeToken {
  50341. _startTimeQuery: Nullable<WebGLQuery>;
  50342. _endTimeQuery: Nullable<WebGLQuery>;
  50343. _timeElapsedQuery: Nullable<WebGLQuery>;
  50344. _timeElapsedQueryEnded: boolean;
  50345. }
  50346. }
  50347. declare module BABYLON {
  50348. /** @hidden */
  50349. export class _OcclusionDataStorage {
  50350. /** @hidden */
  50351. occlusionInternalRetryCounter: number;
  50352. /** @hidden */
  50353. isOcclusionQueryInProgress: boolean;
  50354. /** @hidden */
  50355. isOccluded: boolean;
  50356. /** @hidden */
  50357. occlusionRetryCount: number;
  50358. /** @hidden */
  50359. occlusionType: number;
  50360. /** @hidden */
  50361. occlusionQueryAlgorithmType: number;
  50362. }
  50363. interface Engine {
  50364. /**
  50365. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50366. * @return the new query
  50367. */
  50368. createQuery(): WebGLQuery;
  50369. /**
  50370. * Delete and release a webGL query
  50371. * @param query defines the query to delete
  50372. * @return the current engine
  50373. */
  50374. deleteQuery(query: WebGLQuery): Engine;
  50375. /**
  50376. * Check if a given query has resolved and got its value
  50377. * @param query defines the query to check
  50378. * @returns true if the query got its value
  50379. */
  50380. isQueryResultAvailable(query: WebGLQuery): boolean;
  50381. /**
  50382. * Gets the value of a given query
  50383. * @param query defines the query to check
  50384. * @returns the value of the query
  50385. */
  50386. getQueryResult(query: WebGLQuery): number;
  50387. /**
  50388. * Initiates an occlusion query
  50389. * @param algorithmType defines the algorithm to use
  50390. * @param query defines the query to use
  50391. * @returns the current engine
  50392. * @see http://doc.babylonjs.com/features/occlusionquery
  50393. */
  50394. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50395. /**
  50396. * Ends an occlusion query
  50397. * @see http://doc.babylonjs.com/features/occlusionquery
  50398. * @param algorithmType defines the algorithm to use
  50399. * @returns the current engine
  50400. */
  50401. endOcclusionQuery(algorithmType: number): Engine;
  50402. /**
  50403. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50404. * Please note that only one query can be issued at a time
  50405. * @returns a time token used to track the time span
  50406. */
  50407. startTimeQuery(): Nullable<_TimeToken>;
  50408. /**
  50409. * Ends a time query
  50410. * @param token defines the token used to measure the time span
  50411. * @returns the time spent (in ns)
  50412. */
  50413. endTimeQuery(token: _TimeToken): int;
  50414. /** @hidden */
  50415. _currentNonTimestampToken: Nullable<_TimeToken>;
  50416. /** @hidden */
  50417. _createTimeQuery(): WebGLQuery;
  50418. /** @hidden */
  50419. _deleteTimeQuery(query: WebGLQuery): void;
  50420. /** @hidden */
  50421. _getGlAlgorithmType(algorithmType: number): number;
  50422. /** @hidden */
  50423. _getTimeQueryResult(query: WebGLQuery): any;
  50424. /** @hidden */
  50425. _getTimeQueryAvailability(query: WebGLQuery): any;
  50426. }
  50427. interface AbstractMesh {
  50428. /**
  50429. * Backing filed
  50430. * @hidden
  50431. */
  50432. __occlusionDataStorage: _OcclusionDataStorage;
  50433. /**
  50434. * Access property
  50435. * @hidden
  50436. */
  50437. _occlusionDataStorage: _OcclusionDataStorage;
  50438. /**
  50439. * 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.
  50440. * The default value is -1 which means don't break the query and wait till the result
  50441. * @see http://doc.babylonjs.com/features/occlusionquery
  50442. */
  50443. occlusionRetryCount: number;
  50444. /**
  50445. * 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:
  50446. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50447. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50448. * * 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.
  50449. * @see http://doc.babylonjs.com/features/occlusionquery
  50450. */
  50451. occlusionType: number;
  50452. /**
  50453. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50454. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50455. * * 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.
  50456. * @see http://doc.babylonjs.com/features/occlusionquery
  50457. */
  50458. occlusionQueryAlgorithmType: number;
  50459. /**
  50460. * 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
  50461. * @see http://doc.babylonjs.com/features/occlusionquery
  50462. */
  50463. isOccluded: boolean;
  50464. /**
  50465. * Flag to check the progress status of the query
  50466. * @see http://doc.babylonjs.com/features/occlusionquery
  50467. */
  50468. isOcclusionQueryInProgress: boolean;
  50469. }
  50470. }
  50471. declare module BABYLON {
  50472. /** @hidden */
  50473. export var _forceTransformFeedbackToBundle: boolean;
  50474. interface Engine {
  50475. /**
  50476. * Creates a webGL transform feedback object
  50477. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50478. * @returns the webGL transform feedback object
  50479. */
  50480. createTransformFeedback(): WebGLTransformFeedback;
  50481. /**
  50482. * Delete a webGL transform feedback object
  50483. * @param value defines the webGL transform feedback object to delete
  50484. */
  50485. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50486. /**
  50487. * Bind a webGL transform feedback object to the webgl context
  50488. * @param value defines the webGL transform feedback object to bind
  50489. */
  50490. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50491. /**
  50492. * Begins a transform feedback operation
  50493. * @param usePoints defines if points or triangles must be used
  50494. */
  50495. beginTransformFeedback(usePoints: boolean): void;
  50496. /**
  50497. * Ends a transform feedback operation
  50498. */
  50499. endTransformFeedback(): void;
  50500. /**
  50501. * Specify the varyings to use with transform feedback
  50502. * @param program defines the associated webGL program
  50503. * @param value defines the list of strings representing the varying names
  50504. */
  50505. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50506. /**
  50507. * Bind a webGL buffer for a transform feedback operation
  50508. * @param value defines the webGL buffer to bind
  50509. */
  50510. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50511. }
  50512. }
  50513. declare module BABYLON {
  50514. /**
  50515. * Creation options of the multi render target texture.
  50516. */
  50517. export interface IMultiRenderTargetOptions {
  50518. /**
  50519. * Define if the texture needs to create mip maps after render.
  50520. */
  50521. generateMipMaps?: boolean;
  50522. /**
  50523. * Define the types of all the draw buffers we want to create
  50524. */
  50525. types?: number[];
  50526. /**
  50527. * Define the sampling modes of all the draw buffers we want to create
  50528. */
  50529. samplingModes?: number[];
  50530. /**
  50531. * Define if a depth buffer is required
  50532. */
  50533. generateDepthBuffer?: boolean;
  50534. /**
  50535. * Define if a stencil buffer is required
  50536. */
  50537. generateStencilBuffer?: boolean;
  50538. /**
  50539. * Define if a depth texture is required instead of a depth buffer
  50540. */
  50541. generateDepthTexture?: boolean;
  50542. /**
  50543. * Define the number of desired draw buffers
  50544. */
  50545. textureCount?: number;
  50546. /**
  50547. * Define if aspect ratio should be adapted to the texture or stay the scene one
  50548. */
  50549. doNotChangeAspectRatio?: boolean;
  50550. /**
  50551. * Define the default type of the buffers we are creating
  50552. */
  50553. defaultType?: number;
  50554. }
  50555. /**
  50556. * A multi render target, like a render target provides the ability to render to a texture.
  50557. * Unlike the render target, it can render to several draw buffers in one draw.
  50558. * This is specially interesting in deferred rendering or for any effects requiring more than
  50559. * just one color from a single pass.
  50560. */
  50561. export class MultiRenderTarget extends RenderTargetTexture {
  50562. private _internalTextures;
  50563. private _textures;
  50564. private _multiRenderTargetOptions;
  50565. /**
  50566. * Get if draw buffers are currently supported by the used hardware and browser.
  50567. */
  50568. get isSupported(): boolean;
  50569. /**
  50570. * Get the list of textures generated by the multi render target.
  50571. */
  50572. get textures(): Texture[];
  50573. /**
  50574. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  50575. */
  50576. get depthTexture(): Texture;
  50577. /**
  50578. * Set the wrapping mode on U of all the textures we are rendering to.
  50579. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50580. */
  50581. set wrapU(wrap: number);
  50582. /**
  50583. * Set the wrapping mode on V of all the textures we are rendering to.
  50584. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50585. */
  50586. set wrapV(wrap: number);
  50587. /**
  50588. * Instantiate a new multi render target texture.
  50589. * A multi render target, like a render target provides the ability to render to a texture.
  50590. * Unlike the render target, it can render to several draw buffers in one draw.
  50591. * This is specially interesting in deferred rendering or for any effects requiring more than
  50592. * just one color from a single pass.
  50593. * @param name Define the name of the texture
  50594. * @param size Define the size of the buffers to render to
  50595. * @param count Define the number of target we are rendering into
  50596. * @param scene Define the scene the texture belongs to
  50597. * @param options Define the options used to create the multi render target
  50598. */
  50599. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  50600. /** @hidden */
  50601. _rebuild(): void;
  50602. private _createInternalTextures;
  50603. private _createTextures;
  50604. /**
  50605. * Define the number of samples used if MSAA is enabled.
  50606. */
  50607. get samples(): number;
  50608. set samples(value: number);
  50609. /**
  50610. * Resize all the textures in the multi render target.
  50611. * Be carrefull as it will recreate all the data in the new texture.
  50612. * @param size Define the new size
  50613. */
  50614. resize(size: any): void;
  50615. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  50616. /**
  50617. * Dispose the render targets and their associated resources
  50618. */
  50619. dispose(): void;
  50620. /**
  50621. * Release all the underlying texture used as draw buffers.
  50622. */
  50623. releaseInternalTextures(): void;
  50624. }
  50625. }
  50626. declare module BABYLON {
  50627. interface ThinEngine {
  50628. /**
  50629. * Unbind a list of render target textures from the webGL context
  50630. * This is used only when drawBuffer extension or webGL2 are active
  50631. * @param textures defines the render target textures to unbind
  50632. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50633. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50634. */
  50635. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  50636. /**
  50637. * Create a multi render target texture
  50638. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  50639. * @param size defines the size of the texture
  50640. * @param options defines the creation options
  50641. * @returns the cube texture as an InternalTexture
  50642. */
  50643. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  50644. /**
  50645. * Update the sample count for a given multiple render target texture
  50646. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  50647. * @param textures defines the textures to update
  50648. * @param samples defines the sample count to set
  50649. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  50650. */
  50651. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  50652. }
  50653. }
  50654. declare module BABYLON {
  50655. /**
  50656. * Class used to define an additional view for the engine
  50657. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50658. */
  50659. export class EngineView {
  50660. /** Defines the canvas where to render the view */
  50661. target: HTMLCanvasElement;
  50662. /** Defines an optional camera used to render the view (will use active camera else) */
  50663. camera?: Camera;
  50664. }
  50665. interface Engine {
  50666. /**
  50667. * Gets or sets the HTML element to use for attaching events
  50668. */
  50669. inputElement: Nullable<HTMLElement>;
  50670. /**
  50671. * Gets the current engine view
  50672. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50673. */
  50674. activeView: Nullable<EngineView>;
  50675. /** Gets or sets the list of views */
  50676. views: EngineView[];
  50677. /**
  50678. * Register a new child canvas
  50679. * @param canvas defines the canvas to register
  50680. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  50681. * @returns the associated view
  50682. */
  50683. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  50684. /**
  50685. * Remove a registered child canvas
  50686. * @param canvas defines the canvas to remove
  50687. * @returns the current engine
  50688. */
  50689. unRegisterView(canvas: HTMLCanvasElement): Engine;
  50690. }
  50691. }
  50692. declare module BABYLON {
  50693. interface Engine {
  50694. /** @hidden */
  50695. _excludedCompressedTextures: string[];
  50696. /** @hidden */
  50697. _textureFormatInUse: string;
  50698. /**
  50699. * Gets the list of texture formats supported
  50700. */
  50701. readonly texturesSupported: Array<string>;
  50702. /**
  50703. * Gets the texture format in use
  50704. */
  50705. readonly textureFormatInUse: Nullable<string>;
  50706. /**
  50707. * Set the compressed texture extensions or file names to skip.
  50708. *
  50709. * @param skippedFiles defines the list of those texture files you want to skip
  50710. * Example: [".dds", ".env", "myfile.png"]
  50711. */
  50712. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  50713. /**
  50714. * Set the compressed texture format to use, based on the formats you have, and the formats
  50715. * supported by the hardware / browser.
  50716. *
  50717. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  50718. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  50719. * to API arguments needed to compressed textures. This puts the burden on the container
  50720. * generator to house the arcane code for determining these for current & future formats.
  50721. *
  50722. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50723. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50724. *
  50725. * Note: The result of this call is not taken into account when a texture is base64.
  50726. *
  50727. * @param formatsAvailable defines the list of those format families you have created
  50728. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  50729. *
  50730. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  50731. * @returns The extension selected.
  50732. */
  50733. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  50734. }
  50735. }
  50736. declare module BABYLON {
  50737. /**
  50738. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50739. */
  50740. export interface CubeMapInfo {
  50741. /**
  50742. * The pixel array for the front face.
  50743. * This is stored in format, left to right, up to down format.
  50744. */
  50745. front: Nullable<ArrayBufferView>;
  50746. /**
  50747. * The pixel array for the back face.
  50748. * This is stored in format, left to right, up to down format.
  50749. */
  50750. back: Nullable<ArrayBufferView>;
  50751. /**
  50752. * The pixel array for the left face.
  50753. * This is stored in format, left to right, up to down format.
  50754. */
  50755. left: Nullable<ArrayBufferView>;
  50756. /**
  50757. * The pixel array for the right face.
  50758. * This is stored in format, left to right, up to down format.
  50759. */
  50760. right: Nullable<ArrayBufferView>;
  50761. /**
  50762. * The pixel array for the up face.
  50763. * This is stored in format, left to right, up to down format.
  50764. */
  50765. up: Nullable<ArrayBufferView>;
  50766. /**
  50767. * The pixel array for the down face.
  50768. * This is stored in format, left to right, up to down format.
  50769. */
  50770. down: Nullable<ArrayBufferView>;
  50771. /**
  50772. * The size of the cubemap stored.
  50773. *
  50774. * Each faces will be size * size pixels.
  50775. */
  50776. size: number;
  50777. /**
  50778. * The format of the texture.
  50779. *
  50780. * RGBA, RGB.
  50781. */
  50782. format: number;
  50783. /**
  50784. * The type of the texture data.
  50785. *
  50786. * UNSIGNED_INT, FLOAT.
  50787. */
  50788. type: number;
  50789. /**
  50790. * Specifies whether the texture is in gamma space.
  50791. */
  50792. gammaSpace: boolean;
  50793. }
  50794. /**
  50795. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50796. */
  50797. export class PanoramaToCubeMapTools {
  50798. private static FACE_LEFT;
  50799. private static FACE_RIGHT;
  50800. private static FACE_FRONT;
  50801. private static FACE_BACK;
  50802. private static FACE_DOWN;
  50803. private static FACE_UP;
  50804. /**
  50805. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50806. *
  50807. * @param float32Array The source data.
  50808. * @param inputWidth The width of the input panorama.
  50809. * @param inputHeight The height of the input panorama.
  50810. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50811. * @return The cubemap data
  50812. */
  50813. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50814. private static CreateCubemapTexture;
  50815. private static CalcProjectionSpherical;
  50816. }
  50817. }
  50818. declare module BABYLON {
  50819. /**
  50820. * Helper class dealing with the extraction of spherical polynomial dataArray
  50821. * from a cube map.
  50822. */
  50823. export class CubeMapToSphericalPolynomialTools {
  50824. private static FileFaces;
  50825. /**
  50826. * Converts a texture to the according Spherical Polynomial data.
  50827. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50828. *
  50829. * @param texture The texture to extract the information from.
  50830. * @return The Spherical Polynomial data.
  50831. */
  50832. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  50833. /**
  50834. * Converts a cubemap to the according Spherical Polynomial data.
  50835. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50836. *
  50837. * @param cubeInfo The Cube map to extract the information from.
  50838. * @return The Spherical Polynomial data.
  50839. */
  50840. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  50841. }
  50842. }
  50843. declare module BABYLON {
  50844. interface BaseTexture {
  50845. /**
  50846. * Get the polynomial representation of the texture data.
  50847. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  50848. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  50849. */
  50850. sphericalPolynomial: Nullable<SphericalPolynomial>;
  50851. }
  50852. }
  50853. declare module BABYLON {
  50854. /** @hidden */
  50855. export var rgbdEncodePixelShader: {
  50856. name: string;
  50857. shader: string;
  50858. };
  50859. }
  50860. declare module BABYLON {
  50861. /** @hidden */
  50862. export var rgbdDecodePixelShader: {
  50863. name: string;
  50864. shader: string;
  50865. };
  50866. }
  50867. declare module BABYLON {
  50868. /**
  50869. * Raw texture data and descriptor sufficient for WebGL texture upload
  50870. */
  50871. export interface EnvironmentTextureInfo {
  50872. /**
  50873. * Version of the environment map
  50874. */
  50875. version: number;
  50876. /**
  50877. * Width of image
  50878. */
  50879. width: number;
  50880. /**
  50881. * Irradiance information stored in the file.
  50882. */
  50883. irradiance: any;
  50884. /**
  50885. * Specular information stored in the file.
  50886. */
  50887. specular: any;
  50888. }
  50889. /**
  50890. * Defines One Image in the file. It requires only the position in the file
  50891. * as well as the length.
  50892. */
  50893. interface BufferImageData {
  50894. /**
  50895. * Length of the image data.
  50896. */
  50897. length: number;
  50898. /**
  50899. * Position of the data from the null terminator delimiting the end of the JSON.
  50900. */
  50901. position: number;
  50902. }
  50903. /**
  50904. * Defines the specular data enclosed in the file.
  50905. * This corresponds to the version 1 of the data.
  50906. */
  50907. export interface EnvironmentTextureSpecularInfoV1 {
  50908. /**
  50909. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  50910. */
  50911. specularDataPosition?: number;
  50912. /**
  50913. * This contains all the images data needed to reconstruct the cubemap.
  50914. */
  50915. mipmaps: Array<BufferImageData>;
  50916. /**
  50917. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  50918. */
  50919. lodGenerationScale: number;
  50920. }
  50921. /**
  50922. * Sets of helpers addressing the serialization and deserialization of environment texture
  50923. * stored in a BabylonJS env file.
  50924. * Those files are usually stored as .env files.
  50925. */
  50926. export class EnvironmentTextureTools {
  50927. /**
  50928. * Magic number identifying the env file.
  50929. */
  50930. private static _MagicBytes;
  50931. /**
  50932. * Gets the environment info from an env file.
  50933. * @param data The array buffer containing the .env bytes.
  50934. * @returns the environment file info (the json header) if successfully parsed.
  50935. */
  50936. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  50937. /**
  50938. * Creates an environment texture from a loaded cube texture.
  50939. * @param texture defines the cube texture to convert in env file
  50940. * @return a promise containing the environment data if succesfull.
  50941. */
  50942. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  50943. /**
  50944. * Creates a JSON representation of the spherical data.
  50945. * @param texture defines the texture containing the polynomials
  50946. * @return the JSON representation of the spherical info
  50947. */
  50948. private static _CreateEnvTextureIrradiance;
  50949. /**
  50950. * Creates the ArrayBufferViews used for initializing environment texture image data.
  50951. * @param data the image data
  50952. * @param info parameters that determine what views will be created for accessing the underlying buffer
  50953. * @return the views described by info providing access to the underlying buffer
  50954. */
  50955. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  50956. /**
  50957. * Uploads the texture info contained in the env file to the GPU.
  50958. * @param texture defines the internal texture to upload to
  50959. * @param data defines the data to load
  50960. * @param info defines the texture info retrieved through the GetEnvInfo method
  50961. * @returns a promise
  50962. */
  50963. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  50964. private static _OnImageReadyAsync;
  50965. /**
  50966. * Uploads the levels of image data to the GPU.
  50967. * @param texture defines the internal texture to upload to
  50968. * @param imageData defines the array buffer views of image data [mipmap][face]
  50969. * @returns a promise
  50970. */
  50971. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  50972. /**
  50973. * Uploads spherical polynomials information to the texture.
  50974. * @param texture defines the texture we are trying to upload the information to
  50975. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  50976. */
  50977. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  50978. /** @hidden */
  50979. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50980. }
  50981. }
  50982. declare module BABYLON {
  50983. /** @hidden */
  50984. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  50985. private _genericAttributeLocation;
  50986. private _varyingLocationCount;
  50987. private _varyingLocationMap;
  50988. private _replacements;
  50989. private _textureCount;
  50990. private _uniforms;
  50991. lineProcessor(line: string): string;
  50992. attributeProcessor(attribute: string): string;
  50993. varyingProcessor(varying: string, isFragment: boolean): string;
  50994. uniformProcessor(uniform: string): string;
  50995. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  50996. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  50997. }
  50998. }
  50999. declare module BABYLON {
  51000. /** @hidden */
  51001. export class ShaderCodeInliner {
  51002. static readonly InlineToken: string;
  51003. static readonly RegexpFindFunctionNameAndType: RegExp;
  51004. private _sourceCode;
  51005. private _functionDescr;
  51006. private _numMaxIterations;
  51007. debug: boolean;
  51008. get code(): string;
  51009. constructor(sourceCode: string, numMaxIterations?: number);
  51010. processCode(): void;
  51011. private _collectFunctions;
  51012. private _processInlining;
  51013. private _extractBetweenMarkers;
  51014. private _skipWhitespaces;
  51015. private _removeComments;
  51016. private _replaceFunctionCallsByCode;
  51017. private _findBackward;
  51018. private _escapeRegExp;
  51019. private _replaceNames;
  51020. }
  51021. }
  51022. declare module BABYLON {
  51023. /**
  51024. * Container for accessors for natively-stored mesh data buffers.
  51025. */
  51026. class NativeDataBuffer extends DataBuffer {
  51027. /**
  51028. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51029. */
  51030. nativeIndexBuffer?: any;
  51031. /**
  51032. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51033. */
  51034. nativeVertexBuffer?: any;
  51035. }
  51036. /** @hidden */
  51037. class NativeTexture extends InternalTexture {
  51038. getInternalTexture(): InternalTexture;
  51039. getViewCount(): number;
  51040. }
  51041. /** @hidden */
  51042. export class NativeEngine extends Engine {
  51043. private readonly _native;
  51044. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51045. private readonly INVALID_HANDLE;
  51046. getHardwareScalingLevel(): number;
  51047. constructor();
  51048. dispose(): void;
  51049. /**
  51050. * Can be used to override the current requestAnimationFrame requester.
  51051. * @hidden
  51052. */
  51053. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51054. /**
  51055. * Override default engine behavior.
  51056. * @param color
  51057. * @param backBuffer
  51058. * @param depth
  51059. * @param stencil
  51060. */
  51061. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51062. /**
  51063. * Gets host document
  51064. * @returns the host document object
  51065. */
  51066. getHostDocument(): Nullable<Document>;
  51067. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51068. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51069. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51070. recordVertexArrayObject(vertexBuffers: {
  51071. [key: string]: VertexBuffer;
  51072. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51073. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51074. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51075. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51076. /**
  51077. * Draw a list of indexed primitives
  51078. * @param fillMode defines the primitive to use
  51079. * @param indexStart defines the starting index
  51080. * @param indexCount defines the number of index to draw
  51081. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51082. */
  51083. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51084. /**
  51085. * Draw a list of unindexed primitives
  51086. * @param fillMode defines the primitive to use
  51087. * @param verticesStart defines the index of first vertex to draw
  51088. * @param verticesCount defines the count of vertices to draw
  51089. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51090. */
  51091. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51092. createPipelineContext(): IPipelineContext;
  51093. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51094. /** @hidden */
  51095. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51096. /** @hidden */
  51097. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51098. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51099. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51100. protected _setProgram(program: WebGLProgram): void;
  51101. _releaseEffect(effect: Effect): void;
  51102. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51103. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51104. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51105. bindSamplers(effect: Effect): void;
  51106. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51107. getRenderWidth(useScreen?: boolean): number;
  51108. getRenderHeight(useScreen?: boolean): number;
  51109. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51110. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51111. /**
  51112. * Set the z offset to apply to current rendering
  51113. * @param value defines the offset to apply
  51114. */
  51115. setZOffset(value: number): void;
  51116. /**
  51117. * Gets the current value of the zOffset
  51118. * @returns the current zOffset state
  51119. */
  51120. getZOffset(): number;
  51121. /**
  51122. * Enable or disable depth buffering
  51123. * @param enable defines the state to set
  51124. */
  51125. setDepthBuffer(enable: boolean): void;
  51126. /**
  51127. * Gets a boolean indicating if depth writing is enabled
  51128. * @returns the current depth writing state
  51129. */
  51130. getDepthWrite(): boolean;
  51131. /**
  51132. * Enable or disable depth writing
  51133. * @param enable defines the state to set
  51134. */
  51135. setDepthWrite(enable: boolean): void;
  51136. /**
  51137. * Enable or disable color writing
  51138. * @param enable defines the state to set
  51139. */
  51140. setColorWrite(enable: boolean): void;
  51141. /**
  51142. * Gets a boolean indicating if color writing is enabled
  51143. * @returns the current color writing state
  51144. */
  51145. getColorWrite(): boolean;
  51146. /**
  51147. * Sets alpha constants used by some alpha blending modes
  51148. * @param r defines the red component
  51149. * @param g defines the green component
  51150. * @param b defines the blue component
  51151. * @param a defines the alpha component
  51152. */
  51153. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51154. /**
  51155. * Sets the current alpha mode
  51156. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51157. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51158. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51159. */
  51160. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51161. /**
  51162. * Gets the current alpha mode
  51163. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51164. * @returns the current alpha mode
  51165. */
  51166. getAlphaMode(): number;
  51167. setInt(uniform: WebGLUniformLocation, int: number): void;
  51168. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51169. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51170. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51171. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51172. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51173. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51174. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51175. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51176. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51177. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51178. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51179. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51180. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51181. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51182. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51183. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51184. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51185. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51186. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51187. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51188. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51189. wipeCaches(bruteForce?: boolean): void;
  51190. _createTexture(): WebGLTexture;
  51191. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51192. /**
  51193. * Usually called from Texture.ts.
  51194. * Passed information to create a WebGLTexture
  51195. * @param url defines a value which contains one of the following:
  51196. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51197. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51198. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51199. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51200. * @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)
  51201. * @param scene needed for loading to the correct scene
  51202. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51203. * @param onLoad optional callback to be called upon successful completion
  51204. * @param onError optional callback to be called upon failure
  51205. * @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
  51206. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51207. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51208. * @param forcedExtension defines the extension to use to pick the right loader
  51209. * @param mimeType defines an optional mime type
  51210. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51211. */
  51212. 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;
  51213. /**
  51214. * Creates a cube texture
  51215. * @param rootUrl defines the url where the files to load is located
  51216. * @param scene defines the current scene
  51217. * @param files defines the list of files to load (1 per face)
  51218. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51219. * @param onLoad defines an optional callback raised when the texture is loaded
  51220. * @param onError defines an optional callback raised if there is an issue to load the texture
  51221. * @param format defines the format of the data
  51222. * @param forcedExtension defines the extension to use to pick the right loader
  51223. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51224. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51225. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51226. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51227. * @returns the cube texture as an InternalTexture
  51228. */
  51229. 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;
  51230. private _getSamplingFilter;
  51231. private static _GetNativeTextureFormat;
  51232. createRenderTargetTexture(size: number | {
  51233. width: number;
  51234. height: number;
  51235. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51236. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51237. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51238. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51239. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51240. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51241. /**
  51242. * Updates a dynamic vertex buffer.
  51243. * @param vertexBuffer the vertex buffer to update
  51244. * @param data the data used to update the vertex buffer
  51245. * @param byteOffset the byte offset of the data (optional)
  51246. * @param byteLength the byte length of the data (optional)
  51247. */
  51248. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51249. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51250. private _updateAnisotropicLevel;
  51251. private _getAddressMode;
  51252. /** @hidden */
  51253. _bindTexture(channel: number, texture: InternalTexture): void;
  51254. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51255. releaseEffects(): void;
  51256. /** @hidden */
  51257. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51258. /** @hidden */
  51259. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51260. /** @hidden */
  51261. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51262. /** @hidden */
  51263. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51264. }
  51265. }
  51266. declare module BABYLON {
  51267. /**
  51268. * Gather the list of clipboard event types as constants.
  51269. */
  51270. export class ClipboardEventTypes {
  51271. /**
  51272. * The clipboard event is fired when a copy command is active (pressed).
  51273. */
  51274. static readonly COPY: number;
  51275. /**
  51276. * The clipboard event is fired when a cut command is active (pressed).
  51277. */
  51278. static readonly CUT: number;
  51279. /**
  51280. * The clipboard event is fired when a paste command is active (pressed).
  51281. */
  51282. static readonly PASTE: number;
  51283. }
  51284. /**
  51285. * This class is used to store clipboard related info for the onClipboardObservable event.
  51286. */
  51287. export class ClipboardInfo {
  51288. /**
  51289. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51290. */
  51291. type: number;
  51292. /**
  51293. * Defines the related dom event
  51294. */
  51295. event: ClipboardEvent;
  51296. /**
  51297. *Creates an instance of ClipboardInfo.
  51298. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51299. * @param event Defines the related dom event
  51300. */
  51301. constructor(
  51302. /**
  51303. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51304. */
  51305. type: number,
  51306. /**
  51307. * Defines the related dom event
  51308. */
  51309. event: ClipboardEvent);
  51310. /**
  51311. * Get the clipboard event's type from the keycode.
  51312. * @param keyCode Defines the keyCode for the current keyboard event.
  51313. * @return {number}
  51314. */
  51315. static GetTypeFromCharacter(keyCode: number): number;
  51316. }
  51317. }
  51318. declare module BABYLON {
  51319. /**
  51320. * Google Daydream controller
  51321. */
  51322. export class DaydreamController extends WebVRController {
  51323. /**
  51324. * Base Url for the controller model.
  51325. */
  51326. static MODEL_BASE_URL: string;
  51327. /**
  51328. * File name for the controller model.
  51329. */
  51330. static MODEL_FILENAME: string;
  51331. /**
  51332. * Gamepad Id prefix used to identify Daydream Controller.
  51333. */
  51334. static readonly GAMEPAD_ID_PREFIX: string;
  51335. /**
  51336. * Creates a new DaydreamController from a gamepad
  51337. * @param vrGamepad the gamepad that the controller should be created from
  51338. */
  51339. constructor(vrGamepad: any);
  51340. /**
  51341. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51342. * @param scene scene in which to add meshes
  51343. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51344. */
  51345. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51346. /**
  51347. * Called once for each button that changed state since the last frame
  51348. * @param buttonIdx Which button index changed
  51349. * @param state New state of the button
  51350. * @param changes Which properties on the state changed since last frame
  51351. */
  51352. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51353. }
  51354. }
  51355. declare module BABYLON {
  51356. /**
  51357. * Gear VR Controller
  51358. */
  51359. export class GearVRController extends WebVRController {
  51360. /**
  51361. * Base Url for the controller model.
  51362. */
  51363. static MODEL_BASE_URL: string;
  51364. /**
  51365. * File name for the controller model.
  51366. */
  51367. static MODEL_FILENAME: string;
  51368. /**
  51369. * Gamepad Id prefix used to identify this controller.
  51370. */
  51371. static readonly GAMEPAD_ID_PREFIX: string;
  51372. private readonly _buttonIndexToObservableNameMap;
  51373. /**
  51374. * Creates a new GearVRController from a gamepad
  51375. * @param vrGamepad the gamepad that the controller should be created from
  51376. */
  51377. constructor(vrGamepad: any);
  51378. /**
  51379. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51380. * @param scene scene in which to add meshes
  51381. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51382. */
  51383. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51384. /**
  51385. * Called once for each button that changed state since the last frame
  51386. * @param buttonIdx Which button index changed
  51387. * @param state New state of the button
  51388. * @param changes Which properties on the state changed since last frame
  51389. */
  51390. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51391. }
  51392. }
  51393. declare module BABYLON {
  51394. /**
  51395. * Generic Controller
  51396. */
  51397. export class GenericController extends WebVRController {
  51398. /**
  51399. * Base Url for the controller model.
  51400. */
  51401. static readonly MODEL_BASE_URL: string;
  51402. /**
  51403. * File name for the controller model.
  51404. */
  51405. static readonly MODEL_FILENAME: string;
  51406. /**
  51407. * Creates a new GenericController from a gamepad
  51408. * @param vrGamepad the gamepad that the controller should be created from
  51409. */
  51410. constructor(vrGamepad: any);
  51411. /**
  51412. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51413. * @param scene scene in which to add meshes
  51414. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51415. */
  51416. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51417. /**
  51418. * Called once for each button that changed state since the last frame
  51419. * @param buttonIdx Which button index changed
  51420. * @param state New state of the button
  51421. * @param changes Which properties on the state changed since last frame
  51422. */
  51423. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51424. }
  51425. }
  51426. declare module BABYLON {
  51427. /**
  51428. * Oculus Touch Controller
  51429. */
  51430. export class OculusTouchController extends WebVRController {
  51431. /**
  51432. * Base Url for the controller model.
  51433. */
  51434. static MODEL_BASE_URL: string;
  51435. /**
  51436. * File name for the left controller model.
  51437. */
  51438. static MODEL_LEFT_FILENAME: string;
  51439. /**
  51440. * File name for the right controller model.
  51441. */
  51442. static MODEL_RIGHT_FILENAME: string;
  51443. /**
  51444. * Base Url for the Quest controller model.
  51445. */
  51446. static QUEST_MODEL_BASE_URL: string;
  51447. /**
  51448. * @hidden
  51449. * If the controllers are running on a device that needs the updated Quest controller models
  51450. */
  51451. static _IsQuest: boolean;
  51452. /**
  51453. * Fired when the secondary trigger on this controller is modified
  51454. */
  51455. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51456. /**
  51457. * Fired when the thumb rest on this controller is modified
  51458. */
  51459. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51460. /**
  51461. * Creates a new OculusTouchController from a gamepad
  51462. * @param vrGamepad the gamepad that the controller should be created from
  51463. */
  51464. constructor(vrGamepad: any);
  51465. /**
  51466. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51467. * @param scene scene in which to add meshes
  51468. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51469. */
  51470. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51471. /**
  51472. * Fired when the A button on this controller is modified
  51473. */
  51474. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51475. /**
  51476. * Fired when the B button on this controller is modified
  51477. */
  51478. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51479. /**
  51480. * Fired when the X button on this controller is modified
  51481. */
  51482. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51483. /**
  51484. * Fired when the Y button on this controller is modified
  51485. */
  51486. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51487. /**
  51488. * Called once for each button that changed state since the last frame
  51489. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51490. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51491. * 2) secondary trigger (same)
  51492. * 3) A (right) X (left), touch, pressed = value
  51493. * 4) B / Y
  51494. * 5) thumb rest
  51495. * @param buttonIdx Which button index changed
  51496. * @param state New state of the button
  51497. * @param changes Which properties on the state changed since last frame
  51498. */
  51499. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51500. }
  51501. }
  51502. declare module BABYLON {
  51503. /**
  51504. * Vive Controller
  51505. */
  51506. export class ViveController extends WebVRController {
  51507. /**
  51508. * Base Url for the controller model.
  51509. */
  51510. static MODEL_BASE_URL: string;
  51511. /**
  51512. * File name for the controller model.
  51513. */
  51514. static MODEL_FILENAME: string;
  51515. /**
  51516. * Creates a new ViveController from a gamepad
  51517. * @param vrGamepad the gamepad that the controller should be created from
  51518. */
  51519. constructor(vrGamepad: any);
  51520. /**
  51521. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51522. * @param scene scene in which to add meshes
  51523. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51524. */
  51525. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51526. /**
  51527. * Fired when the left button on this controller is modified
  51528. */
  51529. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51530. /**
  51531. * Fired when the right button on this controller is modified
  51532. */
  51533. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51534. /**
  51535. * Fired when the menu button on this controller is modified
  51536. */
  51537. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51538. /**
  51539. * Called once for each button that changed state since the last frame
  51540. * Vive mapping:
  51541. * 0: touchpad
  51542. * 1: trigger
  51543. * 2: left AND right buttons
  51544. * 3: menu button
  51545. * @param buttonIdx Which button index changed
  51546. * @param state New state of the button
  51547. * @param changes Which properties on the state changed since last frame
  51548. */
  51549. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51550. }
  51551. }
  51552. declare module BABYLON {
  51553. /**
  51554. * Defines the WindowsMotionController object that the state of the windows motion controller
  51555. */
  51556. export class WindowsMotionController extends WebVRController {
  51557. /**
  51558. * The base url used to load the left and right controller models
  51559. */
  51560. static MODEL_BASE_URL: string;
  51561. /**
  51562. * The name of the left controller model file
  51563. */
  51564. static MODEL_LEFT_FILENAME: string;
  51565. /**
  51566. * The name of the right controller model file
  51567. */
  51568. static MODEL_RIGHT_FILENAME: string;
  51569. /**
  51570. * The controller name prefix for this controller type
  51571. */
  51572. static readonly GAMEPAD_ID_PREFIX: string;
  51573. /**
  51574. * The controller id pattern for this controller type
  51575. */
  51576. private static readonly GAMEPAD_ID_PATTERN;
  51577. private _loadedMeshInfo;
  51578. protected readonly _mapping: {
  51579. buttons: string[];
  51580. buttonMeshNames: {
  51581. trigger: string;
  51582. menu: string;
  51583. grip: string;
  51584. thumbstick: string;
  51585. trackpad: string;
  51586. };
  51587. buttonObservableNames: {
  51588. trigger: string;
  51589. menu: string;
  51590. grip: string;
  51591. thumbstick: string;
  51592. trackpad: string;
  51593. };
  51594. axisMeshNames: string[];
  51595. pointingPoseMeshName: string;
  51596. };
  51597. /**
  51598. * Fired when the trackpad on this controller is clicked
  51599. */
  51600. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51601. /**
  51602. * Fired when the trackpad on this controller is modified
  51603. */
  51604. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51605. /**
  51606. * The current x and y values of this controller's trackpad
  51607. */
  51608. trackpad: StickValues;
  51609. /**
  51610. * Creates a new WindowsMotionController from a gamepad
  51611. * @param vrGamepad the gamepad that the controller should be created from
  51612. */
  51613. constructor(vrGamepad: any);
  51614. /**
  51615. * Fired when the trigger on this controller is modified
  51616. */
  51617. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51618. /**
  51619. * Fired when the menu button on this controller is modified
  51620. */
  51621. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51622. /**
  51623. * Fired when the grip button on this controller is modified
  51624. */
  51625. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51626. /**
  51627. * Fired when the thumbstick button on this controller is modified
  51628. */
  51629. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51630. /**
  51631. * Fired when the touchpad button on this controller is modified
  51632. */
  51633. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51634. /**
  51635. * Fired when the touchpad values on this controller are modified
  51636. */
  51637. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  51638. protected _updateTrackpad(): void;
  51639. /**
  51640. * Called once per frame by the engine.
  51641. */
  51642. update(): void;
  51643. /**
  51644. * Called once for each button that changed state since the last frame
  51645. * @param buttonIdx Which button index changed
  51646. * @param state New state of the button
  51647. * @param changes Which properties on the state changed since last frame
  51648. */
  51649. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51650. /**
  51651. * Moves the buttons on the controller mesh based on their current state
  51652. * @param buttonName the name of the button to move
  51653. * @param buttonValue the value of the button which determines the buttons new position
  51654. */
  51655. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  51656. /**
  51657. * Moves the axis on the controller mesh based on its current state
  51658. * @param axis the index of the axis
  51659. * @param axisValue the value of the axis which determines the meshes new position
  51660. * @hidden
  51661. */
  51662. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  51663. /**
  51664. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51665. * @param scene scene in which to add meshes
  51666. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51667. */
  51668. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  51669. /**
  51670. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  51671. * can be transformed by button presses and axes values, based on this._mapping.
  51672. *
  51673. * @param scene scene in which the meshes exist
  51674. * @param meshes list of meshes that make up the controller model to process
  51675. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  51676. */
  51677. private processModel;
  51678. private createMeshInfo;
  51679. /**
  51680. * Gets the ray of the controller in the direction the controller is pointing
  51681. * @param length the length the resulting ray should be
  51682. * @returns a ray in the direction the controller is pointing
  51683. */
  51684. getForwardRay(length?: number): Ray;
  51685. /**
  51686. * Disposes of the controller
  51687. */
  51688. dispose(): void;
  51689. }
  51690. /**
  51691. * This class represents a new windows motion controller in XR.
  51692. */
  51693. export class XRWindowsMotionController extends WindowsMotionController {
  51694. /**
  51695. * Changing the original WIndowsMotionController mapping to fir the new mapping
  51696. */
  51697. protected readonly _mapping: {
  51698. buttons: string[];
  51699. buttonMeshNames: {
  51700. trigger: string;
  51701. menu: string;
  51702. grip: string;
  51703. thumbstick: string;
  51704. trackpad: string;
  51705. };
  51706. buttonObservableNames: {
  51707. trigger: string;
  51708. menu: string;
  51709. grip: string;
  51710. thumbstick: string;
  51711. trackpad: string;
  51712. };
  51713. axisMeshNames: string[];
  51714. pointingPoseMeshName: string;
  51715. };
  51716. /**
  51717. * Construct a new XR-Based windows motion controller
  51718. *
  51719. * @param gamepadInfo the gamepad object from the browser
  51720. */
  51721. constructor(gamepadInfo: any);
  51722. /**
  51723. * holds the thumbstick values (X,Y)
  51724. */
  51725. thumbstickValues: StickValues;
  51726. /**
  51727. * Fired when the thumbstick on this controller is clicked
  51728. */
  51729. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  51730. /**
  51731. * Fired when the thumbstick on this controller is modified
  51732. */
  51733. onThumbstickValuesChangedObservable: Observable<StickValues>;
  51734. /**
  51735. * Fired when the touchpad button on this controller is modified
  51736. */
  51737. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51738. /**
  51739. * Fired when the touchpad values on this controller are modified
  51740. */
  51741. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51742. /**
  51743. * Fired when the thumbstick button on this controller is modified
  51744. * here to prevent breaking changes
  51745. */
  51746. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51747. /**
  51748. * updating the thumbstick(!) and not the trackpad.
  51749. * This is named this way due to the difference between WebVR and XR and to avoid
  51750. * changing the parent class.
  51751. */
  51752. protected _updateTrackpad(): void;
  51753. /**
  51754. * Disposes the class with joy
  51755. */
  51756. dispose(): void;
  51757. }
  51758. }
  51759. declare module BABYLON {
  51760. /**
  51761. * Class containing static functions to help procedurally build meshes
  51762. */
  51763. export class PolyhedronBuilder {
  51764. /**
  51765. * Creates a polyhedron mesh
  51766. * * 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
  51767. * * The parameter `size` (positive float, default 1) sets the polygon size
  51768. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51769. * * 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`
  51770. * * 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
  51771. * * 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)`)
  51772. * * 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
  51773. * * 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
  51774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51775. * * 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
  51776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51777. * @param name defines the name of the mesh
  51778. * @param options defines the options used to create the mesh
  51779. * @param scene defines the hosting scene
  51780. * @returns the polyhedron mesh
  51781. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51782. */
  51783. static CreatePolyhedron(name: string, options: {
  51784. type?: number;
  51785. size?: number;
  51786. sizeX?: number;
  51787. sizeY?: number;
  51788. sizeZ?: number;
  51789. custom?: any;
  51790. faceUV?: Vector4[];
  51791. faceColors?: Color4[];
  51792. flat?: boolean;
  51793. updatable?: boolean;
  51794. sideOrientation?: number;
  51795. frontUVs?: Vector4;
  51796. backUVs?: Vector4;
  51797. }, scene?: Nullable<Scene>): Mesh;
  51798. }
  51799. }
  51800. declare module BABYLON {
  51801. /**
  51802. * Gizmo that enables scaling a mesh along 3 axis
  51803. */
  51804. export class ScaleGizmo extends Gizmo {
  51805. /**
  51806. * Internal gizmo used for interactions on the x axis
  51807. */
  51808. xGizmo: AxisScaleGizmo;
  51809. /**
  51810. * Internal gizmo used for interactions on the y axis
  51811. */
  51812. yGizmo: AxisScaleGizmo;
  51813. /**
  51814. * Internal gizmo used for interactions on the z axis
  51815. */
  51816. zGizmo: AxisScaleGizmo;
  51817. /**
  51818. * Internal gizmo used to scale all axis equally
  51819. */
  51820. uniformScaleGizmo: AxisScaleGizmo;
  51821. private _meshAttached;
  51822. private _updateGizmoRotationToMatchAttachedMesh;
  51823. private _snapDistance;
  51824. private _scaleRatio;
  51825. private _uniformScalingMesh;
  51826. private _octahedron;
  51827. private _sensitivity;
  51828. /** Fires an event when any of it's sub gizmos are dragged */
  51829. onDragStartObservable: Observable<unknown>;
  51830. /** Fires an event when any of it's sub gizmos are released from dragging */
  51831. onDragEndObservable: Observable<unknown>;
  51832. get attachedMesh(): Nullable<AbstractMesh>;
  51833. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51834. /**
  51835. * Creates a ScaleGizmo
  51836. * @param gizmoLayer The utility layer the gizmo will be added to
  51837. */
  51838. constructor(gizmoLayer?: UtilityLayerRenderer);
  51839. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51840. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51841. /**
  51842. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51843. */
  51844. set snapDistance(value: number);
  51845. get snapDistance(): number;
  51846. /**
  51847. * Ratio for the scale of the gizmo (Default: 1)
  51848. */
  51849. set scaleRatio(value: number);
  51850. get scaleRatio(): number;
  51851. /**
  51852. * Sensitivity factor for dragging (Default: 1)
  51853. */
  51854. set sensitivity(value: number);
  51855. get sensitivity(): number;
  51856. /**
  51857. * Disposes of the gizmo
  51858. */
  51859. dispose(): void;
  51860. }
  51861. }
  51862. declare module BABYLON {
  51863. /**
  51864. * Single axis scale gizmo
  51865. */
  51866. export class AxisScaleGizmo extends Gizmo {
  51867. /**
  51868. * Drag behavior responsible for the gizmos dragging interactions
  51869. */
  51870. dragBehavior: PointerDragBehavior;
  51871. private _pointerObserver;
  51872. /**
  51873. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51874. */
  51875. snapDistance: number;
  51876. /**
  51877. * Event that fires each time the gizmo snaps to a new location.
  51878. * * snapDistance is the the change in distance
  51879. */
  51880. onSnapObservable: Observable<{
  51881. snapDistance: number;
  51882. }>;
  51883. /**
  51884. * If the scaling operation should be done on all axis (default: false)
  51885. */
  51886. uniformScaling: boolean;
  51887. /**
  51888. * Custom sensitivity value for the drag strength
  51889. */
  51890. sensitivity: number;
  51891. private _isEnabled;
  51892. private _parent;
  51893. private _arrow;
  51894. private _coloredMaterial;
  51895. private _hoverMaterial;
  51896. /**
  51897. * Creates an AxisScaleGizmo
  51898. * @param gizmoLayer The utility layer the gizmo will be added to
  51899. * @param dragAxis The axis which the gizmo will be able to scale on
  51900. * @param color The color of the gizmo
  51901. */
  51902. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51903. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51904. /**
  51905. * If the gizmo is enabled
  51906. */
  51907. set isEnabled(value: boolean);
  51908. get isEnabled(): boolean;
  51909. /**
  51910. * Disposes of the gizmo
  51911. */
  51912. dispose(): void;
  51913. /**
  51914. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51915. * @param mesh The mesh to replace the default mesh of the gizmo
  51916. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51917. */
  51918. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51919. }
  51920. }
  51921. declare module BABYLON {
  51922. /**
  51923. * Bounding box gizmo
  51924. */
  51925. export class BoundingBoxGizmo extends Gizmo {
  51926. private _lineBoundingBox;
  51927. private _rotateSpheresParent;
  51928. private _scaleBoxesParent;
  51929. private _boundingDimensions;
  51930. private _renderObserver;
  51931. private _pointerObserver;
  51932. private _scaleDragSpeed;
  51933. private _tmpQuaternion;
  51934. private _tmpVector;
  51935. private _tmpRotationMatrix;
  51936. /**
  51937. * 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)
  51938. */
  51939. ignoreChildren: boolean;
  51940. /**
  51941. * 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)
  51942. */
  51943. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  51944. /**
  51945. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  51946. */
  51947. rotationSphereSize: number;
  51948. /**
  51949. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  51950. */
  51951. scaleBoxSize: number;
  51952. /**
  51953. * 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)
  51954. */
  51955. fixedDragMeshScreenSize: boolean;
  51956. /**
  51957. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  51958. */
  51959. fixedDragMeshScreenSizeDistanceFactor: number;
  51960. /**
  51961. * Fired when a rotation sphere or scale box is dragged
  51962. */
  51963. onDragStartObservable: Observable<{}>;
  51964. /**
  51965. * Fired when a scale box is dragged
  51966. */
  51967. onScaleBoxDragObservable: Observable<{}>;
  51968. /**
  51969. * Fired when a scale box drag is ended
  51970. */
  51971. onScaleBoxDragEndObservable: Observable<{}>;
  51972. /**
  51973. * Fired when a rotation sphere is dragged
  51974. */
  51975. onRotationSphereDragObservable: Observable<{}>;
  51976. /**
  51977. * Fired when a rotation sphere drag is ended
  51978. */
  51979. onRotationSphereDragEndObservable: Observable<{}>;
  51980. /**
  51981. * 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)
  51982. */
  51983. scalePivot: Nullable<Vector3>;
  51984. /**
  51985. * Mesh used as a pivot to rotate the attached mesh
  51986. */
  51987. private _anchorMesh;
  51988. private _existingMeshScale;
  51989. private _dragMesh;
  51990. private pointerDragBehavior;
  51991. private coloredMaterial;
  51992. private hoverColoredMaterial;
  51993. /**
  51994. * Sets the color of the bounding box gizmo
  51995. * @param color the color to set
  51996. */
  51997. setColor(color: Color3): void;
  51998. /**
  51999. * Creates an BoundingBoxGizmo
  52000. * @param gizmoLayer The utility layer the gizmo will be added to
  52001. * @param color The color of the gizmo
  52002. */
  52003. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52004. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52005. private _selectNode;
  52006. /**
  52007. * Updates the bounding box information for the Gizmo
  52008. */
  52009. updateBoundingBox(): void;
  52010. private _updateRotationSpheres;
  52011. private _updateScaleBoxes;
  52012. /**
  52013. * Enables rotation on the specified axis and disables rotation on the others
  52014. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52015. */
  52016. setEnabledRotationAxis(axis: string): void;
  52017. /**
  52018. * Enables/disables scaling
  52019. * @param enable if scaling should be enabled
  52020. * @param homogeneousScaling defines if scaling should only be homogeneous
  52021. */
  52022. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52023. private _updateDummy;
  52024. /**
  52025. * Enables a pointer drag behavior on the bounding box of the gizmo
  52026. */
  52027. enableDragBehavior(): void;
  52028. /**
  52029. * Disposes of the gizmo
  52030. */
  52031. dispose(): void;
  52032. /**
  52033. * 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)
  52034. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52035. * @returns the bounding box mesh with the passed in mesh as a child
  52036. */
  52037. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52038. /**
  52039. * CustomMeshes are not supported by this gizmo
  52040. * @param mesh The mesh to replace the default mesh of the gizmo
  52041. */
  52042. setCustomMesh(mesh: Mesh): void;
  52043. }
  52044. }
  52045. declare module BABYLON {
  52046. /**
  52047. * Single plane rotation gizmo
  52048. */
  52049. export class PlaneRotationGizmo extends Gizmo {
  52050. /**
  52051. * Drag behavior responsible for the gizmos dragging interactions
  52052. */
  52053. dragBehavior: PointerDragBehavior;
  52054. private _pointerObserver;
  52055. /**
  52056. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52057. */
  52058. snapDistance: number;
  52059. /**
  52060. * Event that fires each time the gizmo snaps to a new location.
  52061. * * snapDistance is the the change in distance
  52062. */
  52063. onSnapObservable: Observable<{
  52064. snapDistance: number;
  52065. }>;
  52066. private _isEnabled;
  52067. private _parent;
  52068. /**
  52069. * Creates a PlaneRotationGizmo
  52070. * @param gizmoLayer The utility layer the gizmo will be added to
  52071. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52072. * @param color The color of the gizmo
  52073. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52074. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52075. */
  52076. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52077. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52078. /**
  52079. * If the gizmo is enabled
  52080. */
  52081. set isEnabled(value: boolean);
  52082. get isEnabled(): boolean;
  52083. /**
  52084. * Disposes of the gizmo
  52085. */
  52086. dispose(): void;
  52087. }
  52088. }
  52089. declare module BABYLON {
  52090. /**
  52091. * Gizmo that enables rotating a mesh along 3 axis
  52092. */
  52093. export class RotationGizmo extends Gizmo {
  52094. /**
  52095. * Internal gizmo used for interactions on the x axis
  52096. */
  52097. xGizmo: PlaneRotationGizmo;
  52098. /**
  52099. * Internal gizmo used for interactions on the y axis
  52100. */
  52101. yGizmo: PlaneRotationGizmo;
  52102. /**
  52103. * Internal gizmo used for interactions on the z axis
  52104. */
  52105. zGizmo: PlaneRotationGizmo;
  52106. /** Fires an event when any of it's sub gizmos are dragged */
  52107. onDragStartObservable: Observable<unknown>;
  52108. /** Fires an event when any of it's sub gizmos are released from dragging */
  52109. onDragEndObservable: Observable<unknown>;
  52110. private _meshAttached;
  52111. get attachedMesh(): Nullable<AbstractMesh>;
  52112. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52113. /**
  52114. * Creates a RotationGizmo
  52115. * @param gizmoLayer The utility layer the gizmo will be added to
  52116. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52117. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52118. */
  52119. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52120. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52121. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52122. /**
  52123. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52124. */
  52125. set snapDistance(value: number);
  52126. get snapDistance(): number;
  52127. /**
  52128. * Ratio for the scale of the gizmo (Default: 1)
  52129. */
  52130. set scaleRatio(value: number);
  52131. get scaleRatio(): number;
  52132. /**
  52133. * Disposes of the gizmo
  52134. */
  52135. dispose(): void;
  52136. /**
  52137. * CustomMeshes are not supported by this gizmo
  52138. * @param mesh The mesh to replace the default mesh of the gizmo
  52139. */
  52140. setCustomMesh(mesh: Mesh): void;
  52141. }
  52142. }
  52143. declare module BABYLON {
  52144. /**
  52145. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52146. */
  52147. export class GizmoManager implements IDisposable {
  52148. private scene;
  52149. /**
  52150. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52151. */
  52152. gizmos: {
  52153. positionGizmo: Nullable<PositionGizmo>;
  52154. rotationGizmo: Nullable<RotationGizmo>;
  52155. scaleGizmo: Nullable<ScaleGizmo>;
  52156. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52157. };
  52158. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52159. clearGizmoOnEmptyPointerEvent: boolean;
  52160. /** Fires an event when the manager is attached to a mesh */
  52161. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52162. private _gizmosEnabled;
  52163. private _pointerObserver;
  52164. private _attachedMesh;
  52165. private _boundingBoxColor;
  52166. private _defaultUtilityLayer;
  52167. private _defaultKeepDepthUtilityLayer;
  52168. /**
  52169. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52170. */
  52171. boundingBoxDragBehavior: SixDofDragBehavior;
  52172. /**
  52173. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52174. */
  52175. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52176. /**
  52177. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52178. */
  52179. usePointerToAttachGizmos: boolean;
  52180. /**
  52181. * Utility layer that the bounding box gizmo belongs to
  52182. */
  52183. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52184. /**
  52185. * Utility layer that all gizmos besides bounding box belong to
  52186. */
  52187. get utilityLayer(): UtilityLayerRenderer;
  52188. /**
  52189. * Instatiates a gizmo manager
  52190. * @param scene the scene to overlay the gizmos on top of
  52191. */
  52192. constructor(scene: Scene);
  52193. /**
  52194. * Attaches a set of gizmos to the specified mesh
  52195. * @param mesh The mesh the gizmo's should be attached to
  52196. */
  52197. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52198. /**
  52199. * If the position gizmo is enabled
  52200. */
  52201. set positionGizmoEnabled(value: boolean);
  52202. get positionGizmoEnabled(): boolean;
  52203. /**
  52204. * If the rotation gizmo is enabled
  52205. */
  52206. set rotationGizmoEnabled(value: boolean);
  52207. get rotationGizmoEnabled(): boolean;
  52208. /**
  52209. * If the scale gizmo is enabled
  52210. */
  52211. set scaleGizmoEnabled(value: boolean);
  52212. get scaleGizmoEnabled(): boolean;
  52213. /**
  52214. * If the boundingBox gizmo is enabled
  52215. */
  52216. set boundingBoxGizmoEnabled(value: boolean);
  52217. get boundingBoxGizmoEnabled(): boolean;
  52218. /**
  52219. * Disposes of the gizmo manager
  52220. */
  52221. dispose(): void;
  52222. }
  52223. }
  52224. declare module BABYLON {
  52225. /**
  52226. * A directional light is defined by a direction (what a surprise!).
  52227. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52228. * 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.
  52229. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52230. */
  52231. export class DirectionalLight extends ShadowLight {
  52232. private _shadowFrustumSize;
  52233. /**
  52234. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52235. */
  52236. get shadowFrustumSize(): number;
  52237. /**
  52238. * Specifies a fix frustum size for the shadow generation.
  52239. */
  52240. set shadowFrustumSize(value: number);
  52241. private _shadowOrthoScale;
  52242. /**
  52243. * Gets the shadow projection scale against the optimal computed one.
  52244. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52245. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52246. */
  52247. get shadowOrthoScale(): number;
  52248. /**
  52249. * Sets the shadow projection scale against the optimal computed one.
  52250. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52251. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52252. */
  52253. set shadowOrthoScale(value: number);
  52254. /**
  52255. * Automatically compute the projection matrix to best fit (including all the casters)
  52256. * on each frame.
  52257. */
  52258. autoUpdateExtends: boolean;
  52259. /**
  52260. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52261. * on each frame. autoUpdateExtends must be set to true for this to work
  52262. */
  52263. autoCalcShadowZBounds: boolean;
  52264. private _orthoLeft;
  52265. private _orthoRight;
  52266. private _orthoTop;
  52267. private _orthoBottom;
  52268. /**
  52269. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52270. * The directional light is emitted from everywhere in the given direction.
  52271. * It can cast shadows.
  52272. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52273. * @param name The friendly name of the light
  52274. * @param direction The direction of the light
  52275. * @param scene The scene the light belongs to
  52276. */
  52277. constructor(name: string, direction: Vector3, scene: Scene);
  52278. /**
  52279. * Returns the string "DirectionalLight".
  52280. * @return The class name
  52281. */
  52282. getClassName(): string;
  52283. /**
  52284. * Returns the integer 1.
  52285. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52286. */
  52287. getTypeID(): number;
  52288. /**
  52289. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52290. * Returns the DirectionalLight Shadow projection matrix.
  52291. */
  52292. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52293. /**
  52294. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52295. * Returns the DirectionalLight Shadow projection matrix.
  52296. */
  52297. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52298. /**
  52299. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52300. * Returns the DirectionalLight Shadow projection matrix.
  52301. */
  52302. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52303. protected _buildUniformLayout(): void;
  52304. /**
  52305. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52306. * @param effect The effect to update
  52307. * @param lightIndex The index of the light in the effect to update
  52308. * @returns The directional light
  52309. */
  52310. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52311. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52312. /**
  52313. * Gets the minZ used for shadow according to both the scene and the light.
  52314. *
  52315. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52316. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52317. * @param activeCamera The camera we are returning the min for
  52318. * @returns the depth min z
  52319. */
  52320. getDepthMinZ(activeCamera: Camera): number;
  52321. /**
  52322. * Gets the maxZ used for shadow according to both the scene and the light.
  52323. *
  52324. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52325. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52326. * @param activeCamera The camera we are returning the max for
  52327. * @returns the depth max z
  52328. */
  52329. getDepthMaxZ(activeCamera: Camera): number;
  52330. /**
  52331. * Prepares the list of defines specific to the light type.
  52332. * @param defines the list of defines
  52333. * @param lightIndex defines the index of the light for the effect
  52334. */
  52335. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52336. }
  52337. }
  52338. declare module BABYLON {
  52339. /**
  52340. * Class containing static functions to help procedurally build meshes
  52341. */
  52342. export class HemisphereBuilder {
  52343. /**
  52344. * Creates a hemisphere mesh
  52345. * @param name defines the name of the mesh
  52346. * @param options defines the options used to create the mesh
  52347. * @param scene defines the hosting scene
  52348. * @returns the hemisphere mesh
  52349. */
  52350. static CreateHemisphere(name: string, options: {
  52351. segments?: number;
  52352. diameter?: number;
  52353. sideOrientation?: number;
  52354. }, scene: any): Mesh;
  52355. }
  52356. }
  52357. declare module BABYLON {
  52358. /**
  52359. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52360. * These values define a cone of light starting from the position, emitting toward the direction.
  52361. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52362. * and the exponent defines the speed of the decay of the light with distance (reach).
  52363. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52364. */
  52365. export class SpotLight extends ShadowLight {
  52366. private _angle;
  52367. private _innerAngle;
  52368. private _cosHalfAngle;
  52369. private _lightAngleScale;
  52370. private _lightAngleOffset;
  52371. /**
  52372. * Gets the cone angle of the spot light in Radians.
  52373. */
  52374. get angle(): number;
  52375. /**
  52376. * Sets the cone angle of the spot light in Radians.
  52377. */
  52378. set angle(value: number);
  52379. /**
  52380. * Only used in gltf falloff mode, this defines the angle where
  52381. * the directional falloff will start before cutting at angle which could be seen
  52382. * as outer angle.
  52383. */
  52384. get innerAngle(): number;
  52385. /**
  52386. * Only used in gltf falloff mode, this defines the angle where
  52387. * the directional falloff will start before cutting at angle which could be seen
  52388. * as outer angle.
  52389. */
  52390. set innerAngle(value: number);
  52391. private _shadowAngleScale;
  52392. /**
  52393. * Allows scaling the angle of the light for shadow generation only.
  52394. */
  52395. get shadowAngleScale(): number;
  52396. /**
  52397. * Allows scaling the angle of the light for shadow generation only.
  52398. */
  52399. set shadowAngleScale(value: number);
  52400. /**
  52401. * The light decay speed with the distance from the emission spot.
  52402. */
  52403. exponent: number;
  52404. private _projectionTextureMatrix;
  52405. /**
  52406. * Allows reading the projecton texture
  52407. */
  52408. get projectionTextureMatrix(): Matrix;
  52409. protected _projectionTextureLightNear: number;
  52410. /**
  52411. * Gets the near clip of the Spotlight for texture projection.
  52412. */
  52413. get projectionTextureLightNear(): number;
  52414. /**
  52415. * Sets the near clip of the Spotlight for texture projection.
  52416. */
  52417. set projectionTextureLightNear(value: number);
  52418. protected _projectionTextureLightFar: number;
  52419. /**
  52420. * Gets the far clip of the Spotlight for texture projection.
  52421. */
  52422. get projectionTextureLightFar(): number;
  52423. /**
  52424. * Sets the far clip of the Spotlight for texture projection.
  52425. */
  52426. set projectionTextureLightFar(value: number);
  52427. protected _projectionTextureUpDirection: Vector3;
  52428. /**
  52429. * Gets the Up vector of the Spotlight for texture projection.
  52430. */
  52431. get projectionTextureUpDirection(): Vector3;
  52432. /**
  52433. * Sets the Up vector of the Spotlight for texture projection.
  52434. */
  52435. set projectionTextureUpDirection(value: Vector3);
  52436. private _projectionTexture;
  52437. /**
  52438. * Gets the projection texture of the light.
  52439. */
  52440. get projectionTexture(): Nullable<BaseTexture>;
  52441. /**
  52442. * Sets the projection texture of the light.
  52443. */
  52444. set projectionTexture(value: Nullable<BaseTexture>);
  52445. private _projectionTextureViewLightDirty;
  52446. private _projectionTextureProjectionLightDirty;
  52447. private _projectionTextureDirty;
  52448. private _projectionTextureViewTargetVector;
  52449. private _projectionTextureViewLightMatrix;
  52450. private _projectionTextureProjectionLightMatrix;
  52451. private _projectionTextureScalingMatrix;
  52452. /**
  52453. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52454. * It can cast shadows.
  52455. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52456. * @param name The light friendly name
  52457. * @param position The position of the spot light in the scene
  52458. * @param direction The direction of the light in the scene
  52459. * @param angle The cone angle of the light in Radians
  52460. * @param exponent The light decay speed with the distance from the emission spot
  52461. * @param scene The scene the lights belongs to
  52462. */
  52463. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52464. /**
  52465. * Returns the string "SpotLight".
  52466. * @returns the class name
  52467. */
  52468. getClassName(): string;
  52469. /**
  52470. * Returns the integer 2.
  52471. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52472. */
  52473. getTypeID(): number;
  52474. /**
  52475. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52476. */
  52477. protected _setDirection(value: Vector3): void;
  52478. /**
  52479. * Overrides the position setter to recompute the projection texture view light Matrix.
  52480. */
  52481. protected _setPosition(value: Vector3): void;
  52482. /**
  52483. * 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.
  52484. * Returns the SpotLight.
  52485. */
  52486. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52487. protected _computeProjectionTextureViewLightMatrix(): void;
  52488. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52489. /**
  52490. * Main function for light texture projection matrix computing.
  52491. */
  52492. protected _computeProjectionTextureMatrix(): void;
  52493. protected _buildUniformLayout(): void;
  52494. private _computeAngleValues;
  52495. /**
  52496. * Sets the passed Effect "effect" with the Light textures.
  52497. * @param effect The effect to update
  52498. * @param lightIndex The index of the light in the effect to update
  52499. * @returns The light
  52500. */
  52501. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52502. /**
  52503. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52504. * @param effect The effect to update
  52505. * @param lightIndex The index of the light in the effect to update
  52506. * @returns The spot light
  52507. */
  52508. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52509. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52510. /**
  52511. * Disposes the light and the associated resources.
  52512. */
  52513. dispose(): void;
  52514. /**
  52515. * Prepares the list of defines specific to the light type.
  52516. * @param defines the list of defines
  52517. * @param lightIndex defines the index of the light for the effect
  52518. */
  52519. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52520. }
  52521. }
  52522. declare module BABYLON {
  52523. /**
  52524. * Gizmo that enables viewing a light
  52525. */
  52526. export class LightGizmo extends Gizmo {
  52527. private _lightMesh;
  52528. private _material;
  52529. private _cachedPosition;
  52530. private _cachedForward;
  52531. private _attachedMeshParent;
  52532. /**
  52533. * Creates a LightGizmo
  52534. * @param gizmoLayer The utility layer the gizmo will be added to
  52535. */
  52536. constructor(gizmoLayer?: UtilityLayerRenderer);
  52537. private _light;
  52538. /**
  52539. * The light that the gizmo is attached to
  52540. */
  52541. set light(light: Nullable<Light>);
  52542. get light(): Nullable<Light>;
  52543. /**
  52544. * Gets the material used to render the light gizmo
  52545. */
  52546. get material(): StandardMaterial;
  52547. /**
  52548. * @hidden
  52549. * Updates the gizmo to match the attached mesh's position/rotation
  52550. */
  52551. protected _update(): void;
  52552. private static _Scale;
  52553. /**
  52554. * Creates the lines for a light mesh
  52555. */
  52556. private static _CreateLightLines;
  52557. /**
  52558. * Disposes of the light gizmo
  52559. */
  52560. dispose(): void;
  52561. private static _CreateHemisphericLightMesh;
  52562. private static _CreatePointLightMesh;
  52563. private static _CreateSpotLightMesh;
  52564. private static _CreateDirectionalLightMesh;
  52565. }
  52566. }
  52567. declare module BABYLON {
  52568. /** @hidden */
  52569. export var backgroundFragmentDeclaration: {
  52570. name: string;
  52571. shader: string;
  52572. };
  52573. }
  52574. declare module BABYLON {
  52575. /** @hidden */
  52576. export var backgroundUboDeclaration: {
  52577. name: string;
  52578. shader: string;
  52579. };
  52580. }
  52581. declare module BABYLON {
  52582. /** @hidden */
  52583. export var backgroundPixelShader: {
  52584. name: string;
  52585. shader: string;
  52586. };
  52587. }
  52588. declare module BABYLON {
  52589. /** @hidden */
  52590. export var backgroundVertexDeclaration: {
  52591. name: string;
  52592. shader: string;
  52593. };
  52594. }
  52595. declare module BABYLON {
  52596. /** @hidden */
  52597. export var backgroundVertexShader: {
  52598. name: string;
  52599. shader: string;
  52600. };
  52601. }
  52602. declare module BABYLON {
  52603. /**
  52604. * Background material used to create an efficient environement around your scene.
  52605. */
  52606. export class BackgroundMaterial extends PushMaterial {
  52607. /**
  52608. * Standard reflectance value at parallel view angle.
  52609. */
  52610. static StandardReflectance0: number;
  52611. /**
  52612. * Standard reflectance value at grazing angle.
  52613. */
  52614. static StandardReflectance90: number;
  52615. protected _primaryColor: Color3;
  52616. /**
  52617. * Key light Color (multiply against the environement texture)
  52618. */
  52619. primaryColor: Color3;
  52620. protected __perceptualColor: Nullable<Color3>;
  52621. /**
  52622. * Experimental Internal Use Only.
  52623. *
  52624. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52625. * This acts as a helper to set the primary color to a more "human friendly" value.
  52626. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52627. * output color as close as possible from the chosen value.
  52628. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52629. * part of lighting setup.)
  52630. */
  52631. get _perceptualColor(): Nullable<Color3>;
  52632. set _perceptualColor(value: Nullable<Color3>);
  52633. protected _primaryColorShadowLevel: float;
  52634. /**
  52635. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52636. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52637. */
  52638. get primaryColorShadowLevel(): float;
  52639. set primaryColorShadowLevel(value: float);
  52640. protected _primaryColorHighlightLevel: float;
  52641. /**
  52642. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52643. * The primary color is used at the level chosen to define what the white area would look.
  52644. */
  52645. get primaryColorHighlightLevel(): float;
  52646. set primaryColorHighlightLevel(value: float);
  52647. protected _reflectionTexture: Nullable<BaseTexture>;
  52648. /**
  52649. * Reflection Texture used in the material.
  52650. * Should be author in a specific way for the best result (refer to the documentation).
  52651. */
  52652. reflectionTexture: Nullable<BaseTexture>;
  52653. protected _reflectionBlur: float;
  52654. /**
  52655. * Reflection Texture level of blur.
  52656. *
  52657. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52658. * texture twice.
  52659. */
  52660. reflectionBlur: float;
  52661. protected _diffuseTexture: Nullable<BaseTexture>;
  52662. /**
  52663. * Diffuse Texture used in the material.
  52664. * Should be author in a specific way for the best result (refer to the documentation).
  52665. */
  52666. diffuseTexture: Nullable<BaseTexture>;
  52667. protected _shadowLights: Nullable<IShadowLight[]>;
  52668. /**
  52669. * Specify the list of lights casting shadow on the material.
  52670. * All scene shadow lights will be included if null.
  52671. */
  52672. shadowLights: Nullable<IShadowLight[]>;
  52673. protected _shadowLevel: float;
  52674. /**
  52675. * Helps adjusting the shadow to a softer level if required.
  52676. * 0 means black shadows and 1 means no shadows.
  52677. */
  52678. shadowLevel: float;
  52679. protected _sceneCenter: Vector3;
  52680. /**
  52681. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52682. * It is usually zero but might be interesting to modify according to your setup.
  52683. */
  52684. sceneCenter: Vector3;
  52685. protected _opacityFresnel: boolean;
  52686. /**
  52687. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52688. * This helps ensuring a nice transition when the camera goes under the ground.
  52689. */
  52690. opacityFresnel: boolean;
  52691. protected _reflectionFresnel: boolean;
  52692. /**
  52693. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52694. * This helps adding a mirror texture on the ground.
  52695. */
  52696. reflectionFresnel: boolean;
  52697. protected _reflectionFalloffDistance: number;
  52698. /**
  52699. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52700. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52701. */
  52702. reflectionFalloffDistance: number;
  52703. protected _reflectionAmount: number;
  52704. /**
  52705. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52706. */
  52707. reflectionAmount: number;
  52708. protected _reflectionReflectance0: number;
  52709. /**
  52710. * This specifies the weight of the reflection at grazing angle.
  52711. */
  52712. reflectionReflectance0: number;
  52713. protected _reflectionReflectance90: number;
  52714. /**
  52715. * This specifies the weight of the reflection at a perpendicular point of view.
  52716. */
  52717. reflectionReflectance90: number;
  52718. /**
  52719. * Sets the reflection reflectance fresnel values according to the default standard
  52720. * empirically know to work well :-)
  52721. */
  52722. set reflectionStandardFresnelWeight(value: number);
  52723. protected _useRGBColor: boolean;
  52724. /**
  52725. * Helps to directly use the maps channels instead of their level.
  52726. */
  52727. useRGBColor: boolean;
  52728. protected _enableNoise: boolean;
  52729. /**
  52730. * This helps reducing the banding effect that could occur on the background.
  52731. */
  52732. enableNoise: boolean;
  52733. /**
  52734. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52735. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52736. * Recommended to be keep at 1.0 except for special cases.
  52737. */
  52738. get fovMultiplier(): number;
  52739. set fovMultiplier(value: number);
  52740. private _fovMultiplier;
  52741. /**
  52742. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52743. */
  52744. useEquirectangularFOV: boolean;
  52745. private _maxSimultaneousLights;
  52746. /**
  52747. * Number of Simultaneous lights allowed on the material.
  52748. */
  52749. maxSimultaneousLights: int;
  52750. /**
  52751. * Default configuration related to image processing available in the Background Material.
  52752. */
  52753. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52754. /**
  52755. * Keep track of the image processing observer to allow dispose and replace.
  52756. */
  52757. private _imageProcessingObserver;
  52758. /**
  52759. * Attaches a new image processing configuration to the PBR Material.
  52760. * @param configuration (if null the scene configuration will be use)
  52761. */
  52762. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52763. /**
  52764. * Gets the image processing configuration used either in this material.
  52765. */
  52766. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52767. /**
  52768. * Sets the Default image processing configuration used either in the this material.
  52769. *
  52770. * If sets to null, the scene one is in use.
  52771. */
  52772. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52773. /**
  52774. * Gets wether the color curves effect is enabled.
  52775. */
  52776. get cameraColorCurvesEnabled(): boolean;
  52777. /**
  52778. * Sets wether the color curves effect is enabled.
  52779. */
  52780. set cameraColorCurvesEnabled(value: boolean);
  52781. /**
  52782. * Gets wether the color grading effect is enabled.
  52783. */
  52784. get cameraColorGradingEnabled(): boolean;
  52785. /**
  52786. * Gets wether the color grading effect is enabled.
  52787. */
  52788. set cameraColorGradingEnabled(value: boolean);
  52789. /**
  52790. * Gets wether tonemapping is enabled or not.
  52791. */
  52792. get cameraToneMappingEnabled(): boolean;
  52793. /**
  52794. * Sets wether tonemapping is enabled or not
  52795. */
  52796. set cameraToneMappingEnabled(value: boolean);
  52797. /**
  52798. * The camera exposure used on this material.
  52799. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52800. * This corresponds to a photographic exposure.
  52801. */
  52802. get cameraExposure(): float;
  52803. /**
  52804. * The camera exposure used on this material.
  52805. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52806. * This corresponds to a photographic exposure.
  52807. */
  52808. set cameraExposure(value: float);
  52809. /**
  52810. * Gets The camera contrast used on this material.
  52811. */
  52812. get cameraContrast(): float;
  52813. /**
  52814. * Sets The camera contrast used on this material.
  52815. */
  52816. set cameraContrast(value: float);
  52817. /**
  52818. * Gets the Color Grading 2D Lookup Texture.
  52819. */
  52820. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52821. /**
  52822. * Sets the Color Grading 2D Lookup Texture.
  52823. */
  52824. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52825. /**
  52826. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52827. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52828. * 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;
  52829. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52830. */
  52831. get cameraColorCurves(): Nullable<ColorCurves>;
  52832. /**
  52833. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52834. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52835. * 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;
  52836. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52837. */
  52838. set cameraColorCurves(value: Nullable<ColorCurves>);
  52839. /**
  52840. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52841. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52842. */
  52843. switchToBGR: boolean;
  52844. private _renderTargets;
  52845. private _reflectionControls;
  52846. private _white;
  52847. private _primaryShadowColor;
  52848. private _primaryHighlightColor;
  52849. /**
  52850. * Instantiates a Background Material in the given scene
  52851. * @param name The friendly name of the material
  52852. * @param scene The scene to add the material to
  52853. */
  52854. constructor(name: string, scene: Scene);
  52855. /**
  52856. * Gets a boolean indicating that current material needs to register RTT
  52857. */
  52858. get hasRenderTargetTextures(): boolean;
  52859. /**
  52860. * The entire material has been created in order to prevent overdraw.
  52861. * @returns false
  52862. */
  52863. needAlphaTesting(): boolean;
  52864. /**
  52865. * The entire material has been created in order to prevent overdraw.
  52866. * @returns true if blending is enable
  52867. */
  52868. needAlphaBlending(): boolean;
  52869. /**
  52870. * Checks wether the material is ready to be rendered for a given mesh.
  52871. * @param mesh The mesh to render
  52872. * @param subMesh The submesh to check against
  52873. * @param useInstances Specify wether or not the material is used with instances
  52874. * @returns true if all the dependencies are ready (Textures, Effects...)
  52875. */
  52876. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52877. /**
  52878. * Compute the primary color according to the chosen perceptual color.
  52879. */
  52880. private _computePrimaryColorFromPerceptualColor;
  52881. /**
  52882. * Compute the highlights and shadow colors according to their chosen levels.
  52883. */
  52884. private _computePrimaryColors;
  52885. /**
  52886. * Build the uniform buffer used in the material.
  52887. */
  52888. buildUniformLayout(): void;
  52889. /**
  52890. * Unbind the material.
  52891. */
  52892. unbind(): void;
  52893. /**
  52894. * Bind only the world matrix to the material.
  52895. * @param world The world matrix to bind.
  52896. */
  52897. bindOnlyWorldMatrix(world: Matrix): void;
  52898. /**
  52899. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52900. * @param world The world matrix to bind.
  52901. * @param subMesh The submesh to bind for.
  52902. */
  52903. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52904. /**
  52905. * Checks to see if a texture is used in the material.
  52906. * @param texture - Base texture to use.
  52907. * @returns - Boolean specifying if a texture is used in the material.
  52908. */
  52909. hasTexture(texture: BaseTexture): boolean;
  52910. /**
  52911. * Dispose the material.
  52912. * @param forceDisposeEffect Force disposal of the associated effect.
  52913. * @param forceDisposeTextures Force disposal of the associated textures.
  52914. */
  52915. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52916. /**
  52917. * Clones the material.
  52918. * @param name The cloned name.
  52919. * @returns The cloned material.
  52920. */
  52921. clone(name: string): BackgroundMaterial;
  52922. /**
  52923. * Serializes the current material to its JSON representation.
  52924. * @returns The JSON representation.
  52925. */
  52926. serialize(): any;
  52927. /**
  52928. * Gets the class name of the material
  52929. * @returns "BackgroundMaterial"
  52930. */
  52931. getClassName(): string;
  52932. /**
  52933. * Parse a JSON input to create back a background material.
  52934. * @param source The JSON data to parse
  52935. * @param scene The scene to create the parsed material in
  52936. * @param rootUrl The root url of the assets the material depends upon
  52937. * @returns the instantiated BackgroundMaterial.
  52938. */
  52939. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  52940. }
  52941. }
  52942. declare module BABYLON {
  52943. /**
  52944. * Represents the different options available during the creation of
  52945. * a Environment helper.
  52946. *
  52947. * This can control the default ground, skybox and image processing setup of your scene.
  52948. */
  52949. export interface IEnvironmentHelperOptions {
  52950. /**
  52951. * Specifies whether or not to create a ground.
  52952. * True by default.
  52953. */
  52954. createGround: boolean;
  52955. /**
  52956. * Specifies the ground size.
  52957. * 15 by default.
  52958. */
  52959. groundSize: number;
  52960. /**
  52961. * The texture used on the ground for the main color.
  52962. * Comes from the BabylonJS CDN by default.
  52963. *
  52964. * Remarks: Can be either a texture or a url.
  52965. */
  52966. groundTexture: string | BaseTexture;
  52967. /**
  52968. * The color mixed in the ground texture by default.
  52969. * BabylonJS clearColor by default.
  52970. */
  52971. groundColor: Color3;
  52972. /**
  52973. * Specifies the ground opacity.
  52974. * 1 by default.
  52975. */
  52976. groundOpacity: number;
  52977. /**
  52978. * Enables the ground to receive shadows.
  52979. * True by default.
  52980. */
  52981. enableGroundShadow: boolean;
  52982. /**
  52983. * Helps preventing the shadow to be fully black on the ground.
  52984. * 0.5 by default.
  52985. */
  52986. groundShadowLevel: number;
  52987. /**
  52988. * Creates a mirror texture attach to the ground.
  52989. * false by default.
  52990. */
  52991. enableGroundMirror: boolean;
  52992. /**
  52993. * Specifies the ground mirror size ratio.
  52994. * 0.3 by default as the default kernel is 64.
  52995. */
  52996. groundMirrorSizeRatio: number;
  52997. /**
  52998. * Specifies the ground mirror blur kernel size.
  52999. * 64 by default.
  53000. */
  53001. groundMirrorBlurKernel: number;
  53002. /**
  53003. * Specifies the ground mirror visibility amount.
  53004. * 1 by default
  53005. */
  53006. groundMirrorAmount: number;
  53007. /**
  53008. * Specifies the ground mirror reflectance weight.
  53009. * This uses the standard weight of the background material to setup the fresnel effect
  53010. * of the mirror.
  53011. * 1 by default.
  53012. */
  53013. groundMirrorFresnelWeight: number;
  53014. /**
  53015. * Specifies the ground mirror Falloff distance.
  53016. * This can helps reducing the size of the reflection.
  53017. * 0 by Default.
  53018. */
  53019. groundMirrorFallOffDistance: number;
  53020. /**
  53021. * Specifies the ground mirror texture type.
  53022. * Unsigned Int by Default.
  53023. */
  53024. groundMirrorTextureType: number;
  53025. /**
  53026. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53027. * the shown objects.
  53028. */
  53029. groundYBias: number;
  53030. /**
  53031. * Specifies whether or not to create a skybox.
  53032. * True by default.
  53033. */
  53034. createSkybox: boolean;
  53035. /**
  53036. * Specifies the skybox size.
  53037. * 20 by default.
  53038. */
  53039. skyboxSize: number;
  53040. /**
  53041. * The texture used on the skybox for the main color.
  53042. * Comes from the BabylonJS CDN by default.
  53043. *
  53044. * Remarks: Can be either a texture or a url.
  53045. */
  53046. skyboxTexture: string | BaseTexture;
  53047. /**
  53048. * The color mixed in the skybox texture by default.
  53049. * BabylonJS clearColor by default.
  53050. */
  53051. skyboxColor: Color3;
  53052. /**
  53053. * The background rotation around the Y axis of the scene.
  53054. * This helps aligning the key lights of your scene with the background.
  53055. * 0 by default.
  53056. */
  53057. backgroundYRotation: number;
  53058. /**
  53059. * Compute automatically the size of the elements to best fit with the scene.
  53060. */
  53061. sizeAuto: boolean;
  53062. /**
  53063. * Default position of the rootMesh if autoSize is not true.
  53064. */
  53065. rootPosition: Vector3;
  53066. /**
  53067. * Sets up the image processing in the scene.
  53068. * true by default.
  53069. */
  53070. setupImageProcessing: boolean;
  53071. /**
  53072. * The texture used as your environment texture in the scene.
  53073. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53074. *
  53075. * Remarks: Can be either a texture or a url.
  53076. */
  53077. environmentTexture: string | BaseTexture;
  53078. /**
  53079. * The value of the exposure to apply to the scene.
  53080. * 0.6 by default if setupImageProcessing is true.
  53081. */
  53082. cameraExposure: number;
  53083. /**
  53084. * The value of the contrast to apply to the scene.
  53085. * 1.6 by default if setupImageProcessing is true.
  53086. */
  53087. cameraContrast: number;
  53088. /**
  53089. * Specifies whether or not tonemapping should be enabled in the scene.
  53090. * true by default if setupImageProcessing is true.
  53091. */
  53092. toneMappingEnabled: boolean;
  53093. }
  53094. /**
  53095. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53096. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53097. * It also helps with the default setup of your imageProcessing configuration.
  53098. */
  53099. export class EnvironmentHelper {
  53100. /**
  53101. * Default ground texture URL.
  53102. */
  53103. private static _groundTextureCDNUrl;
  53104. /**
  53105. * Default skybox texture URL.
  53106. */
  53107. private static _skyboxTextureCDNUrl;
  53108. /**
  53109. * Default environment texture URL.
  53110. */
  53111. private static _environmentTextureCDNUrl;
  53112. /**
  53113. * Creates the default options for the helper.
  53114. */
  53115. private static _getDefaultOptions;
  53116. private _rootMesh;
  53117. /**
  53118. * Gets the root mesh created by the helper.
  53119. */
  53120. get rootMesh(): Mesh;
  53121. private _skybox;
  53122. /**
  53123. * Gets the skybox created by the helper.
  53124. */
  53125. get skybox(): Nullable<Mesh>;
  53126. private _skyboxTexture;
  53127. /**
  53128. * Gets the skybox texture created by the helper.
  53129. */
  53130. get skyboxTexture(): Nullable<BaseTexture>;
  53131. private _skyboxMaterial;
  53132. /**
  53133. * Gets the skybox material created by the helper.
  53134. */
  53135. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53136. private _ground;
  53137. /**
  53138. * Gets the ground mesh created by the helper.
  53139. */
  53140. get ground(): Nullable<Mesh>;
  53141. private _groundTexture;
  53142. /**
  53143. * Gets the ground texture created by the helper.
  53144. */
  53145. get groundTexture(): Nullable<BaseTexture>;
  53146. private _groundMirror;
  53147. /**
  53148. * Gets the ground mirror created by the helper.
  53149. */
  53150. get groundMirror(): Nullable<MirrorTexture>;
  53151. /**
  53152. * Gets the ground mirror render list to helps pushing the meshes
  53153. * you wish in the ground reflection.
  53154. */
  53155. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53156. private _groundMaterial;
  53157. /**
  53158. * Gets the ground material created by the helper.
  53159. */
  53160. get groundMaterial(): Nullable<BackgroundMaterial>;
  53161. /**
  53162. * Stores the creation options.
  53163. */
  53164. private readonly _scene;
  53165. private _options;
  53166. /**
  53167. * This observable will be notified with any error during the creation of the environment,
  53168. * mainly texture creation errors.
  53169. */
  53170. onErrorObservable: Observable<{
  53171. message?: string;
  53172. exception?: any;
  53173. }>;
  53174. /**
  53175. * constructor
  53176. * @param options Defines the options we want to customize the helper
  53177. * @param scene The scene to add the material to
  53178. */
  53179. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53180. /**
  53181. * Updates the background according to the new options
  53182. * @param options
  53183. */
  53184. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53185. /**
  53186. * Sets the primary color of all the available elements.
  53187. * @param color the main color to affect to the ground and the background
  53188. */
  53189. setMainColor(color: Color3): void;
  53190. /**
  53191. * Setup the image processing according to the specified options.
  53192. */
  53193. private _setupImageProcessing;
  53194. /**
  53195. * Setup the environment texture according to the specified options.
  53196. */
  53197. private _setupEnvironmentTexture;
  53198. /**
  53199. * Setup the background according to the specified options.
  53200. */
  53201. private _setupBackground;
  53202. /**
  53203. * Get the scene sizes according to the setup.
  53204. */
  53205. private _getSceneSize;
  53206. /**
  53207. * Setup the ground according to the specified options.
  53208. */
  53209. private _setupGround;
  53210. /**
  53211. * Setup the ground material according to the specified options.
  53212. */
  53213. private _setupGroundMaterial;
  53214. /**
  53215. * Setup the ground diffuse texture according to the specified options.
  53216. */
  53217. private _setupGroundDiffuseTexture;
  53218. /**
  53219. * Setup the ground mirror texture according to the specified options.
  53220. */
  53221. private _setupGroundMirrorTexture;
  53222. /**
  53223. * Setup the ground to receive the mirror texture.
  53224. */
  53225. private _setupMirrorInGroundMaterial;
  53226. /**
  53227. * Setup the skybox according to the specified options.
  53228. */
  53229. private _setupSkybox;
  53230. /**
  53231. * Setup the skybox material according to the specified options.
  53232. */
  53233. private _setupSkyboxMaterial;
  53234. /**
  53235. * Setup the skybox reflection texture according to the specified options.
  53236. */
  53237. private _setupSkyboxReflectionTexture;
  53238. private _errorHandler;
  53239. /**
  53240. * Dispose all the elements created by the Helper.
  53241. */
  53242. dispose(): void;
  53243. }
  53244. }
  53245. declare module BABYLON {
  53246. /**
  53247. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53248. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53249. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53250. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53251. */
  53252. export class PhotoDome extends TransformNode {
  53253. /**
  53254. * Define the image as a Monoscopic panoramic 360 image.
  53255. */
  53256. static readonly MODE_MONOSCOPIC: number;
  53257. /**
  53258. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53259. */
  53260. static readonly MODE_TOPBOTTOM: number;
  53261. /**
  53262. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53263. */
  53264. static readonly MODE_SIDEBYSIDE: number;
  53265. private _useDirectMapping;
  53266. /**
  53267. * The texture being displayed on the sphere
  53268. */
  53269. protected _photoTexture: Texture;
  53270. /**
  53271. * Gets or sets the texture being displayed on the sphere
  53272. */
  53273. get photoTexture(): Texture;
  53274. set photoTexture(value: Texture);
  53275. /**
  53276. * Observable raised when an error occured while loading the 360 image
  53277. */
  53278. onLoadErrorObservable: Observable<string>;
  53279. /**
  53280. * The skybox material
  53281. */
  53282. protected _material: BackgroundMaterial;
  53283. /**
  53284. * The surface used for the skybox
  53285. */
  53286. protected _mesh: Mesh;
  53287. /**
  53288. * Gets the mesh used for the skybox.
  53289. */
  53290. get mesh(): Mesh;
  53291. /**
  53292. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53293. * Also see the options.resolution property.
  53294. */
  53295. get fovMultiplier(): number;
  53296. set fovMultiplier(value: number);
  53297. private _imageMode;
  53298. /**
  53299. * Gets or set the current video mode for the video. It can be:
  53300. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53301. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53302. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53303. */
  53304. get imageMode(): number;
  53305. set imageMode(value: number);
  53306. /**
  53307. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53308. * @param name Element's name, child elements will append suffixes for their own names.
  53309. * @param urlsOfPhoto defines the url of the photo to display
  53310. * @param options defines an object containing optional or exposed sub element properties
  53311. * @param onError defines a callback called when an error occured while loading the texture
  53312. */
  53313. constructor(name: string, urlOfPhoto: string, options: {
  53314. resolution?: number;
  53315. size?: number;
  53316. useDirectMapping?: boolean;
  53317. faceForward?: boolean;
  53318. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53319. private _onBeforeCameraRenderObserver;
  53320. private _changeImageMode;
  53321. /**
  53322. * Releases resources associated with this node.
  53323. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53324. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53325. */
  53326. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53327. }
  53328. }
  53329. declare module BABYLON {
  53330. /**
  53331. * Class used to host RGBD texture specific utilities
  53332. */
  53333. export class RGBDTextureTools {
  53334. /**
  53335. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53336. * @param texture the texture to expand.
  53337. */
  53338. static ExpandRGBDTexture(texture: Texture): void;
  53339. }
  53340. }
  53341. declare module BABYLON {
  53342. /**
  53343. * Class used to host texture specific utilities
  53344. */
  53345. export class BRDFTextureTools {
  53346. /**
  53347. * Prevents texture cache collision
  53348. */
  53349. private static _instanceNumber;
  53350. /**
  53351. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53352. * @param scene defines the hosting scene
  53353. * @returns the environment BRDF texture
  53354. */
  53355. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53356. private static _environmentBRDFBase64Texture;
  53357. }
  53358. }
  53359. declare module BABYLON {
  53360. /**
  53361. * @hidden
  53362. */
  53363. export interface IMaterialClearCoatDefines {
  53364. CLEARCOAT: boolean;
  53365. CLEARCOAT_DEFAULTIOR: boolean;
  53366. CLEARCOAT_TEXTURE: boolean;
  53367. CLEARCOAT_TEXTUREDIRECTUV: number;
  53368. CLEARCOAT_BUMP: boolean;
  53369. CLEARCOAT_BUMPDIRECTUV: number;
  53370. CLEARCOAT_TINT: boolean;
  53371. CLEARCOAT_TINT_TEXTURE: boolean;
  53372. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53373. /** @hidden */
  53374. _areTexturesDirty: boolean;
  53375. }
  53376. /**
  53377. * Define the code related to the clear coat parameters of the pbr material.
  53378. */
  53379. export class PBRClearCoatConfiguration {
  53380. /**
  53381. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53382. * The default fits with a polyurethane material.
  53383. */
  53384. private static readonly _DefaultIndexOfRefraction;
  53385. private _isEnabled;
  53386. /**
  53387. * Defines if the clear coat is enabled in the material.
  53388. */
  53389. isEnabled: boolean;
  53390. /**
  53391. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53392. */
  53393. intensity: number;
  53394. /**
  53395. * Defines the clear coat layer roughness.
  53396. */
  53397. roughness: number;
  53398. private _indexOfRefraction;
  53399. /**
  53400. * Defines the index of refraction of the clear coat.
  53401. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53402. * The default fits with a polyurethane material.
  53403. * Changing the default value is more performance intensive.
  53404. */
  53405. indexOfRefraction: number;
  53406. private _texture;
  53407. /**
  53408. * Stores the clear coat values in a texture.
  53409. */
  53410. texture: Nullable<BaseTexture>;
  53411. private _bumpTexture;
  53412. /**
  53413. * Define the clear coat specific bump texture.
  53414. */
  53415. bumpTexture: Nullable<BaseTexture>;
  53416. private _isTintEnabled;
  53417. /**
  53418. * Defines if the clear coat tint is enabled in the material.
  53419. */
  53420. isTintEnabled: boolean;
  53421. /**
  53422. * Defines the clear coat tint of the material.
  53423. * This is only use if tint is enabled
  53424. */
  53425. tintColor: Color3;
  53426. /**
  53427. * Defines the distance at which the tint color should be found in the
  53428. * clear coat media.
  53429. * This is only use if tint is enabled
  53430. */
  53431. tintColorAtDistance: number;
  53432. /**
  53433. * Defines the clear coat layer thickness.
  53434. * This is only use if tint is enabled
  53435. */
  53436. tintThickness: number;
  53437. private _tintTexture;
  53438. /**
  53439. * Stores the clear tint values in a texture.
  53440. * rgb is tint
  53441. * a is a thickness factor
  53442. */
  53443. tintTexture: Nullable<BaseTexture>;
  53444. /** @hidden */
  53445. private _internalMarkAllSubMeshesAsTexturesDirty;
  53446. /** @hidden */
  53447. _markAllSubMeshesAsTexturesDirty(): void;
  53448. /**
  53449. * Instantiate a new istance of clear coat configuration.
  53450. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53451. */
  53452. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53453. /**
  53454. * Gets wehter the submesh is ready to be used or not.
  53455. * @param defines the list of "defines" to update.
  53456. * @param scene defines the scene the material belongs to.
  53457. * @param engine defines the engine the material belongs to.
  53458. * @param disableBumpMap defines wether the material disables bump or not.
  53459. * @returns - boolean indicating that the submesh is ready or not.
  53460. */
  53461. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53462. /**
  53463. * Checks to see if a texture is used in the material.
  53464. * @param defines the list of "defines" to update.
  53465. * @param scene defines the scene to the material belongs to.
  53466. */
  53467. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53468. /**
  53469. * Binds the material data.
  53470. * @param uniformBuffer defines the Uniform buffer to fill in.
  53471. * @param scene defines the scene the material belongs to.
  53472. * @param engine defines the engine the material belongs to.
  53473. * @param disableBumpMap defines wether the material disables bump or not.
  53474. * @param isFrozen defines wether the material is frozen or not.
  53475. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53476. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53477. */
  53478. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53479. /**
  53480. * Checks to see if a texture is used in the material.
  53481. * @param texture - Base texture to use.
  53482. * @returns - Boolean specifying if a texture is used in the material.
  53483. */
  53484. hasTexture(texture: BaseTexture): boolean;
  53485. /**
  53486. * Returns an array of the actively used textures.
  53487. * @param activeTextures Array of BaseTextures
  53488. */
  53489. getActiveTextures(activeTextures: BaseTexture[]): void;
  53490. /**
  53491. * Returns the animatable textures.
  53492. * @param animatables Array of animatable textures.
  53493. */
  53494. getAnimatables(animatables: IAnimatable[]): void;
  53495. /**
  53496. * Disposes the resources of the material.
  53497. * @param forceDisposeTextures - Forces the disposal of all textures.
  53498. */
  53499. dispose(forceDisposeTextures?: boolean): void;
  53500. /**
  53501. * Get the current class name of the texture useful for serialization or dynamic coding.
  53502. * @returns "PBRClearCoatConfiguration"
  53503. */
  53504. getClassName(): string;
  53505. /**
  53506. * Add fallbacks to the effect fallbacks list.
  53507. * @param defines defines the Base texture to use.
  53508. * @param fallbacks defines the current fallback list.
  53509. * @param currentRank defines the current fallback rank.
  53510. * @returns the new fallback rank.
  53511. */
  53512. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53513. /**
  53514. * Add the required uniforms to the current list.
  53515. * @param uniforms defines the current uniform list.
  53516. */
  53517. static AddUniforms(uniforms: string[]): void;
  53518. /**
  53519. * Add the required samplers to the current list.
  53520. * @param samplers defines the current sampler list.
  53521. */
  53522. static AddSamplers(samplers: string[]): void;
  53523. /**
  53524. * Add the required uniforms to the current buffer.
  53525. * @param uniformBuffer defines the current uniform buffer.
  53526. */
  53527. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53528. /**
  53529. * Makes a duplicate of the current configuration into another one.
  53530. * @param clearCoatConfiguration define the config where to copy the info
  53531. */
  53532. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  53533. /**
  53534. * Serializes this clear coat configuration.
  53535. * @returns - An object with the serialized config.
  53536. */
  53537. serialize(): any;
  53538. /**
  53539. * Parses a anisotropy Configuration from a serialized object.
  53540. * @param source - Serialized object.
  53541. * @param scene Defines the scene we are parsing for
  53542. * @param rootUrl Defines the rootUrl to load from
  53543. */
  53544. parse(source: any, scene: Scene, rootUrl: string): void;
  53545. }
  53546. }
  53547. declare module BABYLON {
  53548. /**
  53549. * @hidden
  53550. */
  53551. export interface IMaterialAnisotropicDefines {
  53552. ANISOTROPIC: boolean;
  53553. ANISOTROPIC_TEXTURE: boolean;
  53554. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53555. MAINUV1: boolean;
  53556. _areTexturesDirty: boolean;
  53557. _needUVs: boolean;
  53558. }
  53559. /**
  53560. * Define the code related to the anisotropic parameters of the pbr material.
  53561. */
  53562. export class PBRAnisotropicConfiguration {
  53563. private _isEnabled;
  53564. /**
  53565. * Defines if the anisotropy is enabled in the material.
  53566. */
  53567. isEnabled: boolean;
  53568. /**
  53569. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  53570. */
  53571. intensity: number;
  53572. /**
  53573. * Defines if the effect is along the tangents, bitangents or in between.
  53574. * By default, the effect is "strectching" the highlights along the tangents.
  53575. */
  53576. direction: Vector2;
  53577. private _texture;
  53578. /**
  53579. * Stores the anisotropy values in a texture.
  53580. * rg is direction (like normal from -1 to 1)
  53581. * b is a intensity
  53582. */
  53583. texture: Nullable<BaseTexture>;
  53584. /** @hidden */
  53585. private _internalMarkAllSubMeshesAsTexturesDirty;
  53586. /** @hidden */
  53587. _markAllSubMeshesAsTexturesDirty(): void;
  53588. /**
  53589. * Instantiate a new istance of anisotropy configuration.
  53590. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53591. */
  53592. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53593. /**
  53594. * Specifies that the submesh is ready to be used.
  53595. * @param defines the list of "defines" to update.
  53596. * @param scene defines the scene the material belongs to.
  53597. * @returns - boolean indicating that the submesh is ready or not.
  53598. */
  53599. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53600. /**
  53601. * Checks to see if a texture is used in the material.
  53602. * @param defines the list of "defines" to update.
  53603. * @param mesh the mesh we are preparing the defines for.
  53604. * @param scene defines the scene the material belongs to.
  53605. */
  53606. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53607. /**
  53608. * Binds the material data.
  53609. * @param uniformBuffer defines the Uniform buffer to fill in.
  53610. * @param scene defines the scene the material belongs to.
  53611. * @param isFrozen defines wether the material is frozen or not.
  53612. */
  53613. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53614. /**
  53615. * Checks to see if a texture is used in the material.
  53616. * @param texture - Base texture to use.
  53617. * @returns - Boolean specifying if a texture is used in the material.
  53618. */
  53619. hasTexture(texture: BaseTexture): boolean;
  53620. /**
  53621. * Returns an array of the actively used textures.
  53622. * @param activeTextures Array of BaseTextures
  53623. */
  53624. getActiveTextures(activeTextures: BaseTexture[]): void;
  53625. /**
  53626. * Returns the animatable textures.
  53627. * @param animatables Array of animatable textures.
  53628. */
  53629. getAnimatables(animatables: IAnimatable[]): void;
  53630. /**
  53631. * Disposes the resources of the material.
  53632. * @param forceDisposeTextures - Forces the disposal of all textures.
  53633. */
  53634. dispose(forceDisposeTextures?: boolean): void;
  53635. /**
  53636. * Get the current class name of the texture useful for serialization or dynamic coding.
  53637. * @returns "PBRAnisotropicConfiguration"
  53638. */
  53639. getClassName(): string;
  53640. /**
  53641. * Add fallbacks to the effect fallbacks list.
  53642. * @param defines defines the Base texture to use.
  53643. * @param fallbacks defines the current fallback list.
  53644. * @param currentRank defines the current fallback rank.
  53645. * @returns the new fallback rank.
  53646. */
  53647. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53648. /**
  53649. * Add the required uniforms to the current list.
  53650. * @param uniforms defines the current uniform list.
  53651. */
  53652. static AddUniforms(uniforms: string[]): void;
  53653. /**
  53654. * Add the required uniforms to the current buffer.
  53655. * @param uniformBuffer defines the current uniform buffer.
  53656. */
  53657. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53658. /**
  53659. * Add the required samplers to the current list.
  53660. * @param samplers defines the current sampler list.
  53661. */
  53662. static AddSamplers(samplers: string[]): void;
  53663. /**
  53664. * Makes a duplicate of the current configuration into another one.
  53665. * @param anisotropicConfiguration define the config where to copy the info
  53666. */
  53667. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53668. /**
  53669. * Serializes this anisotropy configuration.
  53670. * @returns - An object with the serialized config.
  53671. */
  53672. serialize(): any;
  53673. /**
  53674. * Parses a anisotropy Configuration from a serialized object.
  53675. * @param source - Serialized object.
  53676. * @param scene Defines the scene we are parsing for
  53677. * @param rootUrl Defines the rootUrl to load from
  53678. */
  53679. parse(source: any, scene: Scene, rootUrl: string): void;
  53680. }
  53681. }
  53682. declare module BABYLON {
  53683. /**
  53684. * @hidden
  53685. */
  53686. export interface IMaterialBRDFDefines {
  53687. BRDF_V_HEIGHT_CORRELATED: boolean;
  53688. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53689. SPHERICAL_HARMONICS: boolean;
  53690. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53691. /** @hidden */
  53692. _areMiscDirty: boolean;
  53693. }
  53694. /**
  53695. * Define the code related to the BRDF parameters of the pbr material.
  53696. */
  53697. export class PBRBRDFConfiguration {
  53698. /**
  53699. * Default value used for the energy conservation.
  53700. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53701. */
  53702. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53703. /**
  53704. * Default value used for the Smith Visibility Height Correlated mode.
  53705. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53706. */
  53707. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53708. /**
  53709. * Default value used for the IBL diffuse part.
  53710. * This can help switching back to the polynomials mode globally which is a tiny bit
  53711. * less GPU intensive at the drawback of a lower quality.
  53712. */
  53713. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53714. /**
  53715. * Default value used for activating energy conservation for the specular workflow.
  53716. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53717. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53718. */
  53719. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53720. private _useEnergyConservation;
  53721. /**
  53722. * Defines if the material uses energy conservation.
  53723. */
  53724. useEnergyConservation: boolean;
  53725. private _useSmithVisibilityHeightCorrelated;
  53726. /**
  53727. * LEGACY Mode set to false
  53728. * Defines if the material uses height smith correlated visibility term.
  53729. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53730. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53731. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53732. * Not relying on height correlated will also disable energy conservation.
  53733. */
  53734. useSmithVisibilityHeightCorrelated: boolean;
  53735. private _useSphericalHarmonics;
  53736. /**
  53737. * LEGACY Mode set to false
  53738. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53739. * diffuse part of the IBL.
  53740. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53741. * to the ground truth.
  53742. */
  53743. useSphericalHarmonics: boolean;
  53744. private _useSpecularGlossinessInputEnergyConservation;
  53745. /**
  53746. * Defines if the material uses energy conservation, when the specular workflow is active.
  53747. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53748. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53749. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53750. */
  53751. useSpecularGlossinessInputEnergyConservation: boolean;
  53752. /** @hidden */
  53753. private _internalMarkAllSubMeshesAsMiscDirty;
  53754. /** @hidden */
  53755. _markAllSubMeshesAsMiscDirty(): void;
  53756. /**
  53757. * Instantiate a new istance of clear coat configuration.
  53758. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53759. */
  53760. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53761. /**
  53762. * Checks to see if a texture is used in the material.
  53763. * @param defines the list of "defines" to update.
  53764. */
  53765. prepareDefines(defines: IMaterialBRDFDefines): void;
  53766. /**
  53767. * Get the current class name of the texture useful for serialization or dynamic coding.
  53768. * @returns "PBRClearCoatConfiguration"
  53769. */
  53770. getClassName(): string;
  53771. /**
  53772. * Makes a duplicate of the current configuration into another one.
  53773. * @param brdfConfiguration define the config where to copy the info
  53774. */
  53775. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53776. /**
  53777. * Serializes this BRDF configuration.
  53778. * @returns - An object with the serialized config.
  53779. */
  53780. serialize(): any;
  53781. /**
  53782. * Parses a anisotropy Configuration from a serialized object.
  53783. * @param source - Serialized object.
  53784. * @param scene Defines the scene we are parsing for
  53785. * @param rootUrl Defines the rootUrl to load from
  53786. */
  53787. parse(source: any, scene: Scene, rootUrl: string): void;
  53788. }
  53789. }
  53790. declare module BABYLON {
  53791. /**
  53792. * @hidden
  53793. */
  53794. export interface IMaterialSheenDefines {
  53795. SHEEN: boolean;
  53796. SHEEN_TEXTURE: boolean;
  53797. SHEEN_TEXTUREDIRECTUV: number;
  53798. SHEEN_LINKWITHALBEDO: boolean;
  53799. SHEEN_ROUGHNESS: boolean;
  53800. SHEEN_ALBEDOSCALING: boolean;
  53801. /** @hidden */
  53802. _areTexturesDirty: boolean;
  53803. }
  53804. /**
  53805. * Define the code related to the Sheen parameters of the pbr material.
  53806. */
  53807. export class PBRSheenConfiguration {
  53808. private _isEnabled;
  53809. /**
  53810. * Defines if the material uses sheen.
  53811. */
  53812. isEnabled: boolean;
  53813. private _linkSheenWithAlbedo;
  53814. /**
  53815. * Defines if the sheen is linked to the sheen color.
  53816. */
  53817. linkSheenWithAlbedo: boolean;
  53818. /**
  53819. * Defines the sheen intensity.
  53820. */
  53821. intensity: number;
  53822. /**
  53823. * Defines the sheen color.
  53824. */
  53825. color: Color3;
  53826. private _texture;
  53827. /**
  53828. * Stores the sheen tint values in a texture.
  53829. * rgb is tint
  53830. * a is a intensity
  53831. */
  53832. texture: Nullable<BaseTexture>;
  53833. private _roughness;
  53834. /**
  53835. * Defines the sheen roughness.
  53836. * It is not taken into account if linkSheenWithAlbedo is true.
  53837. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53838. */
  53839. roughness: Nullable<number>;
  53840. private _albedoScaling;
  53841. /**
  53842. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53843. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53844. * making it easier to setup and tweak the effect
  53845. */
  53846. albedoScaling: boolean;
  53847. /** @hidden */
  53848. private _internalMarkAllSubMeshesAsTexturesDirty;
  53849. /** @hidden */
  53850. _markAllSubMeshesAsTexturesDirty(): void;
  53851. /**
  53852. * Instantiate a new istance of clear coat configuration.
  53853. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53854. */
  53855. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53856. /**
  53857. * Specifies that the submesh is ready to be used.
  53858. * @param defines the list of "defines" to update.
  53859. * @param scene defines the scene the material belongs to.
  53860. * @returns - boolean indicating that the submesh is ready or not.
  53861. */
  53862. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53863. /**
  53864. * Checks to see if a texture is used in the material.
  53865. * @param defines the list of "defines" to update.
  53866. * @param scene defines the scene the material belongs to.
  53867. */
  53868. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53869. /**
  53870. * Binds the material data.
  53871. * @param uniformBuffer defines the Uniform buffer to fill in.
  53872. * @param scene defines the scene the material belongs to.
  53873. * @param isFrozen defines wether the material is frozen or not.
  53874. */
  53875. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53876. /**
  53877. * Checks to see if a texture is used in the material.
  53878. * @param texture - Base texture to use.
  53879. * @returns - Boolean specifying if a texture is used in the material.
  53880. */
  53881. hasTexture(texture: BaseTexture): boolean;
  53882. /**
  53883. * Returns an array of the actively used textures.
  53884. * @param activeTextures Array of BaseTextures
  53885. */
  53886. getActiveTextures(activeTextures: BaseTexture[]): void;
  53887. /**
  53888. * Returns the animatable textures.
  53889. * @param animatables Array of animatable textures.
  53890. */
  53891. getAnimatables(animatables: IAnimatable[]): void;
  53892. /**
  53893. * Disposes the resources of the material.
  53894. * @param forceDisposeTextures - Forces the disposal of all textures.
  53895. */
  53896. dispose(forceDisposeTextures?: boolean): void;
  53897. /**
  53898. * Get the current class name of the texture useful for serialization or dynamic coding.
  53899. * @returns "PBRSheenConfiguration"
  53900. */
  53901. getClassName(): string;
  53902. /**
  53903. * Add fallbacks to the effect fallbacks list.
  53904. * @param defines defines the Base texture to use.
  53905. * @param fallbacks defines the current fallback list.
  53906. * @param currentRank defines the current fallback rank.
  53907. * @returns the new fallback rank.
  53908. */
  53909. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53910. /**
  53911. * Add the required uniforms to the current list.
  53912. * @param uniforms defines the current uniform list.
  53913. */
  53914. static AddUniforms(uniforms: string[]): void;
  53915. /**
  53916. * Add the required uniforms to the current buffer.
  53917. * @param uniformBuffer defines the current uniform buffer.
  53918. */
  53919. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53920. /**
  53921. * Add the required samplers to the current list.
  53922. * @param samplers defines the current sampler list.
  53923. */
  53924. static AddSamplers(samplers: string[]): void;
  53925. /**
  53926. * Makes a duplicate of the current configuration into another one.
  53927. * @param sheenConfiguration define the config where to copy the info
  53928. */
  53929. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53930. /**
  53931. * Serializes this BRDF configuration.
  53932. * @returns - An object with the serialized config.
  53933. */
  53934. serialize(): any;
  53935. /**
  53936. * Parses a anisotropy Configuration from a serialized object.
  53937. * @param source - Serialized object.
  53938. * @param scene Defines the scene we are parsing for
  53939. * @param rootUrl Defines the rootUrl to load from
  53940. */
  53941. parse(source: any, scene: Scene, rootUrl: string): void;
  53942. }
  53943. }
  53944. declare module BABYLON {
  53945. /**
  53946. * @hidden
  53947. */
  53948. export interface IMaterialSubSurfaceDefines {
  53949. SUBSURFACE: boolean;
  53950. SS_REFRACTION: boolean;
  53951. SS_TRANSLUCENCY: boolean;
  53952. SS_SCATERRING: boolean;
  53953. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53954. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53955. SS_REFRACTIONMAP_3D: boolean;
  53956. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53957. SS_LODINREFRACTIONALPHA: boolean;
  53958. SS_GAMMAREFRACTION: boolean;
  53959. SS_RGBDREFRACTION: boolean;
  53960. SS_LINEARSPECULARREFRACTION: boolean;
  53961. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53962. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53963. /** @hidden */
  53964. _areTexturesDirty: boolean;
  53965. }
  53966. /**
  53967. * Define the code related to the sub surface parameters of the pbr material.
  53968. */
  53969. export class PBRSubSurfaceConfiguration {
  53970. private _isRefractionEnabled;
  53971. /**
  53972. * Defines if the refraction is enabled in the material.
  53973. */
  53974. isRefractionEnabled: boolean;
  53975. private _isTranslucencyEnabled;
  53976. /**
  53977. * Defines if the translucency is enabled in the material.
  53978. */
  53979. isTranslucencyEnabled: boolean;
  53980. private _isScatteringEnabled;
  53981. /**
  53982. * Defines the refraction intensity of the material.
  53983. * The refraction when enabled replaces the Diffuse part of the material.
  53984. * The intensity helps transitionning between diffuse and refraction.
  53985. */
  53986. refractionIntensity: number;
  53987. /**
  53988. * Defines the translucency intensity of the material.
  53989. * When translucency has been enabled, this defines how much of the "translucency"
  53990. * is addded to the diffuse part of the material.
  53991. */
  53992. translucencyIntensity: number;
  53993. /**
  53994. * Defines the scattering intensity of the material.
  53995. * When scattering has been enabled, this defines how much of the "scattered light"
  53996. * is addded to the diffuse part of the material.
  53997. */
  53998. scatteringIntensity: number;
  53999. private _thicknessTexture;
  54000. /**
  54001. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54002. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54003. * 0 would mean minimumThickness
  54004. * 1 would mean maximumThickness
  54005. * The other channels might be use as a mask to vary the different effects intensity.
  54006. */
  54007. thicknessTexture: Nullable<BaseTexture>;
  54008. private _refractionTexture;
  54009. /**
  54010. * Defines the texture to use for refraction.
  54011. */
  54012. refractionTexture: Nullable<BaseTexture>;
  54013. private _indexOfRefraction;
  54014. /**
  54015. * Index of refraction of the material base layer.
  54016. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54017. *
  54018. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54019. *
  54020. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54021. */
  54022. indexOfRefraction: number;
  54023. private _invertRefractionY;
  54024. /**
  54025. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54026. */
  54027. invertRefractionY: boolean;
  54028. private _linkRefractionWithTransparency;
  54029. /**
  54030. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54031. * Materials half opaque for instance using refraction could benefit from this control.
  54032. */
  54033. linkRefractionWithTransparency: boolean;
  54034. /**
  54035. * Defines the minimum thickness stored in the thickness map.
  54036. * If no thickness map is defined, this value will be used to simulate thickness.
  54037. */
  54038. minimumThickness: number;
  54039. /**
  54040. * Defines the maximum thickness stored in the thickness map.
  54041. */
  54042. maximumThickness: number;
  54043. /**
  54044. * Defines the volume tint of the material.
  54045. * This is used for both translucency and scattering.
  54046. */
  54047. tintColor: Color3;
  54048. /**
  54049. * Defines the distance at which the tint color should be found in the media.
  54050. * This is used for refraction only.
  54051. */
  54052. tintColorAtDistance: number;
  54053. /**
  54054. * Defines how far each channel transmit through the media.
  54055. * It is defined as a color to simplify it selection.
  54056. */
  54057. diffusionDistance: Color3;
  54058. private _useMaskFromThicknessTexture;
  54059. /**
  54060. * Stores the intensity of the different subsurface effects in the thickness texture.
  54061. * * the green channel is the translucency intensity.
  54062. * * the blue channel is the scattering intensity.
  54063. * * the alpha channel is the refraction intensity.
  54064. */
  54065. useMaskFromThicknessTexture: boolean;
  54066. /** @hidden */
  54067. private _internalMarkAllSubMeshesAsTexturesDirty;
  54068. /** @hidden */
  54069. _markAllSubMeshesAsTexturesDirty(): void;
  54070. /**
  54071. * Instantiate a new istance of sub surface configuration.
  54072. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54073. */
  54074. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54075. /**
  54076. * Gets wehter the submesh is ready to be used or not.
  54077. * @param defines the list of "defines" to update.
  54078. * @param scene defines the scene the material belongs to.
  54079. * @returns - boolean indicating that the submesh is ready or not.
  54080. */
  54081. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54082. /**
  54083. * Checks to see if a texture is used in the material.
  54084. * @param defines the list of "defines" to update.
  54085. * @param scene defines the scene to the material belongs to.
  54086. */
  54087. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54088. /**
  54089. * Binds the material data.
  54090. * @param uniformBuffer defines the Uniform buffer to fill in.
  54091. * @param scene defines the scene the material belongs to.
  54092. * @param engine defines the engine the material belongs to.
  54093. * @param isFrozen defines whether the material is frozen or not.
  54094. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54095. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54096. */
  54097. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54098. /**
  54099. * Unbinds the material from the mesh.
  54100. * @param activeEffect defines the effect that should be unbound from.
  54101. * @returns true if unbound, otherwise false
  54102. */
  54103. unbind(activeEffect: Effect): boolean;
  54104. /**
  54105. * Returns the texture used for refraction or null if none is used.
  54106. * @param scene defines the scene the material belongs to.
  54107. * @returns - Refraction texture if present. If no refraction texture and refraction
  54108. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54109. */
  54110. private _getRefractionTexture;
  54111. /**
  54112. * Returns true if alpha blending should be disabled.
  54113. */
  54114. get disableAlphaBlending(): boolean;
  54115. /**
  54116. * Fills the list of render target textures.
  54117. * @param renderTargets the list of render targets to update
  54118. */
  54119. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54120. /**
  54121. * Checks to see if a texture is used in the material.
  54122. * @param texture - Base texture to use.
  54123. * @returns - Boolean specifying if a texture is used in the material.
  54124. */
  54125. hasTexture(texture: BaseTexture): boolean;
  54126. /**
  54127. * Gets a boolean indicating that current material needs to register RTT
  54128. * @returns true if this uses a render target otherwise false.
  54129. */
  54130. hasRenderTargetTextures(): boolean;
  54131. /**
  54132. * Returns an array of the actively used textures.
  54133. * @param activeTextures Array of BaseTextures
  54134. */
  54135. getActiveTextures(activeTextures: BaseTexture[]): void;
  54136. /**
  54137. * Returns the animatable textures.
  54138. * @param animatables Array of animatable textures.
  54139. */
  54140. getAnimatables(animatables: IAnimatable[]): void;
  54141. /**
  54142. * Disposes the resources of the material.
  54143. * @param forceDisposeTextures - Forces the disposal of all textures.
  54144. */
  54145. dispose(forceDisposeTextures?: boolean): void;
  54146. /**
  54147. * Get the current class name of the texture useful for serialization or dynamic coding.
  54148. * @returns "PBRSubSurfaceConfiguration"
  54149. */
  54150. getClassName(): string;
  54151. /**
  54152. * Add fallbacks to the effect fallbacks list.
  54153. * @param defines defines the Base texture to use.
  54154. * @param fallbacks defines the current fallback list.
  54155. * @param currentRank defines the current fallback rank.
  54156. * @returns the new fallback rank.
  54157. */
  54158. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54159. /**
  54160. * Add the required uniforms to the current list.
  54161. * @param uniforms defines the current uniform list.
  54162. */
  54163. static AddUniforms(uniforms: string[]): void;
  54164. /**
  54165. * Add the required samplers to the current list.
  54166. * @param samplers defines the current sampler list.
  54167. */
  54168. static AddSamplers(samplers: string[]): void;
  54169. /**
  54170. * Add the required uniforms to the current buffer.
  54171. * @param uniformBuffer defines the current uniform buffer.
  54172. */
  54173. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54174. /**
  54175. * Makes a duplicate of the current configuration into another one.
  54176. * @param configuration define the config where to copy the info
  54177. */
  54178. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54179. /**
  54180. * Serializes this Sub Surface configuration.
  54181. * @returns - An object with the serialized config.
  54182. */
  54183. serialize(): any;
  54184. /**
  54185. * Parses a anisotropy Configuration from a serialized object.
  54186. * @param source - Serialized object.
  54187. * @param scene Defines the scene we are parsing for
  54188. * @param rootUrl Defines the rootUrl to load from
  54189. */
  54190. parse(source: any, scene: Scene, rootUrl: string): void;
  54191. }
  54192. }
  54193. declare module BABYLON {
  54194. /** @hidden */
  54195. export var pbrFragmentDeclaration: {
  54196. name: string;
  54197. shader: string;
  54198. };
  54199. }
  54200. declare module BABYLON {
  54201. /** @hidden */
  54202. export var pbrUboDeclaration: {
  54203. name: string;
  54204. shader: string;
  54205. };
  54206. }
  54207. declare module BABYLON {
  54208. /** @hidden */
  54209. export var pbrFragmentExtraDeclaration: {
  54210. name: string;
  54211. shader: string;
  54212. };
  54213. }
  54214. declare module BABYLON {
  54215. /** @hidden */
  54216. export var pbrFragmentSamplersDeclaration: {
  54217. name: string;
  54218. shader: string;
  54219. };
  54220. }
  54221. declare module BABYLON {
  54222. /** @hidden */
  54223. export var importanceSampling: {
  54224. name: string;
  54225. shader: string;
  54226. };
  54227. }
  54228. declare module BABYLON {
  54229. /** @hidden */
  54230. export var pbrHelperFunctions: {
  54231. name: string;
  54232. shader: string;
  54233. };
  54234. }
  54235. declare module BABYLON {
  54236. /** @hidden */
  54237. export var harmonicsFunctions: {
  54238. name: string;
  54239. shader: string;
  54240. };
  54241. }
  54242. declare module BABYLON {
  54243. /** @hidden */
  54244. export var pbrDirectLightingSetupFunctions: {
  54245. name: string;
  54246. shader: string;
  54247. };
  54248. }
  54249. declare module BABYLON {
  54250. /** @hidden */
  54251. export var pbrDirectLightingFalloffFunctions: {
  54252. name: string;
  54253. shader: string;
  54254. };
  54255. }
  54256. declare module BABYLON {
  54257. /** @hidden */
  54258. export var pbrBRDFFunctions: {
  54259. name: string;
  54260. shader: string;
  54261. };
  54262. }
  54263. declare module BABYLON {
  54264. /** @hidden */
  54265. export var hdrFilteringFunctions: {
  54266. name: string;
  54267. shader: string;
  54268. };
  54269. }
  54270. declare module BABYLON {
  54271. /** @hidden */
  54272. export var pbrDirectLightingFunctions: {
  54273. name: string;
  54274. shader: string;
  54275. };
  54276. }
  54277. declare module BABYLON {
  54278. /** @hidden */
  54279. export var pbrIBLFunctions: {
  54280. name: string;
  54281. shader: string;
  54282. };
  54283. }
  54284. declare module BABYLON {
  54285. /** @hidden */
  54286. export var pbrBlockAlbedoOpacity: {
  54287. name: string;
  54288. shader: string;
  54289. };
  54290. }
  54291. declare module BABYLON {
  54292. /** @hidden */
  54293. export var pbrBlockReflectivity: {
  54294. name: string;
  54295. shader: string;
  54296. };
  54297. }
  54298. declare module BABYLON {
  54299. /** @hidden */
  54300. export var pbrBlockAmbientOcclusion: {
  54301. name: string;
  54302. shader: string;
  54303. };
  54304. }
  54305. declare module BABYLON {
  54306. /** @hidden */
  54307. export var pbrBlockAlphaFresnel: {
  54308. name: string;
  54309. shader: string;
  54310. };
  54311. }
  54312. declare module BABYLON {
  54313. /** @hidden */
  54314. export var pbrBlockAnisotropic: {
  54315. name: string;
  54316. shader: string;
  54317. };
  54318. }
  54319. declare module BABYLON {
  54320. /** @hidden */
  54321. export var pbrBlockReflection: {
  54322. name: string;
  54323. shader: string;
  54324. };
  54325. }
  54326. declare module BABYLON {
  54327. /** @hidden */
  54328. export var pbrBlockSheen: {
  54329. name: string;
  54330. shader: string;
  54331. };
  54332. }
  54333. declare module BABYLON {
  54334. /** @hidden */
  54335. export var pbrBlockClearcoat: {
  54336. name: string;
  54337. shader: string;
  54338. };
  54339. }
  54340. declare module BABYLON {
  54341. /** @hidden */
  54342. export var pbrBlockSubSurface: {
  54343. name: string;
  54344. shader: string;
  54345. };
  54346. }
  54347. declare module BABYLON {
  54348. /** @hidden */
  54349. export var pbrBlockNormalGeometric: {
  54350. name: string;
  54351. shader: string;
  54352. };
  54353. }
  54354. declare module BABYLON {
  54355. /** @hidden */
  54356. export var pbrBlockNormalFinal: {
  54357. name: string;
  54358. shader: string;
  54359. };
  54360. }
  54361. declare module BABYLON {
  54362. /** @hidden */
  54363. export var pbrBlockGeometryInfo: {
  54364. name: string;
  54365. shader: string;
  54366. };
  54367. }
  54368. declare module BABYLON {
  54369. /** @hidden */
  54370. export var pbrBlockReflectance0: {
  54371. name: string;
  54372. shader: string;
  54373. };
  54374. }
  54375. declare module BABYLON {
  54376. /** @hidden */
  54377. export var pbrBlockReflectance: {
  54378. name: string;
  54379. shader: string;
  54380. };
  54381. }
  54382. declare module BABYLON {
  54383. /** @hidden */
  54384. export var pbrBlockDirectLighting: {
  54385. name: string;
  54386. shader: string;
  54387. };
  54388. }
  54389. declare module BABYLON {
  54390. /** @hidden */
  54391. export var pbrBlockFinalLitComponents: {
  54392. name: string;
  54393. shader: string;
  54394. };
  54395. }
  54396. declare module BABYLON {
  54397. /** @hidden */
  54398. export var pbrBlockFinalUnlitComponents: {
  54399. name: string;
  54400. shader: string;
  54401. };
  54402. }
  54403. declare module BABYLON {
  54404. /** @hidden */
  54405. export var pbrBlockFinalColorComposition: {
  54406. name: string;
  54407. shader: string;
  54408. };
  54409. }
  54410. declare module BABYLON {
  54411. /** @hidden */
  54412. export var pbrBlockImageProcessing: {
  54413. name: string;
  54414. shader: string;
  54415. };
  54416. }
  54417. declare module BABYLON {
  54418. /** @hidden */
  54419. export var pbrDebug: {
  54420. name: string;
  54421. shader: string;
  54422. };
  54423. }
  54424. declare module BABYLON {
  54425. /** @hidden */
  54426. export var pbrPixelShader: {
  54427. name: string;
  54428. shader: string;
  54429. };
  54430. }
  54431. declare module BABYLON {
  54432. /** @hidden */
  54433. export var pbrVertexDeclaration: {
  54434. name: string;
  54435. shader: string;
  54436. };
  54437. }
  54438. declare module BABYLON {
  54439. /** @hidden */
  54440. export var pbrVertexShader: {
  54441. name: string;
  54442. shader: string;
  54443. };
  54444. }
  54445. declare module BABYLON {
  54446. /**
  54447. * Manages the defines for the PBR Material.
  54448. * @hidden
  54449. */
  54450. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  54451. PBR: boolean;
  54452. NUM_SAMPLES: string;
  54453. REALTIME_FILTERING: boolean;
  54454. MAINUV1: boolean;
  54455. MAINUV2: boolean;
  54456. UV1: boolean;
  54457. UV2: boolean;
  54458. ALBEDO: boolean;
  54459. GAMMAALBEDO: boolean;
  54460. ALBEDODIRECTUV: number;
  54461. VERTEXCOLOR: boolean;
  54462. AMBIENT: boolean;
  54463. AMBIENTDIRECTUV: number;
  54464. AMBIENTINGRAYSCALE: boolean;
  54465. OPACITY: boolean;
  54466. VERTEXALPHA: boolean;
  54467. OPACITYDIRECTUV: number;
  54468. OPACITYRGB: boolean;
  54469. ALPHATEST: boolean;
  54470. DEPTHPREPASS: boolean;
  54471. ALPHABLEND: boolean;
  54472. ALPHAFROMALBEDO: boolean;
  54473. ALPHATESTVALUE: string;
  54474. SPECULAROVERALPHA: boolean;
  54475. RADIANCEOVERALPHA: boolean;
  54476. ALPHAFRESNEL: boolean;
  54477. LINEARALPHAFRESNEL: boolean;
  54478. PREMULTIPLYALPHA: boolean;
  54479. EMISSIVE: boolean;
  54480. EMISSIVEDIRECTUV: number;
  54481. REFLECTIVITY: boolean;
  54482. REFLECTIVITYDIRECTUV: number;
  54483. SPECULARTERM: boolean;
  54484. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54485. MICROSURFACEAUTOMATIC: boolean;
  54486. LODBASEDMICROSFURACE: boolean;
  54487. MICROSURFACEMAP: boolean;
  54488. MICROSURFACEMAPDIRECTUV: number;
  54489. METALLICWORKFLOW: boolean;
  54490. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54491. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54492. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54493. AOSTOREINMETALMAPRED: boolean;
  54494. METALLIC_REFLECTANCE: boolean;
  54495. METALLIC_REFLECTANCEDIRECTUV: number;
  54496. ENVIRONMENTBRDF: boolean;
  54497. ENVIRONMENTBRDF_RGBD: boolean;
  54498. NORMAL: boolean;
  54499. TANGENT: boolean;
  54500. BUMP: boolean;
  54501. BUMPDIRECTUV: number;
  54502. OBJECTSPACE_NORMALMAP: boolean;
  54503. PARALLAX: boolean;
  54504. PARALLAXOCCLUSION: boolean;
  54505. NORMALXYSCALE: boolean;
  54506. LIGHTMAP: boolean;
  54507. LIGHTMAPDIRECTUV: number;
  54508. USELIGHTMAPASSHADOWMAP: boolean;
  54509. GAMMALIGHTMAP: boolean;
  54510. RGBDLIGHTMAP: boolean;
  54511. REFLECTION: boolean;
  54512. REFLECTIONMAP_3D: boolean;
  54513. REFLECTIONMAP_SPHERICAL: boolean;
  54514. REFLECTIONMAP_PLANAR: boolean;
  54515. REFLECTIONMAP_CUBIC: boolean;
  54516. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54517. REFLECTIONMAP_PROJECTION: boolean;
  54518. REFLECTIONMAP_SKYBOX: boolean;
  54519. REFLECTIONMAP_EXPLICIT: boolean;
  54520. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54521. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54522. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54523. INVERTCUBICMAP: boolean;
  54524. USESPHERICALFROMREFLECTIONMAP: boolean;
  54525. USEIRRADIANCEMAP: boolean;
  54526. SPHERICAL_HARMONICS: boolean;
  54527. USESPHERICALINVERTEX: boolean;
  54528. REFLECTIONMAP_OPPOSITEZ: boolean;
  54529. LODINREFLECTIONALPHA: boolean;
  54530. GAMMAREFLECTION: boolean;
  54531. RGBDREFLECTION: boolean;
  54532. LINEARSPECULARREFLECTION: boolean;
  54533. RADIANCEOCCLUSION: boolean;
  54534. HORIZONOCCLUSION: boolean;
  54535. INSTANCES: boolean;
  54536. NUM_BONE_INFLUENCERS: number;
  54537. BonesPerMesh: number;
  54538. BONETEXTURE: boolean;
  54539. NONUNIFORMSCALING: boolean;
  54540. MORPHTARGETS: boolean;
  54541. MORPHTARGETS_NORMAL: boolean;
  54542. MORPHTARGETS_TANGENT: boolean;
  54543. MORPHTARGETS_UV: boolean;
  54544. NUM_MORPH_INFLUENCERS: number;
  54545. IMAGEPROCESSING: boolean;
  54546. VIGNETTE: boolean;
  54547. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54548. VIGNETTEBLENDMODEOPAQUE: boolean;
  54549. TONEMAPPING: boolean;
  54550. TONEMAPPING_ACES: boolean;
  54551. CONTRAST: boolean;
  54552. COLORCURVES: boolean;
  54553. COLORGRADING: boolean;
  54554. COLORGRADING3D: boolean;
  54555. SAMPLER3DGREENDEPTH: boolean;
  54556. SAMPLER3DBGRMAP: boolean;
  54557. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54558. EXPOSURE: boolean;
  54559. MULTIVIEW: boolean;
  54560. USEPHYSICALLIGHTFALLOFF: boolean;
  54561. USEGLTFLIGHTFALLOFF: boolean;
  54562. TWOSIDEDLIGHTING: boolean;
  54563. SHADOWFLOAT: boolean;
  54564. CLIPPLANE: boolean;
  54565. CLIPPLANE2: boolean;
  54566. CLIPPLANE3: boolean;
  54567. CLIPPLANE4: boolean;
  54568. CLIPPLANE5: boolean;
  54569. CLIPPLANE6: boolean;
  54570. POINTSIZE: boolean;
  54571. FOG: boolean;
  54572. LOGARITHMICDEPTH: boolean;
  54573. FORCENORMALFORWARD: boolean;
  54574. SPECULARAA: boolean;
  54575. CLEARCOAT: boolean;
  54576. CLEARCOAT_DEFAULTIOR: boolean;
  54577. CLEARCOAT_TEXTURE: boolean;
  54578. CLEARCOAT_TEXTUREDIRECTUV: number;
  54579. CLEARCOAT_BUMP: boolean;
  54580. CLEARCOAT_BUMPDIRECTUV: number;
  54581. CLEARCOAT_TINT: boolean;
  54582. CLEARCOAT_TINT_TEXTURE: boolean;
  54583. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54584. ANISOTROPIC: boolean;
  54585. ANISOTROPIC_TEXTURE: boolean;
  54586. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54587. BRDF_V_HEIGHT_CORRELATED: boolean;
  54588. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54589. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54590. SHEEN: boolean;
  54591. SHEEN_TEXTURE: boolean;
  54592. SHEEN_TEXTUREDIRECTUV: number;
  54593. SHEEN_LINKWITHALBEDO: boolean;
  54594. SHEEN_ROUGHNESS: boolean;
  54595. SHEEN_ALBEDOSCALING: boolean;
  54596. SUBSURFACE: boolean;
  54597. SS_REFRACTION: boolean;
  54598. SS_TRANSLUCENCY: boolean;
  54599. SS_SCATERRING: boolean;
  54600. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54601. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54602. SS_REFRACTIONMAP_3D: boolean;
  54603. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54604. SS_LODINREFRACTIONALPHA: boolean;
  54605. SS_GAMMAREFRACTION: boolean;
  54606. SS_RGBDREFRACTION: boolean;
  54607. SS_LINEARSPECULARREFRACTION: boolean;
  54608. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54609. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54610. UNLIT: boolean;
  54611. DEBUGMODE: number;
  54612. /**
  54613. * Initializes the PBR Material defines.
  54614. */
  54615. constructor();
  54616. /**
  54617. * Resets the PBR Material defines.
  54618. */
  54619. reset(): void;
  54620. }
  54621. /**
  54622. * The Physically based material base class of BJS.
  54623. *
  54624. * This offers the main features of a standard PBR material.
  54625. * For more information, please refer to the documentation :
  54626. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54627. */
  54628. export abstract class PBRBaseMaterial extends PushMaterial {
  54629. /**
  54630. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54631. */
  54632. static readonly PBRMATERIAL_OPAQUE: number;
  54633. /**
  54634. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54635. */
  54636. static readonly PBRMATERIAL_ALPHATEST: number;
  54637. /**
  54638. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54639. */
  54640. static readonly PBRMATERIAL_ALPHABLEND: number;
  54641. /**
  54642. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54643. * They are also discarded below the alpha cutoff threshold to improve performances.
  54644. */
  54645. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54646. /**
  54647. * Defines the default value of how much AO map is occluding the analytical lights
  54648. * (point spot...).
  54649. */
  54650. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54651. /**
  54652. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54653. */
  54654. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54655. /**
  54656. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54657. * to enhance interoperability with other engines.
  54658. */
  54659. static readonly LIGHTFALLOFF_GLTF: number;
  54660. /**
  54661. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54662. * to enhance interoperability with other materials.
  54663. */
  54664. static readonly LIGHTFALLOFF_STANDARD: number;
  54665. /**
  54666. * Intensity of the direct lights e.g. the four lights available in your scene.
  54667. * This impacts both the direct diffuse and specular highlights.
  54668. */
  54669. protected _directIntensity: number;
  54670. /**
  54671. * Intensity of the emissive part of the material.
  54672. * This helps controlling the emissive effect without modifying the emissive color.
  54673. */
  54674. protected _emissiveIntensity: number;
  54675. /**
  54676. * Intensity of the environment e.g. how much the environment will light the object
  54677. * either through harmonics for rough material or through the refelction for shiny ones.
  54678. */
  54679. protected _environmentIntensity: number;
  54680. /**
  54681. * This is a special control allowing the reduction of the specular highlights coming from the
  54682. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54683. */
  54684. protected _specularIntensity: number;
  54685. /**
  54686. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54687. */
  54688. private _lightingInfos;
  54689. /**
  54690. * Debug Control allowing disabling the bump map on this material.
  54691. */
  54692. protected _disableBumpMap: boolean;
  54693. /**
  54694. * AKA Diffuse Texture in standard nomenclature.
  54695. */
  54696. protected _albedoTexture: Nullable<BaseTexture>;
  54697. /**
  54698. * AKA Occlusion Texture in other nomenclature.
  54699. */
  54700. protected _ambientTexture: Nullable<BaseTexture>;
  54701. /**
  54702. * AKA Occlusion Texture Intensity in other nomenclature.
  54703. */
  54704. protected _ambientTextureStrength: number;
  54705. /**
  54706. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54707. * 1 means it completely occludes it
  54708. * 0 mean it has no impact
  54709. */
  54710. protected _ambientTextureImpactOnAnalyticalLights: number;
  54711. /**
  54712. * Stores the alpha values in a texture.
  54713. */
  54714. protected _opacityTexture: Nullable<BaseTexture>;
  54715. /**
  54716. * Stores the reflection values in a texture.
  54717. */
  54718. protected _reflectionTexture: Nullable<BaseTexture>;
  54719. /**
  54720. * Stores the emissive values in a texture.
  54721. */
  54722. protected _emissiveTexture: Nullable<BaseTexture>;
  54723. /**
  54724. * AKA Specular texture in other nomenclature.
  54725. */
  54726. protected _reflectivityTexture: Nullable<BaseTexture>;
  54727. /**
  54728. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54729. */
  54730. protected _metallicTexture: Nullable<BaseTexture>;
  54731. /**
  54732. * Specifies the metallic scalar of the metallic/roughness workflow.
  54733. * Can also be used to scale the metalness values of the metallic texture.
  54734. */
  54735. protected _metallic: Nullable<number>;
  54736. /**
  54737. * Specifies the roughness scalar of the metallic/roughness workflow.
  54738. * Can also be used to scale the roughness values of the metallic texture.
  54739. */
  54740. protected _roughness: Nullable<number>;
  54741. /**
  54742. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  54743. * By default the indexOfrefraction is used to compute F0;
  54744. *
  54745. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  54746. *
  54747. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  54748. * F90 = metallicReflectanceColor;
  54749. */
  54750. protected _metallicF0Factor: number;
  54751. /**
  54752. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  54753. * By default the F90 is always 1;
  54754. *
  54755. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  54756. *
  54757. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  54758. * F90 = metallicReflectanceColor;
  54759. */
  54760. protected _metallicReflectanceColor: Color3;
  54761. /**
  54762. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  54763. * This is multiply against the scalar values defined in the material.
  54764. */
  54765. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  54766. /**
  54767. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54768. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54769. */
  54770. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54771. /**
  54772. * Stores surface normal data used to displace a mesh in a texture.
  54773. */
  54774. protected _bumpTexture: Nullable<BaseTexture>;
  54775. /**
  54776. * Stores the pre-calculated light information of a mesh in a texture.
  54777. */
  54778. protected _lightmapTexture: Nullable<BaseTexture>;
  54779. /**
  54780. * The color of a material in ambient lighting.
  54781. */
  54782. protected _ambientColor: Color3;
  54783. /**
  54784. * AKA Diffuse Color in other nomenclature.
  54785. */
  54786. protected _albedoColor: Color3;
  54787. /**
  54788. * AKA Specular Color in other nomenclature.
  54789. */
  54790. protected _reflectivityColor: Color3;
  54791. /**
  54792. * The color applied when light is reflected from a material.
  54793. */
  54794. protected _reflectionColor: Color3;
  54795. /**
  54796. * The color applied when light is emitted from a material.
  54797. */
  54798. protected _emissiveColor: Color3;
  54799. /**
  54800. * AKA Glossiness in other nomenclature.
  54801. */
  54802. protected _microSurface: number;
  54803. /**
  54804. * Specifies that the material will use the light map as a show map.
  54805. */
  54806. protected _useLightmapAsShadowmap: boolean;
  54807. /**
  54808. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54809. * makes the reflect vector face the model (under horizon).
  54810. */
  54811. protected _useHorizonOcclusion: boolean;
  54812. /**
  54813. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54814. * too much the area relying on ambient texture to define their ambient occlusion.
  54815. */
  54816. protected _useRadianceOcclusion: boolean;
  54817. /**
  54818. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54819. */
  54820. protected _useAlphaFromAlbedoTexture: boolean;
  54821. /**
  54822. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54823. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54824. */
  54825. protected _useSpecularOverAlpha: boolean;
  54826. /**
  54827. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54828. */
  54829. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54830. /**
  54831. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54832. */
  54833. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54834. /**
  54835. * Specifies if the metallic texture contains the roughness information in its green channel.
  54836. */
  54837. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54838. /**
  54839. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54840. */
  54841. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54842. /**
  54843. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54844. */
  54845. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54846. /**
  54847. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54848. */
  54849. protected _useAmbientInGrayScale: boolean;
  54850. /**
  54851. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54852. * The material will try to infer what glossiness each pixel should be.
  54853. */
  54854. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54855. /**
  54856. * Defines the falloff type used in this material.
  54857. * It by default is Physical.
  54858. */
  54859. protected _lightFalloff: number;
  54860. /**
  54861. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54862. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54863. */
  54864. protected _useRadianceOverAlpha: boolean;
  54865. /**
  54866. * Allows using an object space normal map (instead of tangent space).
  54867. */
  54868. protected _useObjectSpaceNormalMap: boolean;
  54869. /**
  54870. * Allows using the bump map in parallax mode.
  54871. */
  54872. protected _useParallax: boolean;
  54873. /**
  54874. * Allows using the bump map in parallax occlusion mode.
  54875. */
  54876. protected _useParallaxOcclusion: boolean;
  54877. /**
  54878. * Controls the scale bias of the parallax mode.
  54879. */
  54880. protected _parallaxScaleBias: number;
  54881. /**
  54882. * If sets to true, disables all the lights affecting the material.
  54883. */
  54884. protected _disableLighting: boolean;
  54885. /**
  54886. * Number of Simultaneous lights allowed on the material.
  54887. */
  54888. protected _maxSimultaneousLights: number;
  54889. /**
  54890. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54891. */
  54892. protected _invertNormalMapX: boolean;
  54893. /**
  54894. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54895. */
  54896. protected _invertNormalMapY: boolean;
  54897. /**
  54898. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54899. */
  54900. protected _twoSidedLighting: boolean;
  54901. /**
  54902. * Defines the alpha limits in alpha test mode.
  54903. */
  54904. protected _alphaCutOff: number;
  54905. /**
  54906. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54907. */
  54908. protected _forceAlphaTest: boolean;
  54909. /**
  54910. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54911. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54912. */
  54913. protected _useAlphaFresnel: boolean;
  54914. /**
  54915. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54916. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54917. */
  54918. protected _useLinearAlphaFresnel: boolean;
  54919. /**
  54920. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54921. * from cos thetav and roughness:
  54922. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54923. */
  54924. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54925. /**
  54926. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54927. */
  54928. protected _forceIrradianceInFragment: boolean;
  54929. private _realTimeFiltering;
  54930. /**
  54931. * Enables realtime filtering on the texture.
  54932. */
  54933. get realTimeFiltering(): boolean;
  54934. set realTimeFiltering(b: boolean);
  54935. private _realTimeFilteringQuality;
  54936. /**
  54937. * Quality switch for realtime filtering
  54938. */
  54939. get realTimeFilteringQuality(): number;
  54940. set realTimeFilteringQuality(n: number);
  54941. /**
  54942. * Force normal to face away from face.
  54943. */
  54944. protected _forceNormalForward: boolean;
  54945. /**
  54946. * Enables specular anti aliasing in the PBR shader.
  54947. * It will both interacts on the Geometry for analytical and IBL lighting.
  54948. * It also prefilter the roughness map based on the bump values.
  54949. */
  54950. protected _enableSpecularAntiAliasing: boolean;
  54951. /**
  54952. * Default configuration related to image processing available in the PBR Material.
  54953. */
  54954. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54955. /**
  54956. * Keep track of the image processing observer to allow dispose and replace.
  54957. */
  54958. private _imageProcessingObserver;
  54959. /**
  54960. * Attaches a new image processing configuration to the PBR Material.
  54961. * @param configuration
  54962. */
  54963. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54964. /**
  54965. * Stores the available render targets.
  54966. */
  54967. private _renderTargets;
  54968. /**
  54969. * Sets the global ambient color for the material used in lighting calculations.
  54970. */
  54971. private _globalAmbientColor;
  54972. /**
  54973. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54974. */
  54975. private _useLogarithmicDepth;
  54976. /**
  54977. * If set to true, no lighting calculations will be applied.
  54978. */
  54979. private _unlit;
  54980. private _debugMode;
  54981. /**
  54982. * @hidden
  54983. * This is reserved for the inspector.
  54984. * Defines the material debug mode.
  54985. * It helps seeing only some components of the material while troubleshooting.
  54986. */
  54987. debugMode: number;
  54988. /**
  54989. * @hidden
  54990. * This is reserved for the inspector.
  54991. * Specify from where on screen the debug mode should start.
  54992. * The value goes from -1 (full screen) to 1 (not visible)
  54993. * It helps with side by side comparison against the final render
  54994. * This defaults to -1
  54995. */
  54996. private debugLimit;
  54997. /**
  54998. * @hidden
  54999. * This is reserved for the inspector.
  55000. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55001. * You can use the factor to better multiply the final value.
  55002. */
  55003. private debugFactor;
  55004. /**
  55005. * Defines the clear coat layer parameters for the material.
  55006. */
  55007. readonly clearCoat: PBRClearCoatConfiguration;
  55008. /**
  55009. * Defines the anisotropic parameters for the material.
  55010. */
  55011. readonly anisotropy: PBRAnisotropicConfiguration;
  55012. /**
  55013. * Defines the BRDF parameters for the material.
  55014. */
  55015. readonly brdf: PBRBRDFConfiguration;
  55016. /**
  55017. * Defines the Sheen parameters for the material.
  55018. */
  55019. readonly sheen: PBRSheenConfiguration;
  55020. /**
  55021. * Defines the SubSurface parameters for the material.
  55022. */
  55023. readonly subSurface: PBRSubSurfaceConfiguration;
  55024. protected _rebuildInParallel: boolean;
  55025. /**
  55026. * Instantiates a new PBRMaterial instance.
  55027. *
  55028. * @param name The material name
  55029. * @param scene The scene the material will be use in.
  55030. */
  55031. constructor(name: string, scene: Scene);
  55032. /**
  55033. * Gets a boolean indicating that current material needs to register RTT
  55034. */
  55035. get hasRenderTargetTextures(): boolean;
  55036. /**
  55037. * Gets the name of the material class.
  55038. */
  55039. getClassName(): string;
  55040. /**
  55041. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55042. */
  55043. get useLogarithmicDepth(): boolean;
  55044. /**
  55045. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55046. */
  55047. set useLogarithmicDepth(value: boolean);
  55048. /**
  55049. * Returns true if alpha blending should be disabled.
  55050. */
  55051. protected get _disableAlphaBlending(): boolean;
  55052. /**
  55053. * Specifies whether or not this material should be rendered in alpha blend mode.
  55054. */
  55055. needAlphaBlending(): boolean;
  55056. /**
  55057. * Specifies whether or not this material should be rendered in alpha test mode.
  55058. */
  55059. needAlphaTesting(): boolean;
  55060. /**
  55061. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55062. */
  55063. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55064. /**
  55065. * Gets the texture used for the alpha test.
  55066. */
  55067. getAlphaTestTexture(): Nullable<BaseTexture>;
  55068. /**
  55069. * Specifies that the submesh is ready to be used.
  55070. * @param mesh - BJS mesh.
  55071. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55072. * @param useInstances - Specifies that instances should be used.
  55073. * @returns - boolean indicating that the submesh is ready or not.
  55074. */
  55075. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55076. /**
  55077. * Specifies if the material uses metallic roughness workflow.
  55078. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55079. */
  55080. isMetallicWorkflow(): boolean;
  55081. private _prepareEffect;
  55082. private _prepareDefines;
  55083. /**
  55084. * Force shader compilation
  55085. */
  55086. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55087. /**
  55088. * Initializes the uniform buffer layout for the shader.
  55089. */
  55090. buildUniformLayout(): void;
  55091. /**
  55092. * Unbinds the material from the mesh
  55093. */
  55094. unbind(): void;
  55095. /**
  55096. * Binds the submesh data.
  55097. * @param world - The world matrix.
  55098. * @param mesh - The BJS mesh.
  55099. * @param subMesh - A submesh of the BJS mesh.
  55100. */
  55101. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55102. /**
  55103. * Returns the animatable textures.
  55104. * @returns - Array of animatable textures.
  55105. */
  55106. getAnimatables(): IAnimatable[];
  55107. /**
  55108. * Returns the texture used for reflections.
  55109. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55110. */
  55111. private _getReflectionTexture;
  55112. /**
  55113. * Returns an array of the actively used textures.
  55114. * @returns - Array of BaseTextures
  55115. */
  55116. getActiveTextures(): BaseTexture[];
  55117. /**
  55118. * Checks to see if a texture is used in the material.
  55119. * @param texture - Base texture to use.
  55120. * @returns - Boolean specifying if a texture is used in the material.
  55121. */
  55122. hasTexture(texture: BaseTexture): boolean;
  55123. /**
  55124. * Disposes the resources of the material.
  55125. * @param forceDisposeEffect - Forces the disposal of effects.
  55126. * @param forceDisposeTextures - Forces the disposal of all textures.
  55127. */
  55128. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55129. }
  55130. }
  55131. declare module BABYLON {
  55132. /**
  55133. * The Physically based material of BJS.
  55134. *
  55135. * This offers the main features of a standard PBR material.
  55136. * For more information, please refer to the documentation :
  55137. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55138. */
  55139. export class PBRMaterial extends PBRBaseMaterial {
  55140. /**
  55141. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55142. */
  55143. static readonly PBRMATERIAL_OPAQUE: number;
  55144. /**
  55145. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55146. */
  55147. static readonly PBRMATERIAL_ALPHATEST: number;
  55148. /**
  55149. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55150. */
  55151. static readonly PBRMATERIAL_ALPHABLEND: number;
  55152. /**
  55153. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55154. * They are also discarded below the alpha cutoff threshold to improve performances.
  55155. */
  55156. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55157. /**
  55158. * Defines the default value of how much AO map is occluding the analytical lights
  55159. * (point spot...).
  55160. */
  55161. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55162. /**
  55163. * Intensity of the direct lights e.g. the four lights available in your scene.
  55164. * This impacts both the direct diffuse and specular highlights.
  55165. */
  55166. directIntensity: number;
  55167. /**
  55168. * Intensity of the emissive part of the material.
  55169. * This helps controlling the emissive effect without modifying the emissive color.
  55170. */
  55171. emissiveIntensity: number;
  55172. /**
  55173. * Intensity of the environment e.g. how much the environment will light the object
  55174. * either through harmonics for rough material or through the refelction for shiny ones.
  55175. */
  55176. environmentIntensity: number;
  55177. /**
  55178. * This is a special control allowing the reduction of the specular highlights coming from the
  55179. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55180. */
  55181. specularIntensity: number;
  55182. /**
  55183. * Debug Control allowing disabling the bump map on this material.
  55184. */
  55185. disableBumpMap: boolean;
  55186. /**
  55187. * AKA Diffuse Texture in standard nomenclature.
  55188. */
  55189. albedoTexture: BaseTexture;
  55190. /**
  55191. * AKA Occlusion Texture in other nomenclature.
  55192. */
  55193. ambientTexture: BaseTexture;
  55194. /**
  55195. * AKA Occlusion Texture Intensity in other nomenclature.
  55196. */
  55197. ambientTextureStrength: number;
  55198. /**
  55199. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55200. * 1 means it completely occludes it
  55201. * 0 mean it has no impact
  55202. */
  55203. ambientTextureImpactOnAnalyticalLights: number;
  55204. /**
  55205. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55206. */
  55207. opacityTexture: BaseTexture;
  55208. /**
  55209. * Stores the reflection values in a texture.
  55210. */
  55211. reflectionTexture: Nullable<BaseTexture>;
  55212. /**
  55213. * Stores the emissive values in a texture.
  55214. */
  55215. emissiveTexture: BaseTexture;
  55216. /**
  55217. * AKA Specular texture in other nomenclature.
  55218. */
  55219. reflectivityTexture: BaseTexture;
  55220. /**
  55221. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55222. */
  55223. metallicTexture: BaseTexture;
  55224. /**
  55225. * Specifies the metallic scalar of the metallic/roughness workflow.
  55226. * Can also be used to scale the metalness values of the metallic texture.
  55227. */
  55228. metallic: Nullable<number>;
  55229. /**
  55230. * Specifies the roughness scalar of the metallic/roughness workflow.
  55231. * Can also be used to scale the roughness values of the metallic texture.
  55232. */
  55233. roughness: Nullable<number>;
  55234. /**
  55235. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55236. * By default the indexOfrefraction is used to compute F0;
  55237. *
  55238. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55239. *
  55240. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55241. * F90 = metallicReflectanceColor;
  55242. */
  55243. metallicF0Factor: number;
  55244. /**
  55245. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55246. * By default the F90 is always 1;
  55247. *
  55248. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55249. *
  55250. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55251. * F90 = metallicReflectanceColor;
  55252. */
  55253. metallicReflectanceColor: Color3;
  55254. /**
  55255. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55256. * This is multiply against the scalar values defined in the material.
  55257. */
  55258. metallicReflectanceTexture: Nullable<BaseTexture>;
  55259. /**
  55260. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55261. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55262. */
  55263. microSurfaceTexture: BaseTexture;
  55264. /**
  55265. * Stores surface normal data used to displace a mesh in a texture.
  55266. */
  55267. bumpTexture: BaseTexture;
  55268. /**
  55269. * Stores the pre-calculated light information of a mesh in a texture.
  55270. */
  55271. lightmapTexture: BaseTexture;
  55272. /**
  55273. * Stores the refracted light information in a texture.
  55274. */
  55275. get refractionTexture(): Nullable<BaseTexture>;
  55276. set refractionTexture(value: Nullable<BaseTexture>);
  55277. /**
  55278. * The color of a material in ambient lighting.
  55279. */
  55280. ambientColor: Color3;
  55281. /**
  55282. * AKA Diffuse Color in other nomenclature.
  55283. */
  55284. albedoColor: Color3;
  55285. /**
  55286. * AKA Specular Color in other nomenclature.
  55287. */
  55288. reflectivityColor: Color3;
  55289. /**
  55290. * The color reflected from the material.
  55291. */
  55292. reflectionColor: Color3;
  55293. /**
  55294. * The color emitted from the material.
  55295. */
  55296. emissiveColor: Color3;
  55297. /**
  55298. * AKA Glossiness in other nomenclature.
  55299. */
  55300. microSurface: number;
  55301. /**
  55302. * Index of refraction of the material base layer.
  55303. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55304. *
  55305. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55306. *
  55307. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55308. */
  55309. get indexOfRefraction(): number;
  55310. set indexOfRefraction(value: number);
  55311. /**
  55312. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55313. */
  55314. get invertRefractionY(): boolean;
  55315. set invertRefractionY(value: boolean);
  55316. /**
  55317. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55318. * Materials half opaque for instance using refraction could benefit from this control.
  55319. */
  55320. get linkRefractionWithTransparency(): boolean;
  55321. set linkRefractionWithTransparency(value: boolean);
  55322. /**
  55323. * If true, the light map contains occlusion information instead of lighting info.
  55324. */
  55325. useLightmapAsShadowmap: boolean;
  55326. /**
  55327. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55328. */
  55329. useAlphaFromAlbedoTexture: boolean;
  55330. /**
  55331. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55332. */
  55333. forceAlphaTest: boolean;
  55334. /**
  55335. * Defines the alpha limits in alpha test mode.
  55336. */
  55337. alphaCutOff: number;
  55338. /**
  55339. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55340. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55341. */
  55342. useSpecularOverAlpha: boolean;
  55343. /**
  55344. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55345. */
  55346. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55347. /**
  55348. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55349. */
  55350. useRoughnessFromMetallicTextureAlpha: boolean;
  55351. /**
  55352. * Specifies if the metallic texture contains the roughness information in its green channel.
  55353. */
  55354. useRoughnessFromMetallicTextureGreen: boolean;
  55355. /**
  55356. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55357. */
  55358. useMetallnessFromMetallicTextureBlue: boolean;
  55359. /**
  55360. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55361. */
  55362. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55363. /**
  55364. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55365. */
  55366. useAmbientInGrayScale: boolean;
  55367. /**
  55368. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55369. * The material will try to infer what glossiness each pixel should be.
  55370. */
  55371. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55372. /**
  55373. * BJS is using an harcoded light falloff based on a manually sets up range.
  55374. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55375. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55376. */
  55377. get usePhysicalLightFalloff(): boolean;
  55378. /**
  55379. * BJS is using an harcoded light falloff based on a manually sets up range.
  55380. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55381. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55382. */
  55383. set usePhysicalLightFalloff(value: boolean);
  55384. /**
  55385. * In order to support the falloff compatibility with gltf, a special mode has been added
  55386. * to reproduce the gltf light falloff.
  55387. */
  55388. get useGLTFLightFalloff(): boolean;
  55389. /**
  55390. * In order to support the falloff compatibility with gltf, a special mode has been added
  55391. * to reproduce the gltf light falloff.
  55392. */
  55393. set useGLTFLightFalloff(value: boolean);
  55394. /**
  55395. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55396. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55397. */
  55398. useRadianceOverAlpha: boolean;
  55399. /**
  55400. * Allows using an object space normal map (instead of tangent space).
  55401. */
  55402. useObjectSpaceNormalMap: boolean;
  55403. /**
  55404. * Allows using the bump map in parallax mode.
  55405. */
  55406. useParallax: boolean;
  55407. /**
  55408. * Allows using the bump map in parallax occlusion mode.
  55409. */
  55410. useParallaxOcclusion: boolean;
  55411. /**
  55412. * Controls the scale bias of the parallax mode.
  55413. */
  55414. parallaxScaleBias: number;
  55415. /**
  55416. * If sets to true, disables all the lights affecting the material.
  55417. */
  55418. disableLighting: boolean;
  55419. /**
  55420. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55421. */
  55422. forceIrradianceInFragment: boolean;
  55423. /**
  55424. * Number of Simultaneous lights allowed on the material.
  55425. */
  55426. maxSimultaneousLights: number;
  55427. /**
  55428. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55429. */
  55430. invertNormalMapX: boolean;
  55431. /**
  55432. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55433. */
  55434. invertNormalMapY: boolean;
  55435. /**
  55436. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55437. */
  55438. twoSidedLighting: boolean;
  55439. /**
  55440. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55441. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55442. */
  55443. useAlphaFresnel: boolean;
  55444. /**
  55445. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55446. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55447. */
  55448. useLinearAlphaFresnel: boolean;
  55449. /**
  55450. * Let user defines the brdf lookup texture used for IBL.
  55451. * A default 8bit version is embedded but you could point at :
  55452. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55453. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55454. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55455. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55456. */
  55457. environmentBRDFTexture: Nullable<BaseTexture>;
  55458. /**
  55459. * Force normal to face away from face.
  55460. */
  55461. forceNormalForward: boolean;
  55462. /**
  55463. * Enables specular anti aliasing in the PBR shader.
  55464. * It will both interacts on the Geometry for analytical and IBL lighting.
  55465. * It also prefilter the roughness map based on the bump values.
  55466. */
  55467. enableSpecularAntiAliasing: boolean;
  55468. /**
  55469. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55470. * makes the reflect vector face the model (under horizon).
  55471. */
  55472. useHorizonOcclusion: boolean;
  55473. /**
  55474. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55475. * too much the area relying on ambient texture to define their ambient occlusion.
  55476. */
  55477. useRadianceOcclusion: boolean;
  55478. /**
  55479. * If set to true, no lighting calculations will be applied.
  55480. */
  55481. unlit: boolean;
  55482. /**
  55483. * Gets the image processing configuration used either in this material.
  55484. */
  55485. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55486. /**
  55487. * Sets the Default image processing configuration used either in the this material.
  55488. *
  55489. * If sets to null, the scene one is in use.
  55490. */
  55491. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55492. /**
  55493. * Gets wether the color curves effect is enabled.
  55494. */
  55495. get cameraColorCurvesEnabled(): boolean;
  55496. /**
  55497. * Sets wether the color curves effect is enabled.
  55498. */
  55499. set cameraColorCurvesEnabled(value: boolean);
  55500. /**
  55501. * Gets wether the color grading effect is enabled.
  55502. */
  55503. get cameraColorGradingEnabled(): boolean;
  55504. /**
  55505. * Gets wether the color grading effect is enabled.
  55506. */
  55507. set cameraColorGradingEnabled(value: boolean);
  55508. /**
  55509. * Gets wether tonemapping is enabled or not.
  55510. */
  55511. get cameraToneMappingEnabled(): boolean;
  55512. /**
  55513. * Sets wether tonemapping is enabled or not
  55514. */
  55515. set cameraToneMappingEnabled(value: boolean);
  55516. /**
  55517. * The camera exposure used on this material.
  55518. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55519. * This corresponds to a photographic exposure.
  55520. */
  55521. get cameraExposure(): number;
  55522. /**
  55523. * The camera exposure used on this material.
  55524. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55525. * This corresponds to a photographic exposure.
  55526. */
  55527. set cameraExposure(value: number);
  55528. /**
  55529. * Gets The camera contrast used on this material.
  55530. */
  55531. get cameraContrast(): number;
  55532. /**
  55533. * Sets The camera contrast used on this material.
  55534. */
  55535. set cameraContrast(value: number);
  55536. /**
  55537. * Gets the Color Grading 2D Lookup Texture.
  55538. */
  55539. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55540. /**
  55541. * Sets the Color Grading 2D Lookup Texture.
  55542. */
  55543. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55544. /**
  55545. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55546. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55547. * 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;
  55548. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55549. */
  55550. get cameraColorCurves(): Nullable<ColorCurves>;
  55551. /**
  55552. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55553. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55554. * 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;
  55555. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55556. */
  55557. set cameraColorCurves(value: Nullable<ColorCurves>);
  55558. /**
  55559. * Instantiates a new PBRMaterial instance.
  55560. *
  55561. * @param name The material name
  55562. * @param scene The scene the material will be use in.
  55563. */
  55564. constructor(name: string, scene: Scene);
  55565. /**
  55566. * Returns the name of this material class.
  55567. */
  55568. getClassName(): string;
  55569. /**
  55570. * Makes a duplicate of the current material.
  55571. * @param name - name to use for the new material.
  55572. */
  55573. clone(name: string): PBRMaterial;
  55574. /**
  55575. * Serializes this PBR Material.
  55576. * @returns - An object with the serialized material.
  55577. */
  55578. serialize(): any;
  55579. /**
  55580. * Parses a PBR Material from a serialized object.
  55581. * @param source - Serialized object.
  55582. * @param scene - BJS scene instance.
  55583. * @param rootUrl - url for the scene object
  55584. * @returns - PBRMaterial
  55585. */
  55586. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55587. }
  55588. }
  55589. declare module BABYLON {
  55590. /**
  55591. * Direct draw surface info
  55592. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55593. */
  55594. export interface DDSInfo {
  55595. /**
  55596. * Width of the texture
  55597. */
  55598. width: number;
  55599. /**
  55600. * Width of the texture
  55601. */
  55602. height: number;
  55603. /**
  55604. * Number of Mipmaps for the texture
  55605. * @see https://en.wikipedia.org/wiki/Mipmap
  55606. */
  55607. mipmapCount: number;
  55608. /**
  55609. * If the textures format is a known fourCC format
  55610. * @see https://www.fourcc.org/
  55611. */
  55612. isFourCC: boolean;
  55613. /**
  55614. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55615. */
  55616. isRGB: boolean;
  55617. /**
  55618. * If the texture is a lumincance format
  55619. */
  55620. isLuminance: boolean;
  55621. /**
  55622. * If this is a cube texture
  55623. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55624. */
  55625. isCube: boolean;
  55626. /**
  55627. * If the texture is a compressed format eg. FOURCC_DXT1
  55628. */
  55629. isCompressed: boolean;
  55630. /**
  55631. * The dxgiFormat of the texture
  55632. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55633. */
  55634. dxgiFormat: number;
  55635. /**
  55636. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55637. */
  55638. textureType: number;
  55639. /**
  55640. * Sphericle polynomial created for the dds texture
  55641. */
  55642. sphericalPolynomial?: SphericalPolynomial;
  55643. }
  55644. /**
  55645. * Class used to provide DDS decompression tools
  55646. */
  55647. export class DDSTools {
  55648. /**
  55649. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55650. */
  55651. static StoreLODInAlphaChannel: boolean;
  55652. /**
  55653. * Gets DDS information from an array buffer
  55654. * @param data defines the array buffer view to read data from
  55655. * @returns the DDS information
  55656. */
  55657. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55658. private static _FloatView;
  55659. private static _Int32View;
  55660. private static _ToHalfFloat;
  55661. private static _FromHalfFloat;
  55662. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55663. private static _GetHalfFloatRGBAArrayBuffer;
  55664. private static _GetFloatRGBAArrayBuffer;
  55665. private static _GetFloatAsUIntRGBAArrayBuffer;
  55666. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55667. private static _GetRGBAArrayBuffer;
  55668. private static _ExtractLongWordOrder;
  55669. private static _GetRGBArrayBuffer;
  55670. private static _GetLuminanceArrayBuffer;
  55671. /**
  55672. * Uploads DDS Levels to a Babylon Texture
  55673. * @hidden
  55674. */
  55675. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55676. }
  55677. interface ThinEngine {
  55678. /**
  55679. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55680. * @param rootUrl defines the url where the file to load is located
  55681. * @param scene defines the current scene
  55682. * @param lodScale defines scale to apply to the mip map selection
  55683. * @param lodOffset defines offset to apply to the mip map selection
  55684. * @param onLoad defines an optional callback raised when the texture is loaded
  55685. * @param onError defines an optional callback raised if there is an issue to load the texture
  55686. * @param format defines the format of the data
  55687. * @param forcedExtension defines the extension to use to pick the right loader
  55688. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55689. * @returns the cube texture as an InternalTexture
  55690. */
  55691. 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;
  55692. }
  55693. }
  55694. declare module BABYLON {
  55695. /**
  55696. * Implementation of the DDS Texture Loader.
  55697. * @hidden
  55698. */
  55699. export class _DDSTextureLoader implements IInternalTextureLoader {
  55700. /**
  55701. * Defines wether the loader supports cascade loading the different faces.
  55702. */
  55703. readonly supportCascades: boolean;
  55704. /**
  55705. * This returns if the loader support the current file information.
  55706. * @param extension defines the file extension of the file being loaded
  55707. * @returns true if the loader can load the specified file
  55708. */
  55709. canLoad(extension: string): boolean;
  55710. /**
  55711. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55712. * @param data contains the texture data
  55713. * @param texture defines the BabylonJS internal texture
  55714. * @param createPolynomials will be true if polynomials have been requested
  55715. * @param onLoad defines the callback to trigger once the texture is ready
  55716. * @param onError defines the callback to trigger in case of error
  55717. */
  55718. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55719. /**
  55720. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55721. * @param data contains the texture data
  55722. * @param texture defines the BabylonJS internal texture
  55723. * @param callback defines the method to call once ready to upload
  55724. */
  55725. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55726. }
  55727. }
  55728. declare module BABYLON {
  55729. /**
  55730. * Implementation of the ENV Texture Loader.
  55731. * @hidden
  55732. */
  55733. export class _ENVTextureLoader implements IInternalTextureLoader {
  55734. /**
  55735. * Defines wether the loader supports cascade loading the different faces.
  55736. */
  55737. readonly supportCascades: boolean;
  55738. /**
  55739. * This returns if the loader support the current file information.
  55740. * @param extension defines the file extension of the file being loaded
  55741. * @returns true if the loader can load the specified file
  55742. */
  55743. canLoad(extension: string): boolean;
  55744. /**
  55745. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55746. * @param data contains the texture data
  55747. * @param texture defines the BabylonJS internal texture
  55748. * @param createPolynomials will be true if polynomials have been requested
  55749. * @param onLoad defines the callback to trigger once the texture is ready
  55750. * @param onError defines the callback to trigger in case of error
  55751. */
  55752. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55753. /**
  55754. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55755. * @param data contains the texture data
  55756. * @param texture defines the BabylonJS internal texture
  55757. * @param callback defines the method to call once ready to upload
  55758. */
  55759. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55760. }
  55761. }
  55762. declare module BABYLON {
  55763. /**
  55764. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55765. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55766. */
  55767. export class KhronosTextureContainer {
  55768. /** contents of the KTX container file */
  55769. data: ArrayBufferView;
  55770. private static HEADER_LEN;
  55771. private static COMPRESSED_2D;
  55772. private static COMPRESSED_3D;
  55773. private static TEX_2D;
  55774. private static TEX_3D;
  55775. /**
  55776. * Gets the openGL type
  55777. */
  55778. glType: number;
  55779. /**
  55780. * Gets the openGL type size
  55781. */
  55782. glTypeSize: number;
  55783. /**
  55784. * Gets the openGL format
  55785. */
  55786. glFormat: number;
  55787. /**
  55788. * Gets the openGL internal format
  55789. */
  55790. glInternalFormat: number;
  55791. /**
  55792. * Gets the base internal format
  55793. */
  55794. glBaseInternalFormat: number;
  55795. /**
  55796. * Gets image width in pixel
  55797. */
  55798. pixelWidth: number;
  55799. /**
  55800. * Gets image height in pixel
  55801. */
  55802. pixelHeight: number;
  55803. /**
  55804. * Gets image depth in pixels
  55805. */
  55806. pixelDepth: number;
  55807. /**
  55808. * Gets the number of array elements
  55809. */
  55810. numberOfArrayElements: number;
  55811. /**
  55812. * Gets the number of faces
  55813. */
  55814. numberOfFaces: number;
  55815. /**
  55816. * Gets the number of mipmap levels
  55817. */
  55818. numberOfMipmapLevels: number;
  55819. /**
  55820. * Gets the bytes of key value data
  55821. */
  55822. bytesOfKeyValueData: number;
  55823. /**
  55824. * Gets the load type
  55825. */
  55826. loadType: number;
  55827. /**
  55828. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55829. */
  55830. isInvalid: boolean;
  55831. /**
  55832. * Creates a new KhronosTextureContainer
  55833. * @param data contents of the KTX container file
  55834. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55835. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55836. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55837. */
  55838. constructor(
  55839. /** contents of the KTX container file */
  55840. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55841. /**
  55842. * Uploads KTX content to a Babylon Texture.
  55843. * It is assumed that the texture has already been created & is currently bound
  55844. * @hidden
  55845. */
  55846. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55847. private _upload2DCompressedLevels;
  55848. /**
  55849. * Checks if the given data starts with a KTX file identifier.
  55850. * @param data the data to check
  55851. * @returns true if the data is a KTX file or false otherwise
  55852. */
  55853. static IsValid(data: ArrayBufferView): boolean;
  55854. }
  55855. }
  55856. declare module BABYLON {
  55857. /**
  55858. * Class for loading KTX2 files
  55859. * !!! Experimental Extension Subject to Changes !!!
  55860. * @hidden
  55861. */
  55862. export class KhronosTextureContainer2 {
  55863. private static _ModulePromise;
  55864. private static _TranscodeFormat;
  55865. constructor(engine: ThinEngine);
  55866. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55867. private _determineTranscodeFormat;
  55868. /**
  55869. * Checks if the given data starts with a KTX2 file identifier.
  55870. * @param data the data to check
  55871. * @returns true if the data is a KTX2 file or false otherwise
  55872. */
  55873. static IsValid(data: ArrayBufferView): boolean;
  55874. }
  55875. }
  55876. declare module BABYLON {
  55877. /**
  55878. * Implementation of the KTX Texture Loader.
  55879. * @hidden
  55880. */
  55881. export class _KTXTextureLoader implements IInternalTextureLoader {
  55882. /**
  55883. * Defines wether the loader supports cascade loading the different faces.
  55884. */
  55885. readonly supportCascades: boolean;
  55886. /**
  55887. * This returns if the loader support the current file information.
  55888. * @param extension defines the file extension of the file being loaded
  55889. * @returns true if the loader can load the specified file
  55890. */
  55891. canLoad(extension: string): boolean;
  55892. /**
  55893. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55894. * @param data contains the texture data
  55895. * @param texture defines the BabylonJS internal texture
  55896. * @param createPolynomials will be true if polynomials have been requested
  55897. * @param onLoad defines the callback to trigger once the texture is ready
  55898. * @param onError defines the callback to trigger in case of error
  55899. */
  55900. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55901. /**
  55902. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55903. * @param data contains the texture data
  55904. * @param texture defines the BabylonJS internal texture
  55905. * @param callback defines the method to call once ready to upload
  55906. */
  55907. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55908. }
  55909. }
  55910. declare module BABYLON {
  55911. /** @hidden */
  55912. export var _forceSceneHelpersToBundle: boolean;
  55913. interface Scene {
  55914. /**
  55915. * Creates a default light for the scene.
  55916. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55917. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55918. */
  55919. createDefaultLight(replace?: boolean): void;
  55920. /**
  55921. * Creates a default camera for the scene.
  55922. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55923. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55924. * @param replace has default false, when true replaces the active camera in the scene
  55925. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55926. */
  55927. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55928. /**
  55929. * Creates a default camera and a default light.
  55930. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55931. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55932. * @param replace has the default false, when true replaces the active camera/light in the scene
  55933. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55934. */
  55935. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55936. /**
  55937. * Creates a new sky box
  55938. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55939. * @param environmentTexture defines the texture to use as environment texture
  55940. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55941. * @param scale defines the overall scale of the skybox
  55942. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55943. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55944. * @returns a new mesh holding the sky box
  55945. */
  55946. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55947. /**
  55948. * Creates a new environment
  55949. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55950. * @param options defines the options you can use to configure the environment
  55951. * @returns the new EnvironmentHelper
  55952. */
  55953. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55954. /**
  55955. * Creates a new VREXperienceHelper
  55956. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55957. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55958. * @returns a new VREXperienceHelper
  55959. */
  55960. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55961. /**
  55962. * Creates a new WebXRDefaultExperience
  55963. * @see http://doc.babylonjs.com/how_to/webxr
  55964. * @param options experience options
  55965. * @returns a promise for a new WebXRDefaultExperience
  55966. */
  55967. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55968. }
  55969. }
  55970. declare module BABYLON {
  55971. /**
  55972. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55973. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55974. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55975. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55976. */
  55977. export class VideoDome extends TransformNode {
  55978. /**
  55979. * Define the video source as a Monoscopic panoramic 360 video.
  55980. */
  55981. static readonly MODE_MONOSCOPIC: number;
  55982. /**
  55983. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55984. */
  55985. static readonly MODE_TOPBOTTOM: number;
  55986. /**
  55987. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55988. */
  55989. static readonly MODE_SIDEBYSIDE: number;
  55990. private _halfDome;
  55991. private _useDirectMapping;
  55992. /**
  55993. * The video texture being displayed on the sphere
  55994. */
  55995. protected _videoTexture: VideoTexture;
  55996. /**
  55997. * Gets the video texture being displayed on the sphere
  55998. */
  55999. get videoTexture(): VideoTexture;
  56000. /**
  56001. * The skybox material
  56002. */
  56003. protected _material: BackgroundMaterial;
  56004. /**
  56005. * The surface used for the skybox
  56006. */
  56007. protected _mesh: Mesh;
  56008. /**
  56009. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56010. */
  56011. private _halfDomeMask;
  56012. /**
  56013. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56014. * Also see the options.resolution property.
  56015. */
  56016. get fovMultiplier(): number;
  56017. set fovMultiplier(value: number);
  56018. private _videoMode;
  56019. /**
  56020. * Gets or set the current video mode for the video. It can be:
  56021. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56022. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56023. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56024. */
  56025. get videoMode(): number;
  56026. set videoMode(value: number);
  56027. /**
  56028. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56029. *
  56030. */
  56031. get halfDome(): boolean;
  56032. /**
  56033. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56034. */
  56035. set halfDome(enabled: boolean);
  56036. /**
  56037. * Oberserver used in Stereoscopic VR Mode.
  56038. */
  56039. private _onBeforeCameraRenderObserver;
  56040. /**
  56041. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56042. * @param name Element's name, child elements will append suffixes for their own names.
  56043. * @param urlsOrVideo defines the url(s) or the video element to use
  56044. * @param options An object containing optional or exposed sub element properties
  56045. */
  56046. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56047. resolution?: number;
  56048. clickToPlay?: boolean;
  56049. autoPlay?: boolean;
  56050. loop?: boolean;
  56051. size?: number;
  56052. poster?: string;
  56053. faceForward?: boolean;
  56054. useDirectMapping?: boolean;
  56055. halfDomeMode?: boolean;
  56056. }, scene: Scene);
  56057. private _changeVideoMode;
  56058. /**
  56059. * Releases resources associated with this node.
  56060. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56061. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56062. */
  56063. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56064. }
  56065. }
  56066. declare module BABYLON {
  56067. /**
  56068. * This class can be used to get instrumentation data from a Babylon engine
  56069. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56070. */
  56071. export class EngineInstrumentation implements IDisposable {
  56072. /**
  56073. * Define the instrumented engine.
  56074. */
  56075. engine: Engine;
  56076. private _captureGPUFrameTime;
  56077. private _gpuFrameTimeToken;
  56078. private _gpuFrameTime;
  56079. private _captureShaderCompilationTime;
  56080. private _shaderCompilationTime;
  56081. private _onBeginFrameObserver;
  56082. private _onEndFrameObserver;
  56083. private _onBeforeShaderCompilationObserver;
  56084. private _onAfterShaderCompilationObserver;
  56085. /**
  56086. * Gets the perf counter used for GPU frame time
  56087. */
  56088. get gpuFrameTimeCounter(): PerfCounter;
  56089. /**
  56090. * Gets the GPU frame time capture status
  56091. */
  56092. get captureGPUFrameTime(): boolean;
  56093. /**
  56094. * Enable or disable the GPU frame time capture
  56095. */
  56096. set captureGPUFrameTime(value: boolean);
  56097. /**
  56098. * Gets the perf counter used for shader compilation time
  56099. */
  56100. get shaderCompilationTimeCounter(): PerfCounter;
  56101. /**
  56102. * Gets the shader compilation time capture status
  56103. */
  56104. get captureShaderCompilationTime(): boolean;
  56105. /**
  56106. * Enable or disable the shader compilation time capture
  56107. */
  56108. set captureShaderCompilationTime(value: boolean);
  56109. /**
  56110. * Instantiates a new engine instrumentation.
  56111. * This class can be used to get instrumentation data from a Babylon engine
  56112. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56113. * @param engine Defines the engine to instrument
  56114. */
  56115. constructor(
  56116. /**
  56117. * Define the instrumented engine.
  56118. */
  56119. engine: Engine);
  56120. /**
  56121. * Dispose and release associated resources.
  56122. */
  56123. dispose(): void;
  56124. }
  56125. }
  56126. declare module BABYLON {
  56127. /**
  56128. * This class can be used to get instrumentation data from a Babylon engine
  56129. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56130. */
  56131. export class SceneInstrumentation implements IDisposable {
  56132. /**
  56133. * Defines the scene to instrument
  56134. */
  56135. scene: Scene;
  56136. private _captureActiveMeshesEvaluationTime;
  56137. private _activeMeshesEvaluationTime;
  56138. private _captureRenderTargetsRenderTime;
  56139. private _renderTargetsRenderTime;
  56140. private _captureFrameTime;
  56141. private _frameTime;
  56142. private _captureRenderTime;
  56143. private _renderTime;
  56144. private _captureInterFrameTime;
  56145. private _interFrameTime;
  56146. private _captureParticlesRenderTime;
  56147. private _particlesRenderTime;
  56148. private _captureSpritesRenderTime;
  56149. private _spritesRenderTime;
  56150. private _capturePhysicsTime;
  56151. private _physicsTime;
  56152. private _captureAnimationsTime;
  56153. private _animationsTime;
  56154. private _captureCameraRenderTime;
  56155. private _cameraRenderTime;
  56156. private _onBeforeActiveMeshesEvaluationObserver;
  56157. private _onAfterActiveMeshesEvaluationObserver;
  56158. private _onBeforeRenderTargetsRenderObserver;
  56159. private _onAfterRenderTargetsRenderObserver;
  56160. private _onAfterRenderObserver;
  56161. private _onBeforeDrawPhaseObserver;
  56162. private _onAfterDrawPhaseObserver;
  56163. private _onBeforeAnimationsObserver;
  56164. private _onBeforeParticlesRenderingObserver;
  56165. private _onAfterParticlesRenderingObserver;
  56166. private _onBeforeSpritesRenderingObserver;
  56167. private _onAfterSpritesRenderingObserver;
  56168. private _onBeforePhysicsObserver;
  56169. private _onAfterPhysicsObserver;
  56170. private _onAfterAnimationsObserver;
  56171. private _onBeforeCameraRenderObserver;
  56172. private _onAfterCameraRenderObserver;
  56173. /**
  56174. * Gets the perf counter used for active meshes evaluation time
  56175. */
  56176. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56177. /**
  56178. * Gets the active meshes evaluation time capture status
  56179. */
  56180. get captureActiveMeshesEvaluationTime(): boolean;
  56181. /**
  56182. * Enable or disable the active meshes evaluation time capture
  56183. */
  56184. set captureActiveMeshesEvaluationTime(value: boolean);
  56185. /**
  56186. * Gets the perf counter used for render targets render time
  56187. */
  56188. get renderTargetsRenderTimeCounter(): PerfCounter;
  56189. /**
  56190. * Gets the render targets render time capture status
  56191. */
  56192. get captureRenderTargetsRenderTime(): boolean;
  56193. /**
  56194. * Enable or disable the render targets render time capture
  56195. */
  56196. set captureRenderTargetsRenderTime(value: boolean);
  56197. /**
  56198. * Gets the perf counter used for particles render time
  56199. */
  56200. get particlesRenderTimeCounter(): PerfCounter;
  56201. /**
  56202. * Gets the particles render time capture status
  56203. */
  56204. get captureParticlesRenderTime(): boolean;
  56205. /**
  56206. * Enable or disable the particles render time capture
  56207. */
  56208. set captureParticlesRenderTime(value: boolean);
  56209. /**
  56210. * Gets the perf counter used for sprites render time
  56211. */
  56212. get spritesRenderTimeCounter(): PerfCounter;
  56213. /**
  56214. * Gets the sprites render time capture status
  56215. */
  56216. get captureSpritesRenderTime(): boolean;
  56217. /**
  56218. * Enable or disable the sprites render time capture
  56219. */
  56220. set captureSpritesRenderTime(value: boolean);
  56221. /**
  56222. * Gets the perf counter used for physics time
  56223. */
  56224. get physicsTimeCounter(): PerfCounter;
  56225. /**
  56226. * Gets the physics time capture status
  56227. */
  56228. get capturePhysicsTime(): boolean;
  56229. /**
  56230. * Enable or disable the physics time capture
  56231. */
  56232. set capturePhysicsTime(value: boolean);
  56233. /**
  56234. * Gets the perf counter used for animations time
  56235. */
  56236. get animationsTimeCounter(): PerfCounter;
  56237. /**
  56238. * Gets the animations time capture status
  56239. */
  56240. get captureAnimationsTime(): boolean;
  56241. /**
  56242. * Enable or disable the animations time capture
  56243. */
  56244. set captureAnimationsTime(value: boolean);
  56245. /**
  56246. * Gets the perf counter used for frame time capture
  56247. */
  56248. get frameTimeCounter(): PerfCounter;
  56249. /**
  56250. * Gets the frame time capture status
  56251. */
  56252. get captureFrameTime(): boolean;
  56253. /**
  56254. * Enable or disable the frame time capture
  56255. */
  56256. set captureFrameTime(value: boolean);
  56257. /**
  56258. * Gets the perf counter used for inter-frames time capture
  56259. */
  56260. get interFrameTimeCounter(): PerfCounter;
  56261. /**
  56262. * Gets the inter-frames time capture status
  56263. */
  56264. get captureInterFrameTime(): boolean;
  56265. /**
  56266. * Enable or disable the inter-frames time capture
  56267. */
  56268. set captureInterFrameTime(value: boolean);
  56269. /**
  56270. * Gets the perf counter used for render time capture
  56271. */
  56272. get renderTimeCounter(): PerfCounter;
  56273. /**
  56274. * Gets the render time capture status
  56275. */
  56276. get captureRenderTime(): boolean;
  56277. /**
  56278. * Enable or disable the render time capture
  56279. */
  56280. set captureRenderTime(value: boolean);
  56281. /**
  56282. * Gets the perf counter used for camera render time capture
  56283. */
  56284. get cameraRenderTimeCounter(): PerfCounter;
  56285. /**
  56286. * Gets the camera render time capture status
  56287. */
  56288. get captureCameraRenderTime(): boolean;
  56289. /**
  56290. * Enable or disable the camera render time capture
  56291. */
  56292. set captureCameraRenderTime(value: boolean);
  56293. /**
  56294. * Gets the perf counter used for draw calls
  56295. */
  56296. get drawCallsCounter(): PerfCounter;
  56297. /**
  56298. * Instantiates a new scene instrumentation.
  56299. * This class can be used to get instrumentation data from a Babylon engine
  56300. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56301. * @param scene Defines the scene to instrument
  56302. */
  56303. constructor(
  56304. /**
  56305. * Defines the scene to instrument
  56306. */
  56307. scene: Scene);
  56308. /**
  56309. * Dispose and release associated resources.
  56310. */
  56311. dispose(): void;
  56312. }
  56313. }
  56314. declare module BABYLON {
  56315. /** @hidden */
  56316. export var glowMapGenerationPixelShader: {
  56317. name: string;
  56318. shader: string;
  56319. };
  56320. }
  56321. declare module BABYLON {
  56322. /** @hidden */
  56323. export var glowMapGenerationVertexShader: {
  56324. name: string;
  56325. shader: string;
  56326. };
  56327. }
  56328. declare module BABYLON {
  56329. /**
  56330. * Effect layer options. This helps customizing the behaviour
  56331. * of the effect layer.
  56332. */
  56333. export interface IEffectLayerOptions {
  56334. /**
  56335. * Multiplication factor apply to the canvas size to compute the render target size
  56336. * used to generated the objects (the smaller the faster).
  56337. */
  56338. mainTextureRatio: number;
  56339. /**
  56340. * Enforces a fixed size texture to ensure effect stability across devices.
  56341. */
  56342. mainTextureFixedSize?: number;
  56343. /**
  56344. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56345. */
  56346. alphaBlendingMode: number;
  56347. /**
  56348. * The camera attached to the layer.
  56349. */
  56350. camera: Nullable<Camera>;
  56351. /**
  56352. * The rendering group to draw the layer in.
  56353. */
  56354. renderingGroupId: number;
  56355. }
  56356. /**
  56357. * The effect layer Helps adding post process effect blended with the main pass.
  56358. *
  56359. * This can be for instance use to generate glow or higlight effects on the scene.
  56360. *
  56361. * The effect layer class can not be used directly and is intented to inherited from to be
  56362. * customized per effects.
  56363. */
  56364. export abstract class EffectLayer {
  56365. private _vertexBuffers;
  56366. private _indexBuffer;
  56367. private _cachedDefines;
  56368. private _effectLayerMapGenerationEffect;
  56369. private _effectLayerOptions;
  56370. private _mergeEffect;
  56371. protected _scene: Scene;
  56372. protected _engine: Engine;
  56373. protected _maxSize: number;
  56374. protected _mainTextureDesiredSize: ISize;
  56375. protected _mainTexture: RenderTargetTexture;
  56376. protected _shouldRender: boolean;
  56377. protected _postProcesses: PostProcess[];
  56378. protected _textures: BaseTexture[];
  56379. protected _emissiveTextureAndColor: {
  56380. texture: Nullable<BaseTexture>;
  56381. color: Color4;
  56382. };
  56383. /**
  56384. * The name of the layer
  56385. */
  56386. name: string;
  56387. /**
  56388. * The clear color of the texture used to generate the glow map.
  56389. */
  56390. neutralColor: Color4;
  56391. /**
  56392. * Specifies whether the highlight layer is enabled or not.
  56393. */
  56394. isEnabled: boolean;
  56395. /**
  56396. * Gets the camera attached to the layer.
  56397. */
  56398. get camera(): Nullable<Camera>;
  56399. /**
  56400. * Gets the rendering group id the layer should render in.
  56401. */
  56402. get renderingGroupId(): number;
  56403. set renderingGroupId(renderingGroupId: number);
  56404. /**
  56405. * An event triggered when the effect layer has been disposed.
  56406. */
  56407. onDisposeObservable: Observable<EffectLayer>;
  56408. /**
  56409. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56410. */
  56411. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56412. /**
  56413. * An event triggered when the generated texture is being merged in the scene.
  56414. */
  56415. onBeforeComposeObservable: Observable<EffectLayer>;
  56416. /**
  56417. * An event triggered when the mesh is rendered into the effect render target.
  56418. */
  56419. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56420. /**
  56421. * An event triggered after the mesh has been rendered into the effect render target.
  56422. */
  56423. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56424. /**
  56425. * An event triggered when the generated texture has been merged in the scene.
  56426. */
  56427. onAfterComposeObservable: Observable<EffectLayer>;
  56428. /**
  56429. * An event triggered when the efffect layer changes its size.
  56430. */
  56431. onSizeChangedObservable: Observable<EffectLayer>;
  56432. /** @hidden */
  56433. static _SceneComponentInitialization: (scene: Scene) => void;
  56434. /**
  56435. * Instantiates a new effect Layer and references it in the scene.
  56436. * @param name The name of the layer
  56437. * @param scene The scene to use the layer in
  56438. */
  56439. constructor(
  56440. /** The Friendly of the effect in the scene */
  56441. name: string, scene: Scene);
  56442. /**
  56443. * Get the effect name of the layer.
  56444. * @return The effect name
  56445. */
  56446. abstract getEffectName(): string;
  56447. /**
  56448. * Checks for the readiness of the element composing the layer.
  56449. * @param subMesh the mesh to check for
  56450. * @param useInstances specify whether or not to use instances to render the mesh
  56451. * @return true if ready otherwise, false
  56452. */
  56453. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56454. /**
  56455. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56456. * @returns true if the effect requires stencil during the main canvas render pass.
  56457. */
  56458. abstract needStencil(): boolean;
  56459. /**
  56460. * Create the merge effect. This is the shader use to blit the information back
  56461. * to the main canvas at the end of the scene rendering.
  56462. * @returns The effect containing the shader used to merge the effect on the main canvas
  56463. */
  56464. protected abstract _createMergeEffect(): Effect;
  56465. /**
  56466. * Creates the render target textures and post processes used in the effect layer.
  56467. */
  56468. protected abstract _createTextureAndPostProcesses(): void;
  56469. /**
  56470. * Implementation specific of rendering the generating effect on the main canvas.
  56471. * @param effect The effect used to render through
  56472. */
  56473. protected abstract _internalRender(effect: Effect): void;
  56474. /**
  56475. * Sets the required values for both the emissive texture and and the main color.
  56476. */
  56477. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56478. /**
  56479. * Free any resources and references associated to a mesh.
  56480. * Internal use
  56481. * @param mesh The mesh to free.
  56482. */
  56483. abstract _disposeMesh(mesh: Mesh): void;
  56484. /**
  56485. * Serializes this layer (Glow or Highlight for example)
  56486. * @returns a serialized layer object
  56487. */
  56488. abstract serialize?(): any;
  56489. /**
  56490. * Initializes the effect layer with the required options.
  56491. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56492. */
  56493. protected _init(options: Partial<IEffectLayerOptions>): void;
  56494. /**
  56495. * Generates the index buffer of the full screen quad blending to the main canvas.
  56496. */
  56497. private _generateIndexBuffer;
  56498. /**
  56499. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56500. */
  56501. private _generateVertexBuffer;
  56502. /**
  56503. * Sets the main texture desired size which is the closest power of two
  56504. * of the engine canvas size.
  56505. */
  56506. private _setMainTextureSize;
  56507. /**
  56508. * Creates the main texture for the effect layer.
  56509. */
  56510. protected _createMainTexture(): void;
  56511. /**
  56512. * Adds specific effects defines.
  56513. * @param defines The defines to add specifics to.
  56514. */
  56515. protected _addCustomEffectDefines(defines: string[]): void;
  56516. /**
  56517. * Checks for the readiness of the element composing the layer.
  56518. * @param subMesh the mesh to check for
  56519. * @param useInstances specify whether or not to use instances to render the mesh
  56520. * @param emissiveTexture the associated emissive texture used to generate the glow
  56521. * @return true if ready otherwise, false
  56522. */
  56523. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56524. /**
  56525. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56526. */
  56527. render(): void;
  56528. /**
  56529. * Determine if a given mesh will be used in the current effect.
  56530. * @param mesh mesh to test
  56531. * @returns true if the mesh will be used
  56532. */
  56533. hasMesh(mesh: AbstractMesh): boolean;
  56534. /**
  56535. * Returns true if the layer contains information to display, otherwise false.
  56536. * @returns true if the glow layer should be rendered
  56537. */
  56538. shouldRender(): boolean;
  56539. /**
  56540. * Returns true if the mesh should render, otherwise false.
  56541. * @param mesh The mesh to render
  56542. * @returns true if it should render otherwise false
  56543. */
  56544. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56545. /**
  56546. * Returns true if the mesh can be rendered, otherwise false.
  56547. * @param mesh The mesh to render
  56548. * @param material The material used on the mesh
  56549. * @returns true if it can be rendered otherwise false
  56550. */
  56551. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56552. /**
  56553. * Returns true if the mesh should render, otherwise false.
  56554. * @param mesh The mesh to render
  56555. * @returns true if it should render otherwise false
  56556. */
  56557. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56558. /**
  56559. * Renders the submesh passed in parameter to the generation map.
  56560. */
  56561. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56562. /**
  56563. * Defines whether the current material of the mesh should be use to render the effect.
  56564. * @param mesh defines the current mesh to render
  56565. */
  56566. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56567. /**
  56568. * Rebuild the required buffers.
  56569. * @hidden Internal use only.
  56570. */
  56571. _rebuild(): void;
  56572. /**
  56573. * Dispose only the render target textures and post process.
  56574. */
  56575. private _disposeTextureAndPostProcesses;
  56576. /**
  56577. * Dispose the highlight layer and free resources.
  56578. */
  56579. dispose(): void;
  56580. /**
  56581. * Gets the class name of the effect layer
  56582. * @returns the string with the class name of the effect layer
  56583. */
  56584. getClassName(): string;
  56585. /**
  56586. * Creates an effect layer from parsed effect layer data
  56587. * @param parsedEffectLayer defines effect layer data
  56588. * @param scene defines the current scene
  56589. * @param rootUrl defines the root URL containing the effect layer information
  56590. * @returns a parsed effect Layer
  56591. */
  56592. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56593. }
  56594. }
  56595. declare module BABYLON {
  56596. interface AbstractScene {
  56597. /**
  56598. * The list of effect layers (highlights/glow) added to the scene
  56599. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56600. * @see http://doc.babylonjs.com/how_to/glow_layer
  56601. */
  56602. effectLayers: Array<EffectLayer>;
  56603. /**
  56604. * Removes the given effect layer from this scene.
  56605. * @param toRemove defines the effect layer to remove
  56606. * @returns the index of the removed effect layer
  56607. */
  56608. removeEffectLayer(toRemove: EffectLayer): number;
  56609. /**
  56610. * Adds the given effect layer to this scene
  56611. * @param newEffectLayer defines the effect layer to add
  56612. */
  56613. addEffectLayer(newEffectLayer: EffectLayer): void;
  56614. }
  56615. /**
  56616. * Defines the layer scene component responsible to manage any effect layers
  56617. * in a given scene.
  56618. */
  56619. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56620. /**
  56621. * The component name helpfull to identify the component in the list of scene components.
  56622. */
  56623. readonly name: string;
  56624. /**
  56625. * The scene the component belongs to.
  56626. */
  56627. scene: Scene;
  56628. private _engine;
  56629. private _renderEffects;
  56630. private _needStencil;
  56631. private _previousStencilState;
  56632. /**
  56633. * Creates a new instance of the component for the given scene
  56634. * @param scene Defines the scene to register the component in
  56635. */
  56636. constructor(scene: Scene);
  56637. /**
  56638. * Registers the component in a given scene
  56639. */
  56640. register(): void;
  56641. /**
  56642. * Rebuilds the elements related to this component in case of
  56643. * context lost for instance.
  56644. */
  56645. rebuild(): void;
  56646. /**
  56647. * Serializes the component data to the specified json object
  56648. * @param serializationObject The object to serialize to
  56649. */
  56650. serialize(serializationObject: any): void;
  56651. /**
  56652. * Adds all the elements from the container to the scene
  56653. * @param container the container holding the elements
  56654. */
  56655. addFromContainer(container: AbstractScene): void;
  56656. /**
  56657. * Removes all the elements in the container from the scene
  56658. * @param container contains the elements to remove
  56659. * @param dispose if the removed element should be disposed (default: false)
  56660. */
  56661. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56662. /**
  56663. * Disposes the component and the associated ressources.
  56664. */
  56665. dispose(): void;
  56666. private _isReadyForMesh;
  56667. private _renderMainTexture;
  56668. private _setStencil;
  56669. private _setStencilBack;
  56670. private _draw;
  56671. private _drawCamera;
  56672. private _drawRenderingGroup;
  56673. }
  56674. }
  56675. declare module BABYLON {
  56676. /** @hidden */
  56677. export var glowMapMergePixelShader: {
  56678. name: string;
  56679. shader: string;
  56680. };
  56681. }
  56682. declare module BABYLON {
  56683. /** @hidden */
  56684. export var glowMapMergeVertexShader: {
  56685. name: string;
  56686. shader: string;
  56687. };
  56688. }
  56689. declare module BABYLON {
  56690. interface AbstractScene {
  56691. /**
  56692. * Return a the first highlight layer of the scene with a given name.
  56693. * @param name The name of the highlight layer to look for.
  56694. * @return The highlight layer if found otherwise null.
  56695. */
  56696. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56697. }
  56698. /**
  56699. * Glow layer options. This helps customizing the behaviour
  56700. * of the glow layer.
  56701. */
  56702. export interface IGlowLayerOptions {
  56703. /**
  56704. * Multiplication factor apply to the canvas size to compute the render target size
  56705. * used to generated the glowing objects (the smaller the faster).
  56706. */
  56707. mainTextureRatio: number;
  56708. /**
  56709. * Enforces a fixed size texture to ensure resize independant blur.
  56710. */
  56711. mainTextureFixedSize?: number;
  56712. /**
  56713. * How big is the kernel of the blur texture.
  56714. */
  56715. blurKernelSize: number;
  56716. /**
  56717. * The camera attached to the layer.
  56718. */
  56719. camera: Nullable<Camera>;
  56720. /**
  56721. * Enable MSAA by chosing the number of samples.
  56722. */
  56723. mainTextureSamples?: number;
  56724. /**
  56725. * The rendering group to draw the layer in.
  56726. */
  56727. renderingGroupId: number;
  56728. }
  56729. /**
  56730. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56731. *
  56732. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56733. *
  56734. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56735. */
  56736. export class GlowLayer extends EffectLayer {
  56737. /**
  56738. * Effect Name of the layer.
  56739. */
  56740. static readonly EffectName: string;
  56741. /**
  56742. * The default blur kernel size used for the glow.
  56743. */
  56744. static DefaultBlurKernelSize: number;
  56745. /**
  56746. * The default texture size ratio used for the glow.
  56747. */
  56748. static DefaultTextureRatio: number;
  56749. /**
  56750. * Sets the kernel size of the blur.
  56751. */
  56752. set blurKernelSize(value: number);
  56753. /**
  56754. * Gets the kernel size of the blur.
  56755. */
  56756. get blurKernelSize(): number;
  56757. /**
  56758. * Sets the glow intensity.
  56759. */
  56760. set intensity(value: number);
  56761. /**
  56762. * Gets the glow intensity.
  56763. */
  56764. get intensity(): number;
  56765. private _options;
  56766. private _intensity;
  56767. private _horizontalBlurPostprocess1;
  56768. private _verticalBlurPostprocess1;
  56769. private _horizontalBlurPostprocess2;
  56770. private _verticalBlurPostprocess2;
  56771. private _blurTexture1;
  56772. private _blurTexture2;
  56773. private _postProcesses1;
  56774. private _postProcesses2;
  56775. private _includedOnlyMeshes;
  56776. private _excludedMeshes;
  56777. private _meshesUsingTheirOwnMaterials;
  56778. /**
  56779. * Callback used to let the user override the color selection on a per mesh basis
  56780. */
  56781. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56782. /**
  56783. * Callback used to let the user override the texture selection on a per mesh basis
  56784. */
  56785. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56786. /**
  56787. * Instantiates a new glow Layer and references it to the scene.
  56788. * @param name The name of the layer
  56789. * @param scene The scene to use the layer in
  56790. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56791. */
  56792. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56793. /**
  56794. * Get the effect name of the layer.
  56795. * @return The effect name
  56796. */
  56797. getEffectName(): string;
  56798. /**
  56799. * Create the merge effect. This is the shader use to blit the information back
  56800. * to the main canvas at the end of the scene rendering.
  56801. */
  56802. protected _createMergeEffect(): Effect;
  56803. /**
  56804. * Creates the render target textures and post processes used in the glow layer.
  56805. */
  56806. protected _createTextureAndPostProcesses(): void;
  56807. /**
  56808. * Checks for the readiness of the element composing the layer.
  56809. * @param subMesh the mesh to check for
  56810. * @param useInstances specify wether or not to use instances to render the mesh
  56811. * @param emissiveTexture the associated emissive texture used to generate the glow
  56812. * @return true if ready otherwise, false
  56813. */
  56814. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56815. /**
  56816. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56817. */
  56818. needStencil(): boolean;
  56819. /**
  56820. * Returns true if the mesh can be rendered, otherwise false.
  56821. * @param mesh The mesh to render
  56822. * @param material The material used on the mesh
  56823. * @returns true if it can be rendered otherwise false
  56824. */
  56825. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56826. /**
  56827. * Implementation specific of rendering the generating effect on the main canvas.
  56828. * @param effect The effect used to render through
  56829. */
  56830. protected _internalRender(effect: Effect): void;
  56831. /**
  56832. * Sets the required values for both the emissive texture and and the main color.
  56833. */
  56834. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56835. /**
  56836. * Returns true if the mesh should render, otherwise false.
  56837. * @param mesh The mesh to render
  56838. * @returns true if it should render otherwise false
  56839. */
  56840. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56841. /**
  56842. * Adds specific effects defines.
  56843. * @param defines The defines to add specifics to.
  56844. */
  56845. protected _addCustomEffectDefines(defines: string[]): void;
  56846. /**
  56847. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56848. * @param mesh The mesh to exclude from the glow layer
  56849. */
  56850. addExcludedMesh(mesh: Mesh): void;
  56851. /**
  56852. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56853. * @param mesh The mesh to remove
  56854. */
  56855. removeExcludedMesh(mesh: Mesh): void;
  56856. /**
  56857. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56858. * @param mesh The mesh to include in the glow layer
  56859. */
  56860. addIncludedOnlyMesh(mesh: Mesh): void;
  56861. /**
  56862. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56863. * @param mesh The mesh to remove
  56864. */
  56865. removeIncludedOnlyMesh(mesh: Mesh): void;
  56866. /**
  56867. * Determine if a given mesh will be used in the glow layer
  56868. * @param mesh The mesh to test
  56869. * @returns true if the mesh will be highlighted by the current glow layer
  56870. */
  56871. hasMesh(mesh: AbstractMesh): boolean;
  56872. /**
  56873. * Defines whether the current material of the mesh should be use to render the effect.
  56874. * @param mesh defines the current mesh to render
  56875. */
  56876. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56877. /**
  56878. * Add a mesh to be rendered through its own material and not with emissive only.
  56879. * @param mesh The mesh for which we need to use its material
  56880. */
  56881. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56882. /**
  56883. * Remove a mesh from being rendered through its own material and not with emissive only.
  56884. * @param mesh The mesh for which we need to not use its material
  56885. */
  56886. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56887. /**
  56888. * Free any resources and references associated to a mesh.
  56889. * Internal use
  56890. * @param mesh The mesh to free.
  56891. * @hidden
  56892. */
  56893. _disposeMesh(mesh: Mesh): void;
  56894. /**
  56895. * Gets the class name of the effect layer
  56896. * @returns the string with the class name of the effect layer
  56897. */
  56898. getClassName(): string;
  56899. /**
  56900. * Serializes this glow layer
  56901. * @returns a serialized glow layer object
  56902. */
  56903. serialize(): any;
  56904. /**
  56905. * Creates a Glow Layer from parsed glow layer data
  56906. * @param parsedGlowLayer defines glow layer data
  56907. * @param scene defines the current scene
  56908. * @param rootUrl defines the root URL containing the glow layer information
  56909. * @returns a parsed Glow Layer
  56910. */
  56911. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56912. }
  56913. }
  56914. declare module BABYLON {
  56915. /** @hidden */
  56916. export var glowBlurPostProcessPixelShader: {
  56917. name: string;
  56918. shader: string;
  56919. };
  56920. }
  56921. declare module BABYLON {
  56922. interface AbstractScene {
  56923. /**
  56924. * Return a the first highlight layer of the scene with a given name.
  56925. * @param name The name of the highlight layer to look for.
  56926. * @return The highlight layer if found otherwise null.
  56927. */
  56928. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56929. }
  56930. /**
  56931. * Highlight layer options. This helps customizing the behaviour
  56932. * of the highlight layer.
  56933. */
  56934. export interface IHighlightLayerOptions {
  56935. /**
  56936. * Multiplication factor apply to the canvas size to compute the render target size
  56937. * used to generated the glowing objects (the smaller the faster).
  56938. */
  56939. mainTextureRatio: number;
  56940. /**
  56941. * Enforces a fixed size texture to ensure resize independant blur.
  56942. */
  56943. mainTextureFixedSize?: number;
  56944. /**
  56945. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56946. * of the picture to blur (the smaller the faster).
  56947. */
  56948. blurTextureSizeRatio: number;
  56949. /**
  56950. * How big in texel of the blur texture is the vertical blur.
  56951. */
  56952. blurVerticalSize: number;
  56953. /**
  56954. * How big in texel of the blur texture is the horizontal blur.
  56955. */
  56956. blurHorizontalSize: number;
  56957. /**
  56958. * Alpha blending mode used to apply the blur. Default is combine.
  56959. */
  56960. alphaBlendingMode: number;
  56961. /**
  56962. * The camera attached to the layer.
  56963. */
  56964. camera: Nullable<Camera>;
  56965. /**
  56966. * Should we display highlight as a solid stroke?
  56967. */
  56968. isStroke?: boolean;
  56969. /**
  56970. * The rendering group to draw the layer in.
  56971. */
  56972. renderingGroupId: number;
  56973. }
  56974. /**
  56975. * The highlight layer Helps adding a glow effect around a mesh.
  56976. *
  56977. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56978. * glowy meshes to your scene.
  56979. *
  56980. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56981. */
  56982. export class HighlightLayer extends EffectLayer {
  56983. name: string;
  56984. /**
  56985. * Effect Name of the highlight layer.
  56986. */
  56987. static readonly EffectName: string;
  56988. /**
  56989. * The neutral color used during the preparation of the glow effect.
  56990. * This is black by default as the blend operation is a blend operation.
  56991. */
  56992. static NeutralColor: Color4;
  56993. /**
  56994. * Stencil value used for glowing meshes.
  56995. */
  56996. static GlowingMeshStencilReference: number;
  56997. /**
  56998. * Stencil value used for the other meshes in the scene.
  56999. */
  57000. static NormalMeshStencilReference: number;
  57001. /**
  57002. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57003. */
  57004. innerGlow: boolean;
  57005. /**
  57006. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57007. */
  57008. outerGlow: boolean;
  57009. /**
  57010. * Specifies the horizontal size of the blur.
  57011. */
  57012. set blurHorizontalSize(value: number);
  57013. /**
  57014. * Specifies the vertical size of the blur.
  57015. */
  57016. set blurVerticalSize(value: number);
  57017. /**
  57018. * Gets the horizontal size of the blur.
  57019. */
  57020. get blurHorizontalSize(): number;
  57021. /**
  57022. * Gets the vertical size of the blur.
  57023. */
  57024. get blurVerticalSize(): number;
  57025. /**
  57026. * An event triggered when the highlight layer is being blurred.
  57027. */
  57028. onBeforeBlurObservable: Observable<HighlightLayer>;
  57029. /**
  57030. * An event triggered when the highlight layer has been blurred.
  57031. */
  57032. onAfterBlurObservable: Observable<HighlightLayer>;
  57033. private _instanceGlowingMeshStencilReference;
  57034. private _options;
  57035. private _downSamplePostprocess;
  57036. private _horizontalBlurPostprocess;
  57037. private _verticalBlurPostprocess;
  57038. private _blurTexture;
  57039. private _meshes;
  57040. private _excludedMeshes;
  57041. /**
  57042. * Instantiates a new highlight Layer and references it to the scene..
  57043. * @param name The name of the layer
  57044. * @param scene The scene to use the layer in
  57045. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57046. */
  57047. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57048. /**
  57049. * Get the effect name of the layer.
  57050. * @return The effect name
  57051. */
  57052. getEffectName(): string;
  57053. /**
  57054. * Create the merge effect. This is the shader use to blit the information back
  57055. * to the main canvas at the end of the scene rendering.
  57056. */
  57057. protected _createMergeEffect(): Effect;
  57058. /**
  57059. * Creates the render target textures and post processes used in the highlight layer.
  57060. */
  57061. protected _createTextureAndPostProcesses(): void;
  57062. /**
  57063. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57064. */
  57065. needStencil(): boolean;
  57066. /**
  57067. * Checks for the readiness of the element composing the layer.
  57068. * @param subMesh the mesh to check for
  57069. * @param useInstances specify wether or not to use instances to render the mesh
  57070. * @param emissiveTexture the associated emissive texture used to generate the glow
  57071. * @return true if ready otherwise, false
  57072. */
  57073. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57074. /**
  57075. * Implementation specific of rendering the generating effect on the main canvas.
  57076. * @param effect The effect used to render through
  57077. */
  57078. protected _internalRender(effect: Effect): void;
  57079. /**
  57080. * Returns true if the layer contains information to display, otherwise false.
  57081. */
  57082. shouldRender(): boolean;
  57083. /**
  57084. * Returns true if the mesh should render, otherwise false.
  57085. * @param mesh The mesh to render
  57086. * @returns true if it should render otherwise false
  57087. */
  57088. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57089. /**
  57090. * Adds specific effects defines.
  57091. * @param defines The defines to add specifics to.
  57092. */
  57093. protected _addCustomEffectDefines(defines: string[]): void;
  57094. /**
  57095. * Sets the required values for both the emissive texture and and the main color.
  57096. */
  57097. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57098. /**
  57099. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57100. * @param mesh The mesh to exclude from the highlight layer
  57101. */
  57102. addExcludedMesh(mesh: Mesh): void;
  57103. /**
  57104. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57105. * @param mesh The mesh to highlight
  57106. */
  57107. removeExcludedMesh(mesh: Mesh): void;
  57108. /**
  57109. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57110. * @param mesh mesh to test
  57111. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57112. */
  57113. hasMesh(mesh: AbstractMesh): boolean;
  57114. /**
  57115. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57116. * @param mesh The mesh to highlight
  57117. * @param color The color of the highlight
  57118. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57119. */
  57120. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57121. /**
  57122. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57123. * @param mesh The mesh to highlight
  57124. */
  57125. removeMesh(mesh: Mesh): void;
  57126. /**
  57127. * Remove all the meshes currently referenced in the highlight layer
  57128. */
  57129. removeAllMeshes(): void;
  57130. /**
  57131. * Force the stencil to the normal expected value for none glowing parts
  57132. */
  57133. private _defaultStencilReference;
  57134. /**
  57135. * Free any resources and references associated to a mesh.
  57136. * Internal use
  57137. * @param mesh The mesh to free.
  57138. * @hidden
  57139. */
  57140. _disposeMesh(mesh: Mesh): void;
  57141. /**
  57142. * Dispose the highlight layer and free resources.
  57143. */
  57144. dispose(): void;
  57145. /**
  57146. * Gets the class name of the effect layer
  57147. * @returns the string with the class name of the effect layer
  57148. */
  57149. getClassName(): string;
  57150. /**
  57151. * Serializes this Highlight layer
  57152. * @returns a serialized Highlight layer object
  57153. */
  57154. serialize(): any;
  57155. /**
  57156. * Creates a Highlight layer from parsed Highlight layer data
  57157. * @param parsedHightlightLayer defines the Highlight layer data
  57158. * @param scene defines the current scene
  57159. * @param rootUrl defines the root URL containing the Highlight layer information
  57160. * @returns a parsed Highlight layer
  57161. */
  57162. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57163. }
  57164. }
  57165. declare module BABYLON {
  57166. interface AbstractScene {
  57167. /**
  57168. * The list of layers (background and foreground) of the scene
  57169. */
  57170. layers: Array<Layer>;
  57171. }
  57172. /**
  57173. * Defines the layer scene component responsible to manage any layers
  57174. * in a given scene.
  57175. */
  57176. export class LayerSceneComponent implements ISceneComponent {
  57177. /**
  57178. * The component name helpfull to identify the component in the list of scene components.
  57179. */
  57180. readonly name: string;
  57181. /**
  57182. * The scene the component belongs to.
  57183. */
  57184. scene: Scene;
  57185. private _engine;
  57186. /**
  57187. * Creates a new instance of the component for the given scene
  57188. * @param scene Defines the scene to register the component in
  57189. */
  57190. constructor(scene: Scene);
  57191. /**
  57192. * Registers the component in a given scene
  57193. */
  57194. register(): void;
  57195. /**
  57196. * Rebuilds the elements related to this component in case of
  57197. * context lost for instance.
  57198. */
  57199. rebuild(): void;
  57200. /**
  57201. * Disposes the component and the associated ressources.
  57202. */
  57203. dispose(): void;
  57204. private _draw;
  57205. private _drawCameraPredicate;
  57206. private _drawCameraBackground;
  57207. private _drawCameraForeground;
  57208. private _drawRenderTargetPredicate;
  57209. private _drawRenderTargetBackground;
  57210. private _drawRenderTargetForeground;
  57211. /**
  57212. * Adds all the elements from the container to the scene
  57213. * @param container the container holding the elements
  57214. */
  57215. addFromContainer(container: AbstractScene): void;
  57216. /**
  57217. * Removes all the elements in the container from the scene
  57218. * @param container contains the elements to remove
  57219. * @param dispose if the removed element should be disposed (default: false)
  57220. */
  57221. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57222. }
  57223. }
  57224. declare module BABYLON {
  57225. /** @hidden */
  57226. export var layerPixelShader: {
  57227. name: string;
  57228. shader: string;
  57229. };
  57230. }
  57231. declare module BABYLON {
  57232. /** @hidden */
  57233. export var layerVertexShader: {
  57234. name: string;
  57235. shader: string;
  57236. };
  57237. }
  57238. declare module BABYLON {
  57239. /**
  57240. * This represents a full screen 2d layer.
  57241. * This can be useful to display a picture in the background of your scene for instance.
  57242. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57243. */
  57244. export class Layer {
  57245. /**
  57246. * Define the name of the layer.
  57247. */
  57248. name: string;
  57249. /**
  57250. * Define the texture the layer should display.
  57251. */
  57252. texture: Nullable<Texture>;
  57253. /**
  57254. * Is the layer in background or foreground.
  57255. */
  57256. isBackground: boolean;
  57257. /**
  57258. * Define the color of the layer (instead of texture).
  57259. */
  57260. color: Color4;
  57261. /**
  57262. * Define the scale of the layer in order to zoom in out of the texture.
  57263. */
  57264. scale: Vector2;
  57265. /**
  57266. * Define an offset for the layer in order to shift the texture.
  57267. */
  57268. offset: Vector2;
  57269. /**
  57270. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57271. */
  57272. alphaBlendingMode: number;
  57273. /**
  57274. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57275. * Alpha test will not mix with the background color in case of transparency.
  57276. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57277. */
  57278. alphaTest: boolean;
  57279. /**
  57280. * Define a mask to restrict the layer to only some of the scene cameras.
  57281. */
  57282. layerMask: number;
  57283. /**
  57284. * Define the list of render target the layer is visible into.
  57285. */
  57286. renderTargetTextures: RenderTargetTexture[];
  57287. /**
  57288. * Define if the layer is only used in renderTarget or if it also
  57289. * renders in the main frame buffer of the canvas.
  57290. */
  57291. renderOnlyInRenderTargetTextures: boolean;
  57292. private _scene;
  57293. private _vertexBuffers;
  57294. private _indexBuffer;
  57295. private _effect;
  57296. private _previousDefines;
  57297. /**
  57298. * An event triggered when the layer is disposed.
  57299. */
  57300. onDisposeObservable: Observable<Layer>;
  57301. private _onDisposeObserver;
  57302. /**
  57303. * Back compatibility with callback before the onDisposeObservable existed.
  57304. * The set callback will be triggered when the layer has been disposed.
  57305. */
  57306. set onDispose(callback: () => void);
  57307. /**
  57308. * An event triggered before rendering the scene
  57309. */
  57310. onBeforeRenderObservable: Observable<Layer>;
  57311. private _onBeforeRenderObserver;
  57312. /**
  57313. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57314. * The set callback will be triggered just before rendering the layer.
  57315. */
  57316. set onBeforeRender(callback: () => void);
  57317. /**
  57318. * An event triggered after rendering the scene
  57319. */
  57320. onAfterRenderObservable: Observable<Layer>;
  57321. private _onAfterRenderObserver;
  57322. /**
  57323. * Back compatibility with callback before the onAfterRenderObservable existed.
  57324. * The set callback will be triggered just after rendering the layer.
  57325. */
  57326. set onAfterRender(callback: () => void);
  57327. /**
  57328. * Instantiates a new layer.
  57329. * This represents a full screen 2d layer.
  57330. * This can be useful to display a picture in the background of your scene for instance.
  57331. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57332. * @param name Define the name of the layer in the scene
  57333. * @param imgUrl Define the url of the texture to display in the layer
  57334. * @param scene Define the scene the layer belongs to
  57335. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57336. * @param color Defines a color for the layer
  57337. */
  57338. constructor(
  57339. /**
  57340. * Define the name of the layer.
  57341. */
  57342. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57343. private _createIndexBuffer;
  57344. /** @hidden */
  57345. _rebuild(): void;
  57346. /**
  57347. * Renders the layer in the scene.
  57348. */
  57349. render(): void;
  57350. /**
  57351. * Disposes and releases the associated ressources.
  57352. */
  57353. dispose(): void;
  57354. }
  57355. }
  57356. declare module BABYLON {
  57357. /** @hidden */
  57358. export var lensFlarePixelShader: {
  57359. name: string;
  57360. shader: string;
  57361. };
  57362. }
  57363. declare module BABYLON {
  57364. /** @hidden */
  57365. export var lensFlareVertexShader: {
  57366. name: string;
  57367. shader: string;
  57368. };
  57369. }
  57370. declare module BABYLON {
  57371. /**
  57372. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57373. * It is usually composed of several `lensFlare`.
  57374. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57375. */
  57376. export class LensFlareSystem {
  57377. /**
  57378. * Define the name of the lens flare system
  57379. */
  57380. name: string;
  57381. /**
  57382. * List of lens flares used in this system.
  57383. */
  57384. lensFlares: LensFlare[];
  57385. /**
  57386. * Define a limit from the border the lens flare can be visible.
  57387. */
  57388. borderLimit: number;
  57389. /**
  57390. * Define a viewport border we do not want to see the lens flare in.
  57391. */
  57392. viewportBorder: number;
  57393. /**
  57394. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57395. */
  57396. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57397. /**
  57398. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57399. */
  57400. layerMask: number;
  57401. /**
  57402. * Define the id of the lens flare system in the scene.
  57403. * (equal to name by default)
  57404. */
  57405. id: string;
  57406. private _scene;
  57407. private _emitter;
  57408. private _vertexBuffers;
  57409. private _indexBuffer;
  57410. private _effect;
  57411. private _positionX;
  57412. private _positionY;
  57413. private _isEnabled;
  57414. /** @hidden */
  57415. static _SceneComponentInitialization: (scene: Scene) => void;
  57416. /**
  57417. * Instantiates a lens flare system.
  57418. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57419. * It is usually composed of several `lensFlare`.
  57420. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57421. * @param name Define the name of the lens flare system in the scene
  57422. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57423. * @param scene Define the scene the lens flare system belongs to
  57424. */
  57425. constructor(
  57426. /**
  57427. * Define the name of the lens flare system
  57428. */
  57429. name: string, emitter: any, scene: Scene);
  57430. /**
  57431. * Define if the lens flare system is enabled.
  57432. */
  57433. get isEnabled(): boolean;
  57434. set isEnabled(value: boolean);
  57435. /**
  57436. * Get the scene the effects belongs to.
  57437. * @returns the scene holding the lens flare system
  57438. */
  57439. getScene(): Scene;
  57440. /**
  57441. * Get the emitter of the lens flare system.
  57442. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57443. * @returns the emitter of the lens flare system
  57444. */
  57445. getEmitter(): any;
  57446. /**
  57447. * Set the emitter of the lens flare system.
  57448. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57449. * @param newEmitter Define the new emitter of the system
  57450. */
  57451. setEmitter(newEmitter: any): void;
  57452. /**
  57453. * Get the lens flare system emitter position.
  57454. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57455. * @returns the position
  57456. */
  57457. getEmitterPosition(): Vector3;
  57458. /**
  57459. * @hidden
  57460. */
  57461. computeEffectivePosition(globalViewport: Viewport): boolean;
  57462. /** @hidden */
  57463. _isVisible(): boolean;
  57464. /**
  57465. * @hidden
  57466. */
  57467. render(): boolean;
  57468. /**
  57469. * Dispose and release the lens flare with its associated resources.
  57470. */
  57471. dispose(): void;
  57472. /**
  57473. * Parse a lens flare system from a JSON repressentation
  57474. * @param parsedLensFlareSystem Define the JSON to parse
  57475. * @param scene Define the scene the parsed system should be instantiated in
  57476. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57477. * @returns the parsed system
  57478. */
  57479. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57480. /**
  57481. * Serialize the current Lens Flare System into a JSON representation.
  57482. * @returns the serialized JSON
  57483. */
  57484. serialize(): any;
  57485. }
  57486. }
  57487. declare module BABYLON {
  57488. /**
  57489. * This represents one of the lens effect in a `lensFlareSystem`.
  57490. * It controls one of the indiviual texture used in the effect.
  57491. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57492. */
  57493. export class LensFlare {
  57494. /**
  57495. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57496. */
  57497. size: number;
  57498. /**
  57499. * 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.
  57500. */
  57501. position: number;
  57502. /**
  57503. * Define the lens color.
  57504. */
  57505. color: Color3;
  57506. /**
  57507. * Define the lens texture.
  57508. */
  57509. texture: Nullable<Texture>;
  57510. /**
  57511. * Define the alpha mode to render this particular lens.
  57512. */
  57513. alphaMode: number;
  57514. private _system;
  57515. /**
  57516. * Creates a new Lens Flare.
  57517. * This represents one of the lens effect in a `lensFlareSystem`.
  57518. * It controls one of the indiviual texture used in the effect.
  57519. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57520. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57521. * @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.
  57522. * @param color Define the lens color
  57523. * @param imgUrl Define the lens texture url
  57524. * @param system Define the `lensFlareSystem` this flare is part of
  57525. * @returns The newly created Lens Flare
  57526. */
  57527. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57528. /**
  57529. * Instantiates a new Lens Flare.
  57530. * This represents one of the lens effect in a `lensFlareSystem`.
  57531. * It controls one of the indiviual texture used in the effect.
  57532. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57533. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57534. * @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.
  57535. * @param color Define the lens color
  57536. * @param imgUrl Define the lens texture url
  57537. * @param system Define the `lensFlareSystem` this flare is part of
  57538. */
  57539. constructor(
  57540. /**
  57541. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57542. */
  57543. size: number,
  57544. /**
  57545. * 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.
  57546. */
  57547. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57548. /**
  57549. * Dispose and release the lens flare with its associated resources.
  57550. */
  57551. dispose(): void;
  57552. }
  57553. }
  57554. declare module BABYLON {
  57555. interface AbstractScene {
  57556. /**
  57557. * The list of lens flare system added to the scene
  57558. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57559. */
  57560. lensFlareSystems: Array<LensFlareSystem>;
  57561. /**
  57562. * Removes the given lens flare system from this scene.
  57563. * @param toRemove The lens flare system to remove
  57564. * @returns The index of the removed lens flare system
  57565. */
  57566. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57567. /**
  57568. * Adds the given lens flare system to this scene
  57569. * @param newLensFlareSystem The lens flare system to add
  57570. */
  57571. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57572. /**
  57573. * Gets a lens flare system using its name
  57574. * @param name defines the name to look for
  57575. * @returns the lens flare system or null if not found
  57576. */
  57577. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57578. /**
  57579. * Gets a lens flare system using its id
  57580. * @param id defines the id to look for
  57581. * @returns the lens flare system or null if not found
  57582. */
  57583. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57584. }
  57585. /**
  57586. * Defines the lens flare scene component responsible to manage any lens flares
  57587. * in a given scene.
  57588. */
  57589. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57590. /**
  57591. * The component name helpfull to identify the component in the list of scene components.
  57592. */
  57593. readonly name: string;
  57594. /**
  57595. * The scene the component belongs to.
  57596. */
  57597. scene: Scene;
  57598. /**
  57599. * Creates a new instance of the component for the given scene
  57600. * @param scene Defines the scene to register the component in
  57601. */
  57602. constructor(scene: Scene);
  57603. /**
  57604. * Registers the component in a given scene
  57605. */
  57606. register(): void;
  57607. /**
  57608. * Rebuilds the elements related to this component in case of
  57609. * context lost for instance.
  57610. */
  57611. rebuild(): void;
  57612. /**
  57613. * Adds all the elements from the container to the scene
  57614. * @param container the container holding the elements
  57615. */
  57616. addFromContainer(container: AbstractScene): void;
  57617. /**
  57618. * Removes all the elements in the container from the scene
  57619. * @param container contains the elements to remove
  57620. * @param dispose if the removed element should be disposed (default: false)
  57621. */
  57622. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57623. /**
  57624. * Serializes the component data to the specified json object
  57625. * @param serializationObject The object to serialize to
  57626. */
  57627. serialize(serializationObject: any): void;
  57628. /**
  57629. * Disposes the component and the associated ressources.
  57630. */
  57631. dispose(): void;
  57632. private _draw;
  57633. }
  57634. }
  57635. declare module BABYLON {
  57636. /** @hidden */
  57637. export var depthPixelShader: {
  57638. name: string;
  57639. shader: string;
  57640. };
  57641. }
  57642. declare module BABYLON {
  57643. /** @hidden */
  57644. export var depthVertexShader: {
  57645. name: string;
  57646. shader: string;
  57647. };
  57648. }
  57649. declare module BABYLON {
  57650. /**
  57651. * This represents a depth renderer in Babylon.
  57652. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57653. */
  57654. export class DepthRenderer {
  57655. private _scene;
  57656. private _depthMap;
  57657. private _effect;
  57658. private readonly _storeNonLinearDepth;
  57659. private readonly _clearColor;
  57660. /** Get if the depth renderer is using packed depth or not */
  57661. readonly isPacked: boolean;
  57662. private _cachedDefines;
  57663. private _camera;
  57664. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57665. enabled: boolean;
  57666. /**
  57667. * Specifiess that the depth renderer will only be used within
  57668. * the camera it is created for.
  57669. * This can help forcing its rendering during the camera processing.
  57670. */
  57671. useOnlyInActiveCamera: boolean;
  57672. /** @hidden */
  57673. static _SceneComponentInitialization: (scene: Scene) => void;
  57674. /**
  57675. * Instantiates a depth renderer
  57676. * @param scene The scene the renderer belongs to
  57677. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57678. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57679. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57680. */
  57681. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57682. /**
  57683. * Creates the depth rendering effect and checks if the effect is ready.
  57684. * @param subMesh The submesh to be used to render the depth map of
  57685. * @param useInstances If multiple world instances should be used
  57686. * @returns if the depth renderer is ready to render the depth map
  57687. */
  57688. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57689. /**
  57690. * Gets the texture which the depth map will be written to.
  57691. * @returns The depth map texture
  57692. */
  57693. getDepthMap(): RenderTargetTexture;
  57694. /**
  57695. * Disposes of the depth renderer.
  57696. */
  57697. dispose(): void;
  57698. }
  57699. }
  57700. declare module BABYLON {
  57701. /** @hidden */
  57702. export var minmaxReduxPixelShader: {
  57703. name: string;
  57704. shader: string;
  57705. };
  57706. }
  57707. declare module BABYLON {
  57708. /**
  57709. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57710. * and maximum values from all values of the texture.
  57711. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57712. * The source values are read from the red channel of the texture.
  57713. */
  57714. export class MinMaxReducer {
  57715. /**
  57716. * Observable triggered when the computation has been performed
  57717. */
  57718. onAfterReductionPerformed: Observable<{
  57719. min: number;
  57720. max: number;
  57721. }>;
  57722. protected _camera: Camera;
  57723. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57724. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57725. protected _postProcessManager: PostProcessManager;
  57726. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57727. protected _forceFullscreenViewport: boolean;
  57728. /**
  57729. * Creates a min/max reducer
  57730. * @param camera The camera to use for the post processes
  57731. */
  57732. constructor(camera: Camera);
  57733. /**
  57734. * Gets the texture used to read the values from.
  57735. */
  57736. get sourceTexture(): Nullable<RenderTargetTexture>;
  57737. /**
  57738. * Sets the source texture to read the values from.
  57739. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57740. * because in such textures '1' value must not be taken into account to compute the maximum
  57741. * as this value is used to clear the texture.
  57742. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57743. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57744. * @param depthRedux Indicates if the texture is a depth texture or not
  57745. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57746. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57747. */
  57748. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57749. /**
  57750. * Defines the refresh rate of the computation.
  57751. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57752. */
  57753. get refreshRate(): number;
  57754. set refreshRate(value: number);
  57755. protected _activated: boolean;
  57756. /**
  57757. * Gets the activation status of the reducer
  57758. */
  57759. get activated(): boolean;
  57760. /**
  57761. * Activates the reduction computation.
  57762. * When activated, the observers registered in onAfterReductionPerformed are
  57763. * called after the compuation is performed
  57764. */
  57765. activate(): void;
  57766. /**
  57767. * Deactivates the reduction computation.
  57768. */
  57769. deactivate(): void;
  57770. /**
  57771. * Disposes the min/max reducer
  57772. * @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.
  57773. */
  57774. dispose(disposeAll?: boolean): void;
  57775. }
  57776. }
  57777. declare module BABYLON {
  57778. /**
  57779. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57780. */
  57781. export class DepthReducer extends MinMaxReducer {
  57782. private _depthRenderer;
  57783. private _depthRendererId;
  57784. /**
  57785. * Gets the depth renderer used for the computation.
  57786. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57787. */
  57788. get depthRenderer(): Nullable<DepthRenderer>;
  57789. /**
  57790. * Creates a depth reducer
  57791. * @param camera The camera used to render the depth texture
  57792. */
  57793. constructor(camera: Camera);
  57794. /**
  57795. * Sets the depth renderer to use to generate the depth map
  57796. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57797. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57798. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57799. */
  57800. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57801. /** @hidden */
  57802. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57803. /**
  57804. * Activates the reduction computation.
  57805. * When activated, the observers registered in onAfterReductionPerformed are
  57806. * called after the compuation is performed
  57807. */
  57808. activate(): void;
  57809. /**
  57810. * Deactivates the reduction computation.
  57811. */
  57812. deactivate(): void;
  57813. /**
  57814. * Disposes the depth reducer
  57815. * @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.
  57816. */
  57817. dispose(disposeAll?: boolean): void;
  57818. }
  57819. }
  57820. declare module BABYLON {
  57821. /**
  57822. * A CSM implementation allowing casting shadows on large scenes.
  57823. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57824. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57825. */
  57826. export class CascadedShadowGenerator extends ShadowGenerator {
  57827. private static readonly frustumCornersNDCSpace;
  57828. /**
  57829. * Name of the CSM class
  57830. */
  57831. static CLASSNAME: string;
  57832. /**
  57833. * Defines the default number of cascades used by the CSM.
  57834. */
  57835. static readonly DEFAULT_CASCADES_COUNT: number;
  57836. /**
  57837. * Defines the minimum number of cascades used by the CSM.
  57838. */
  57839. static readonly MIN_CASCADES_COUNT: number;
  57840. /**
  57841. * Defines the maximum number of cascades used by the CSM.
  57842. */
  57843. static readonly MAX_CASCADES_COUNT: number;
  57844. protected _validateFilter(filter: number): number;
  57845. /**
  57846. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57847. */
  57848. penumbraDarkness: number;
  57849. private _numCascades;
  57850. /**
  57851. * Gets or set the number of cascades used by the CSM.
  57852. */
  57853. get numCascades(): number;
  57854. set numCascades(value: number);
  57855. /**
  57856. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57857. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  57858. */
  57859. stabilizeCascades: boolean;
  57860. private _freezeShadowCastersBoundingInfo;
  57861. private _freezeShadowCastersBoundingInfoObservable;
  57862. /**
  57863. * Enables or disables the shadow casters bounding info computation.
  57864. * If your shadow casters don't move, you can disable this feature.
  57865. * If it is enabled, the bounding box computation is done every frame.
  57866. */
  57867. get freezeShadowCastersBoundingInfo(): boolean;
  57868. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57869. private _scbiMin;
  57870. private _scbiMax;
  57871. protected _computeShadowCastersBoundingInfo(): void;
  57872. protected _shadowCastersBoundingInfo: BoundingInfo;
  57873. /**
  57874. * Gets or sets the shadow casters bounding info.
  57875. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57876. * so that the system won't overwrite the bounds you provide
  57877. */
  57878. get shadowCastersBoundingInfo(): BoundingInfo;
  57879. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57880. protected _breaksAreDirty: boolean;
  57881. protected _minDistance: number;
  57882. protected _maxDistance: number;
  57883. /**
  57884. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57885. *
  57886. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57887. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57888. * @param min minimal distance for the breaks (default to 0.)
  57889. * @param max maximal distance for the breaks (default to 1.)
  57890. */
  57891. setMinMaxDistance(min: number, max: number): void;
  57892. /** Gets the minimal distance used in the cascade break computation */
  57893. get minDistance(): number;
  57894. /** Gets the maximal distance used in the cascade break computation */
  57895. get maxDistance(): number;
  57896. /**
  57897. * Gets the class name of that object
  57898. * @returns "CascadedShadowGenerator"
  57899. */
  57900. getClassName(): string;
  57901. private _cascadeMinExtents;
  57902. private _cascadeMaxExtents;
  57903. /**
  57904. * Gets a cascade minimum extents
  57905. * @param cascadeIndex index of the cascade
  57906. * @returns the minimum cascade extents
  57907. */
  57908. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57909. /**
  57910. * Gets a cascade maximum extents
  57911. * @param cascadeIndex index of the cascade
  57912. * @returns the maximum cascade extents
  57913. */
  57914. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57915. private _cascades;
  57916. private _currentLayer;
  57917. private _viewSpaceFrustumsZ;
  57918. private _viewMatrices;
  57919. private _projectionMatrices;
  57920. private _transformMatrices;
  57921. private _transformMatricesAsArray;
  57922. private _frustumLengths;
  57923. private _lightSizeUVCorrection;
  57924. private _depthCorrection;
  57925. private _frustumCornersWorldSpace;
  57926. private _frustumCenter;
  57927. private _shadowCameraPos;
  57928. private _shadowMaxZ;
  57929. /**
  57930. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57931. * It defaults to camera.maxZ
  57932. */
  57933. get shadowMaxZ(): number;
  57934. /**
  57935. * Sets the shadow max z distance.
  57936. */
  57937. set shadowMaxZ(value: number);
  57938. protected _debug: boolean;
  57939. /**
  57940. * Gets or sets the debug flag.
  57941. * When enabled, the cascades are materialized by different colors on the screen.
  57942. */
  57943. get debug(): boolean;
  57944. set debug(dbg: boolean);
  57945. private _depthClamp;
  57946. /**
  57947. * Gets or sets the depth clamping value.
  57948. *
  57949. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57950. * to account for the shadow casters far away.
  57951. *
  57952. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57953. */
  57954. get depthClamp(): boolean;
  57955. set depthClamp(value: boolean);
  57956. private _cascadeBlendPercentage;
  57957. /**
  57958. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57959. * It defaults to 0.1 (10% blending).
  57960. */
  57961. get cascadeBlendPercentage(): number;
  57962. set cascadeBlendPercentage(value: number);
  57963. private _lambda;
  57964. /**
  57965. * Gets or set the lambda parameter.
  57966. * This parameter is used to split the camera frustum and create the cascades.
  57967. * 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.
  57968. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57969. */
  57970. get lambda(): number;
  57971. set lambda(value: number);
  57972. /**
  57973. * Gets the view matrix corresponding to a given cascade
  57974. * @param cascadeNum cascade to retrieve the view matrix from
  57975. * @returns the cascade view matrix
  57976. */
  57977. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57978. /**
  57979. * Gets the projection matrix corresponding to a given cascade
  57980. * @param cascadeNum cascade to retrieve the projection matrix from
  57981. * @returns the cascade projection matrix
  57982. */
  57983. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57984. /**
  57985. * Gets the transformation matrix corresponding to a given cascade
  57986. * @param cascadeNum cascade to retrieve the transformation matrix from
  57987. * @returns the cascade transformation matrix
  57988. */
  57989. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57990. private _depthRenderer;
  57991. /**
  57992. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57993. *
  57994. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57995. *
  57996. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57997. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57998. * @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
  57999. */
  58000. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58001. private _depthReducer;
  58002. private _autoCalcDepthBounds;
  58003. /**
  58004. * Gets or sets the autoCalcDepthBounds property.
  58005. *
  58006. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58007. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58008. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58009. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58010. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58011. */
  58012. get autoCalcDepthBounds(): boolean;
  58013. set autoCalcDepthBounds(value: boolean);
  58014. /**
  58015. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58016. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58017. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58018. * for setting the refresh rate on the renderer yourself!
  58019. */
  58020. get autoCalcDepthBoundsRefreshRate(): number;
  58021. set autoCalcDepthBoundsRefreshRate(value: number);
  58022. /**
  58023. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58024. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58025. * you change the camera near/far planes!
  58026. */
  58027. splitFrustum(): void;
  58028. private _splitFrustum;
  58029. private _computeMatrices;
  58030. private _computeFrustumInWorldSpace;
  58031. private _computeCascadeFrustum;
  58032. /**
  58033. * Support test.
  58034. */
  58035. static get IsSupported(): boolean;
  58036. /** @hidden */
  58037. static _SceneComponentInitialization: (scene: Scene) => void;
  58038. /**
  58039. * Creates a Cascaded Shadow Generator object.
  58040. * A ShadowGenerator is the required tool to use the shadows.
  58041. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58042. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58043. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58044. * @param light The directional light object generating the shadows.
  58045. * @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.
  58046. */
  58047. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58048. protected _initializeGenerator(): void;
  58049. protected _createTargetRenderTexture(): void;
  58050. protected _initializeShadowMap(): void;
  58051. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58052. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58053. /**
  58054. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58055. * @param defines Defines of the material we want to update
  58056. * @param lightIndex Index of the light in the enabled light list of the material
  58057. */
  58058. prepareDefines(defines: any, lightIndex: number): void;
  58059. /**
  58060. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58061. * defined in the generator but impacting the effect).
  58062. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58063. * @param effect The effect we are binfing the information for
  58064. */
  58065. bindShadowLight(lightIndex: string, effect: Effect): void;
  58066. /**
  58067. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58068. * (eq to view projection * shadow projection matrices)
  58069. * @returns The transform matrix used to create the shadow map
  58070. */
  58071. getTransformMatrix(): Matrix;
  58072. /**
  58073. * Disposes the ShadowGenerator.
  58074. * Returns nothing.
  58075. */
  58076. dispose(): void;
  58077. /**
  58078. * Serializes the shadow generator setup to a json object.
  58079. * @returns The serialized JSON object
  58080. */
  58081. serialize(): any;
  58082. /**
  58083. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58084. * @param parsedShadowGenerator The JSON object to parse
  58085. * @param scene The scene to create the shadow map for
  58086. * @returns The parsed shadow generator
  58087. */
  58088. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58089. }
  58090. }
  58091. declare module BABYLON {
  58092. /**
  58093. * Defines the shadow generator component responsible to manage any shadow generators
  58094. * in a given scene.
  58095. */
  58096. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58097. /**
  58098. * The component name helpfull to identify the component in the list of scene components.
  58099. */
  58100. readonly name: string;
  58101. /**
  58102. * The scene the component belongs to.
  58103. */
  58104. scene: Scene;
  58105. /**
  58106. * Creates a new instance of the component for the given scene
  58107. * @param scene Defines the scene to register the component in
  58108. */
  58109. constructor(scene: Scene);
  58110. /**
  58111. * Registers the component in a given scene
  58112. */
  58113. register(): void;
  58114. /**
  58115. * Rebuilds the elements related to this component in case of
  58116. * context lost for instance.
  58117. */
  58118. rebuild(): void;
  58119. /**
  58120. * Serializes the component data to the specified json object
  58121. * @param serializationObject The object to serialize to
  58122. */
  58123. serialize(serializationObject: any): void;
  58124. /**
  58125. * Adds all the elements from the container to the scene
  58126. * @param container the container holding the elements
  58127. */
  58128. addFromContainer(container: AbstractScene): void;
  58129. /**
  58130. * Removes all the elements in the container from the scene
  58131. * @param container contains the elements to remove
  58132. * @param dispose if the removed element should be disposed (default: false)
  58133. */
  58134. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58135. /**
  58136. * Rebuilds the elements related to this component in case of
  58137. * context lost for instance.
  58138. */
  58139. dispose(): void;
  58140. private _gatherRenderTargets;
  58141. }
  58142. }
  58143. declare module BABYLON {
  58144. /**
  58145. * A point light is a light defined by an unique point in world space.
  58146. * The light is emitted in every direction from this point.
  58147. * A good example of a point light is a standard light bulb.
  58148. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58149. */
  58150. export class PointLight extends ShadowLight {
  58151. private _shadowAngle;
  58152. /**
  58153. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58154. * This specifies what angle the shadow will use to be created.
  58155. *
  58156. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58157. */
  58158. get shadowAngle(): number;
  58159. /**
  58160. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58161. * This specifies what angle the shadow will use to be created.
  58162. *
  58163. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58164. */
  58165. set shadowAngle(value: number);
  58166. /**
  58167. * Gets the direction if it has been set.
  58168. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58169. */
  58170. get direction(): Vector3;
  58171. /**
  58172. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58173. */
  58174. set direction(value: Vector3);
  58175. /**
  58176. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58177. * A PointLight emits the light in every direction.
  58178. * It can cast shadows.
  58179. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58180. * ```javascript
  58181. * var pointLight = new PointLight("pl", camera.position, scene);
  58182. * ```
  58183. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58184. * @param name The light friendly name
  58185. * @param position The position of the point light in the scene
  58186. * @param scene The scene the lights belongs to
  58187. */
  58188. constructor(name: string, position: Vector3, scene: Scene);
  58189. /**
  58190. * Returns the string "PointLight"
  58191. * @returns the class name
  58192. */
  58193. getClassName(): string;
  58194. /**
  58195. * Returns the integer 0.
  58196. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58197. */
  58198. getTypeID(): number;
  58199. /**
  58200. * Specifies wether or not the shadowmap should be a cube texture.
  58201. * @returns true if the shadowmap needs to be a cube texture.
  58202. */
  58203. needCube(): boolean;
  58204. /**
  58205. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58206. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58207. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58208. */
  58209. getShadowDirection(faceIndex?: number): Vector3;
  58210. /**
  58211. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58212. * - fov = PI / 2
  58213. * - aspect ratio : 1.0
  58214. * - z-near and far equal to the active camera minZ and maxZ.
  58215. * Returns the PointLight.
  58216. */
  58217. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58218. protected _buildUniformLayout(): void;
  58219. /**
  58220. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58221. * @param effect The effect to update
  58222. * @param lightIndex The index of the light in the effect to update
  58223. * @returns The point light
  58224. */
  58225. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58226. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58227. /**
  58228. * Prepares the list of defines specific to the light type.
  58229. * @param defines the list of defines
  58230. * @param lightIndex defines the index of the light for the effect
  58231. */
  58232. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58233. }
  58234. }
  58235. declare module BABYLON {
  58236. /**
  58237. * Header information of HDR texture files.
  58238. */
  58239. export interface HDRInfo {
  58240. /**
  58241. * The height of the texture in pixels.
  58242. */
  58243. height: number;
  58244. /**
  58245. * The width of the texture in pixels.
  58246. */
  58247. width: number;
  58248. /**
  58249. * The index of the beginning of the data in the binary file.
  58250. */
  58251. dataPosition: number;
  58252. }
  58253. /**
  58254. * This groups tools to convert HDR texture to native colors array.
  58255. */
  58256. export class HDRTools {
  58257. private static Ldexp;
  58258. private static Rgbe2float;
  58259. private static readStringLine;
  58260. /**
  58261. * Reads header information from an RGBE texture stored in a native array.
  58262. * More information on this format are available here:
  58263. * https://en.wikipedia.org/wiki/RGBE_image_format
  58264. *
  58265. * @param uint8array The binary file stored in native array.
  58266. * @return The header information.
  58267. */
  58268. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58269. /**
  58270. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58271. * This RGBE texture needs to store the information as a panorama.
  58272. *
  58273. * More information on this format are available here:
  58274. * https://en.wikipedia.org/wiki/RGBE_image_format
  58275. *
  58276. * @param buffer The binary file stored in an array buffer.
  58277. * @param size The expected size of the extracted cubemap.
  58278. * @return The Cube Map information.
  58279. */
  58280. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58281. /**
  58282. * Returns the pixels data extracted from an RGBE texture.
  58283. * This pixels will be stored left to right up to down in the R G B order in one array.
  58284. *
  58285. * More information on this format are available here:
  58286. * https://en.wikipedia.org/wiki/RGBE_image_format
  58287. *
  58288. * @param uint8array The binary file stored in an array buffer.
  58289. * @param hdrInfo The header information of the file.
  58290. * @return The pixels data in RGB right to left up to down order.
  58291. */
  58292. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58293. private static RGBE_ReadPixels_RLE;
  58294. }
  58295. }
  58296. declare module BABYLON {
  58297. /**
  58298. * Effect Render Options
  58299. */
  58300. export interface IEffectRendererOptions {
  58301. /**
  58302. * Defines the vertices positions.
  58303. */
  58304. positions?: number[];
  58305. /**
  58306. * Defines the indices.
  58307. */
  58308. indices?: number[];
  58309. }
  58310. /**
  58311. * Helper class to render one or more effects.
  58312. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58313. */
  58314. export class EffectRenderer {
  58315. private engine;
  58316. private static _DefaultOptions;
  58317. private _vertexBuffers;
  58318. private _indexBuffer;
  58319. private _fullscreenViewport;
  58320. /**
  58321. * Creates an effect renderer
  58322. * @param engine the engine to use for rendering
  58323. * @param options defines the options of the effect renderer
  58324. */
  58325. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58326. /**
  58327. * Sets the current viewport in normalized coordinates 0-1
  58328. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58329. */
  58330. setViewport(viewport?: Viewport): void;
  58331. /**
  58332. * Binds the embedded attributes buffer to the effect.
  58333. * @param effect Defines the effect to bind the attributes for
  58334. */
  58335. bindBuffers(effect: Effect): void;
  58336. /**
  58337. * Sets the current effect wrapper to use during draw.
  58338. * The effect needs to be ready before calling this api.
  58339. * This also sets the default full screen position attribute.
  58340. * @param effectWrapper Defines the effect to draw with
  58341. */
  58342. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58343. /**
  58344. * Restores engine states
  58345. */
  58346. restoreStates(): void;
  58347. /**
  58348. * Draws a full screen quad.
  58349. */
  58350. draw(): void;
  58351. private isRenderTargetTexture;
  58352. /**
  58353. * renders one or more effects to a specified texture
  58354. * @param effectWrapper the effect to renderer
  58355. * @param outputTexture texture to draw to, if null it will render to the screen.
  58356. */
  58357. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58358. /**
  58359. * Disposes of the effect renderer
  58360. */
  58361. dispose(): void;
  58362. }
  58363. /**
  58364. * Options to create an EffectWrapper
  58365. */
  58366. interface EffectWrapperCreationOptions {
  58367. /**
  58368. * Engine to use to create the effect
  58369. */
  58370. engine: ThinEngine;
  58371. /**
  58372. * Fragment shader for the effect
  58373. */
  58374. fragmentShader: string;
  58375. /**
  58376. * Use the shader store instead of direct source code
  58377. */
  58378. useShaderStore?: boolean;
  58379. /**
  58380. * Vertex shader for the effect
  58381. */
  58382. vertexShader?: string;
  58383. /**
  58384. * Attributes to use in the shader
  58385. */
  58386. attributeNames?: Array<string>;
  58387. /**
  58388. * Uniforms to use in the shader
  58389. */
  58390. uniformNames?: Array<string>;
  58391. /**
  58392. * Texture sampler names to use in the shader
  58393. */
  58394. samplerNames?: Array<string>;
  58395. /**
  58396. * Defines to use in the shader
  58397. */
  58398. defines?: Array<string>;
  58399. /**
  58400. * Callback when effect is compiled
  58401. */
  58402. onCompiled?: Nullable<(effect: Effect) => void>;
  58403. /**
  58404. * The friendly name of the effect displayed in Spector.
  58405. */
  58406. name?: string;
  58407. }
  58408. /**
  58409. * Wraps an effect to be used for rendering
  58410. */
  58411. export class EffectWrapper {
  58412. /**
  58413. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58414. */
  58415. onApplyObservable: Observable<{}>;
  58416. /**
  58417. * The underlying effect
  58418. */
  58419. effect: Effect;
  58420. /**
  58421. * Creates an effect to be renderer
  58422. * @param creationOptions options to create the effect
  58423. */
  58424. constructor(creationOptions: EffectWrapperCreationOptions);
  58425. /**
  58426. * Disposes of the effect wrapper
  58427. */
  58428. dispose(): void;
  58429. }
  58430. }
  58431. declare module BABYLON {
  58432. /** @hidden */
  58433. export var hdrFilteringVertexShader: {
  58434. name: string;
  58435. shader: string;
  58436. };
  58437. }
  58438. declare module BABYLON {
  58439. /** @hidden */
  58440. export var hdrFilteringPixelShader: {
  58441. name: string;
  58442. shader: string;
  58443. };
  58444. }
  58445. declare module BABYLON {
  58446. /**
  58447. * Options for texture filtering
  58448. */
  58449. interface IHDRFilteringOptions {
  58450. /**
  58451. * Scales pixel intensity for the input HDR map.
  58452. */
  58453. hdrScale?: number;
  58454. /**
  58455. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58456. */
  58457. quality?: number;
  58458. }
  58459. /**
  58460. * Filters HDR maps to get correct renderings of PBR reflections
  58461. */
  58462. export class HDRFiltering {
  58463. private _engine;
  58464. private _effectRenderer;
  58465. private _effectWrapper;
  58466. private _lodGenerationOffset;
  58467. private _lodGenerationScale;
  58468. /**
  58469. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58470. * you care about baking speed.
  58471. */
  58472. quality: number;
  58473. /**
  58474. * Scales pixel intensity for the input HDR map.
  58475. */
  58476. hdrScale: number;
  58477. /**
  58478. * Instantiates HDR filter for reflection maps
  58479. *
  58480. * @param engine Thin engine
  58481. * @param options Options
  58482. */
  58483. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58484. private _createRenderTarget;
  58485. private _prefilterInternal;
  58486. private _createEffect;
  58487. /**
  58488. * Get a value indicating if the filter is ready to be used
  58489. * @param texture Texture to filter
  58490. * @returns true if the filter is ready
  58491. */
  58492. isReady(texture: BaseTexture): boolean;
  58493. /**
  58494. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58495. * Prefiltering will be invoked at the end of next rendering pass.
  58496. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58497. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58498. * @param texture Texture to filter
  58499. * @param onFinished Callback when filtering is done
  58500. * @return Promise called when prefiltering is done
  58501. */
  58502. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  58503. }
  58504. }
  58505. declare module BABYLON {
  58506. /**
  58507. * This represents a texture coming from an HDR input.
  58508. *
  58509. * The only supported format is currently panorama picture stored in RGBE format.
  58510. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58511. */
  58512. export class HDRCubeTexture extends BaseTexture {
  58513. private static _facesMapping;
  58514. private _generateHarmonics;
  58515. private _noMipmap;
  58516. private _prefilterOnLoad;
  58517. private _textureMatrix;
  58518. private _size;
  58519. private _onLoad;
  58520. private _onError;
  58521. /**
  58522. * The texture URL.
  58523. */
  58524. url: string;
  58525. /**
  58526. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58527. */
  58528. coordinatesMode: number;
  58529. protected _isBlocking: boolean;
  58530. /**
  58531. * Sets wether or not the texture is blocking during loading.
  58532. */
  58533. set isBlocking(value: boolean);
  58534. /**
  58535. * Gets wether or not the texture is blocking during loading.
  58536. */
  58537. get isBlocking(): boolean;
  58538. protected _rotationY: number;
  58539. /**
  58540. * Sets texture matrix rotation angle around Y axis in radians.
  58541. */
  58542. set rotationY(value: number);
  58543. /**
  58544. * Gets texture matrix rotation angle around Y axis radians.
  58545. */
  58546. get rotationY(): number;
  58547. /**
  58548. * Gets or sets the center of the bounding box associated with the cube texture
  58549. * It must define where the camera used to render the texture was set
  58550. */
  58551. boundingBoxPosition: Vector3;
  58552. private _boundingBoxSize;
  58553. /**
  58554. * Gets or sets the size of the bounding box associated with the cube texture
  58555. * When defined, the cubemap will switch to local mode
  58556. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58557. * @example https://www.babylonjs-playground.com/#RNASML
  58558. */
  58559. set boundingBoxSize(value: Vector3);
  58560. get boundingBoxSize(): Vector3;
  58561. /**
  58562. * Instantiates an HDRTexture from the following parameters.
  58563. *
  58564. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58565. * @param sceneOrEngine The scene or engine the texture will be used in
  58566. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58567. * @param noMipmap Forces to not generate the mipmap if true
  58568. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58569. * @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)
  58570. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  58571. */
  58572. 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>);
  58573. /**
  58574. * Get the current class name of the texture useful for serialization or dynamic coding.
  58575. * @returns "HDRCubeTexture"
  58576. */
  58577. getClassName(): string;
  58578. /**
  58579. * Occurs when the file is raw .hdr file.
  58580. */
  58581. private loadTexture;
  58582. clone(): HDRCubeTexture;
  58583. delayLoad(): void;
  58584. /**
  58585. * Get the texture reflection matrix used to rotate/transform the reflection.
  58586. * @returns the reflection matrix
  58587. */
  58588. getReflectionTextureMatrix(): Matrix;
  58589. /**
  58590. * Set the texture reflection matrix used to rotate/transform the reflection.
  58591. * @param value Define the reflection matrix to set
  58592. */
  58593. setReflectionTextureMatrix(value: Matrix): void;
  58594. /**
  58595. * Parses a JSON representation of an HDR Texture in order to create the texture
  58596. * @param parsedTexture Define the JSON representation
  58597. * @param scene Define the scene the texture should be created in
  58598. * @param rootUrl Define the root url in case we need to load relative dependencies
  58599. * @returns the newly created texture after parsing
  58600. */
  58601. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58602. serialize(): any;
  58603. }
  58604. }
  58605. declare module BABYLON {
  58606. /**
  58607. * Class used to control physics engine
  58608. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58609. */
  58610. export class PhysicsEngine implements IPhysicsEngine {
  58611. private _physicsPlugin;
  58612. /**
  58613. * Global value used to control the smallest number supported by the simulation
  58614. */
  58615. static Epsilon: number;
  58616. private _impostors;
  58617. private _joints;
  58618. private _subTimeStep;
  58619. /**
  58620. * Gets the gravity vector used by the simulation
  58621. */
  58622. gravity: Vector3;
  58623. /**
  58624. * Factory used to create the default physics plugin.
  58625. * @returns The default physics plugin
  58626. */
  58627. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58628. /**
  58629. * Creates a new Physics Engine
  58630. * @param gravity defines the gravity vector used by the simulation
  58631. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58632. */
  58633. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58634. /**
  58635. * Sets the gravity vector used by the simulation
  58636. * @param gravity defines the gravity vector to use
  58637. */
  58638. setGravity(gravity: Vector3): void;
  58639. /**
  58640. * Set the time step of the physics engine.
  58641. * Default is 1/60.
  58642. * To slow it down, enter 1/600 for example.
  58643. * To speed it up, 1/30
  58644. * @param newTimeStep defines the new timestep to apply to this world.
  58645. */
  58646. setTimeStep(newTimeStep?: number): void;
  58647. /**
  58648. * Get the time step of the physics engine.
  58649. * @returns the current time step
  58650. */
  58651. getTimeStep(): number;
  58652. /**
  58653. * Set the sub time step of the physics engine.
  58654. * Default is 0 meaning there is no sub steps
  58655. * To increase physics resolution precision, set a small value (like 1 ms)
  58656. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58657. */
  58658. setSubTimeStep(subTimeStep?: number): void;
  58659. /**
  58660. * Get the sub time step of the physics engine.
  58661. * @returns the current sub time step
  58662. */
  58663. getSubTimeStep(): number;
  58664. /**
  58665. * Release all resources
  58666. */
  58667. dispose(): void;
  58668. /**
  58669. * Gets the name of the current physics plugin
  58670. * @returns the name of the plugin
  58671. */
  58672. getPhysicsPluginName(): string;
  58673. /**
  58674. * Adding a new impostor for the impostor tracking.
  58675. * This will be done by the impostor itself.
  58676. * @param impostor the impostor to add
  58677. */
  58678. addImpostor(impostor: PhysicsImpostor): void;
  58679. /**
  58680. * Remove an impostor from the engine.
  58681. * This impostor and its mesh will not longer be updated by the physics engine.
  58682. * @param impostor the impostor to remove
  58683. */
  58684. removeImpostor(impostor: PhysicsImpostor): void;
  58685. /**
  58686. * Add a joint to the physics engine
  58687. * @param mainImpostor defines the main impostor to which the joint is added.
  58688. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58689. * @param joint defines the joint that will connect both impostors.
  58690. */
  58691. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58692. /**
  58693. * Removes a joint from the simulation
  58694. * @param mainImpostor defines the impostor used with the joint
  58695. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58696. * @param joint defines the joint to remove
  58697. */
  58698. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58699. /**
  58700. * Called by the scene. No need to call it.
  58701. * @param delta defines the timespam between frames
  58702. */
  58703. _step(delta: number): void;
  58704. /**
  58705. * Gets the current plugin used to run the simulation
  58706. * @returns current plugin
  58707. */
  58708. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58709. /**
  58710. * Gets the list of physic impostors
  58711. * @returns an array of PhysicsImpostor
  58712. */
  58713. getImpostors(): Array<PhysicsImpostor>;
  58714. /**
  58715. * Gets the impostor for a physics enabled object
  58716. * @param object defines the object impersonated by the impostor
  58717. * @returns the PhysicsImpostor or null if not found
  58718. */
  58719. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58720. /**
  58721. * Gets the impostor for a physics body object
  58722. * @param body defines physics body used by the impostor
  58723. * @returns the PhysicsImpostor or null if not found
  58724. */
  58725. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58726. /**
  58727. * Does a raycast in the physics world
  58728. * @param from when should the ray start?
  58729. * @param to when should the ray end?
  58730. * @returns PhysicsRaycastResult
  58731. */
  58732. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58733. }
  58734. }
  58735. declare module BABYLON {
  58736. /** @hidden */
  58737. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58738. private _useDeltaForWorldStep;
  58739. world: any;
  58740. name: string;
  58741. private _physicsMaterials;
  58742. private _fixedTimeStep;
  58743. private _cannonRaycastResult;
  58744. private _raycastResult;
  58745. private _physicsBodysToRemoveAfterStep;
  58746. private _firstFrame;
  58747. BJSCANNON: any;
  58748. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58749. setGravity(gravity: Vector3): void;
  58750. setTimeStep(timeStep: number): void;
  58751. getTimeStep(): number;
  58752. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58753. private _removeMarkedPhysicsBodiesFromWorld;
  58754. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58755. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58756. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58757. private _processChildMeshes;
  58758. removePhysicsBody(impostor: PhysicsImpostor): void;
  58759. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58760. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58761. private _addMaterial;
  58762. private _checkWithEpsilon;
  58763. private _createShape;
  58764. private _createHeightmap;
  58765. private _minus90X;
  58766. private _plus90X;
  58767. private _tmpPosition;
  58768. private _tmpDeltaPosition;
  58769. private _tmpUnityRotation;
  58770. private _updatePhysicsBodyTransformation;
  58771. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58772. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58773. isSupported(): boolean;
  58774. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58775. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58776. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58777. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58778. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58779. getBodyMass(impostor: PhysicsImpostor): number;
  58780. getBodyFriction(impostor: PhysicsImpostor): number;
  58781. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58782. getBodyRestitution(impostor: PhysicsImpostor): number;
  58783. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58784. sleepBody(impostor: PhysicsImpostor): void;
  58785. wakeUpBody(impostor: PhysicsImpostor): void;
  58786. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58787. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58788. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58789. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58790. getRadius(impostor: PhysicsImpostor): number;
  58791. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58792. dispose(): void;
  58793. private _extendNamespace;
  58794. /**
  58795. * Does a raycast in the physics world
  58796. * @param from when should the ray start?
  58797. * @param to when should the ray end?
  58798. * @returns PhysicsRaycastResult
  58799. */
  58800. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58801. }
  58802. }
  58803. declare module BABYLON {
  58804. /** @hidden */
  58805. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58806. private _useDeltaForWorldStep;
  58807. world: any;
  58808. name: string;
  58809. BJSOIMO: any;
  58810. private _raycastResult;
  58811. private _fixedTimeStep;
  58812. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58813. setGravity(gravity: Vector3): void;
  58814. setTimeStep(timeStep: number): void;
  58815. getTimeStep(): number;
  58816. private _tmpImpostorsArray;
  58817. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58818. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58819. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58820. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58821. private _tmpPositionVector;
  58822. removePhysicsBody(impostor: PhysicsImpostor): void;
  58823. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58824. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58825. isSupported(): boolean;
  58826. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58827. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58828. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58829. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58830. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58831. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58832. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58833. getBodyMass(impostor: PhysicsImpostor): number;
  58834. getBodyFriction(impostor: PhysicsImpostor): number;
  58835. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58836. getBodyRestitution(impostor: PhysicsImpostor): number;
  58837. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58838. sleepBody(impostor: PhysicsImpostor): void;
  58839. wakeUpBody(impostor: PhysicsImpostor): void;
  58840. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58841. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58842. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58843. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58844. getRadius(impostor: PhysicsImpostor): number;
  58845. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58846. dispose(): void;
  58847. /**
  58848. * Does a raycast in the physics world
  58849. * @param from when should the ray start?
  58850. * @param to when should the ray end?
  58851. * @returns PhysicsRaycastResult
  58852. */
  58853. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58854. }
  58855. }
  58856. declare module BABYLON {
  58857. /**
  58858. * Class containing static functions to help procedurally build meshes
  58859. */
  58860. export class RibbonBuilder {
  58861. /**
  58862. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58863. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58864. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58865. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58866. * * 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
  58867. * * 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
  58868. * * 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
  58869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58870. * * 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
  58871. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58872. * * 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
  58873. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58874. * * 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
  58875. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58877. * @param name defines the name of the mesh
  58878. * @param options defines the options used to create the mesh
  58879. * @param scene defines the hosting scene
  58880. * @returns the ribbon mesh
  58881. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58882. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58883. */
  58884. static CreateRibbon(name: string, options: {
  58885. pathArray: Vector3[][];
  58886. closeArray?: boolean;
  58887. closePath?: boolean;
  58888. offset?: number;
  58889. updatable?: boolean;
  58890. sideOrientation?: number;
  58891. frontUVs?: Vector4;
  58892. backUVs?: Vector4;
  58893. instance?: Mesh;
  58894. invertUV?: boolean;
  58895. uvs?: Vector2[];
  58896. colors?: Color4[];
  58897. }, scene?: Nullable<Scene>): Mesh;
  58898. }
  58899. }
  58900. declare module BABYLON {
  58901. /**
  58902. * Class containing static functions to help procedurally build meshes
  58903. */
  58904. export class ShapeBuilder {
  58905. /**
  58906. * 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.
  58907. * * 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.
  58908. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58909. * * 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.
  58910. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58911. * * 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
  58912. * * 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
  58913. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58915. * * 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
  58916. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58918. * @param name defines the name of the mesh
  58919. * @param options defines the options used to create the mesh
  58920. * @param scene defines the hosting scene
  58921. * @returns the extruded shape mesh
  58922. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58924. */
  58925. static ExtrudeShape(name: string, options: {
  58926. shape: Vector3[];
  58927. path: Vector3[];
  58928. scale?: number;
  58929. rotation?: number;
  58930. cap?: number;
  58931. updatable?: boolean;
  58932. sideOrientation?: number;
  58933. frontUVs?: Vector4;
  58934. backUVs?: Vector4;
  58935. instance?: Mesh;
  58936. invertUV?: boolean;
  58937. }, scene?: Nullable<Scene>): Mesh;
  58938. /**
  58939. * Creates an custom extruded shape mesh.
  58940. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58941. * * 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.
  58942. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58943. * * 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
  58944. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58945. * * 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
  58946. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58947. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58948. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58949. * * 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
  58950. * * 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
  58951. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58953. * * 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
  58954. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58956. * @param name defines the name of the mesh
  58957. * @param options defines the options used to create the mesh
  58958. * @param scene defines the hosting scene
  58959. * @returns the custom extruded shape mesh
  58960. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58961. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58962. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58963. */
  58964. static ExtrudeShapeCustom(name: string, options: {
  58965. shape: Vector3[];
  58966. path: Vector3[];
  58967. scaleFunction?: any;
  58968. rotationFunction?: any;
  58969. ribbonCloseArray?: boolean;
  58970. ribbonClosePath?: boolean;
  58971. cap?: number;
  58972. updatable?: boolean;
  58973. sideOrientation?: number;
  58974. frontUVs?: Vector4;
  58975. backUVs?: Vector4;
  58976. instance?: Mesh;
  58977. invertUV?: boolean;
  58978. }, scene?: Nullable<Scene>): Mesh;
  58979. private static _ExtrudeShapeGeneric;
  58980. }
  58981. }
  58982. declare module BABYLON {
  58983. /**
  58984. * AmmoJS Physics plugin
  58985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58986. * @see https://github.com/kripken/ammo.js/
  58987. */
  58988. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58989. private _useDeltaForWorldStep;
  58990. /**
  58991. * Reference to the Ammo library
  58992. */
  58993. bjsAMMO: any;
  58994. /**
  58995. * Created ammoJS world which physics bodies are added to
  58996. */
  58997. world: any;
  58998. /**
  58999. * Name of the plugin
  59000. */
  59001. name: string;
  59002. private _timeStep;
  59003. private _fixedTimeStep;
  59004. private _maxSteps;
  59005. private _tmpQuaternion;
  59006. private _tmpAmmoTransform;
  59007. private _tmpAmmoQuaternion;
  59008. private _tmpAmmoConcreteContactResultCallback;
  59009. private _collisionConfiguration;
  59010. private _dispatcher;
  59011. private _overlappingPairCache;
  59012. private _solver;
  59013. private _softBodySolver;
  59014. private _tmpAmmoVectorA;
  59015. private _tmpAmmoVectorB;
  59016. private _tmpAmmoVectorC;
  59017. private _tmpAmmoVectorD;
  59018. private _tmpContactCallbackResult;
  59019. private _tmpAmmoVectorRCA;
  59020. private _tmpAmmoVectorRCB;
  59021. private _raycastResult;
  59022. private static readonly DISABLE_COLLISION_FLAG;
  59023. private static readonly KINEMATIC_FLAG;
  59024. private static readonly DISABLE_DEACTIVATION_FLAG;
  59025. /**
  59026. * Initializes the ammoJS plugin
  59027. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59028. * @param ammoInjection can be used to inject your own ammo reference
  59029. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59030. */
  59031. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59032. /**
  59033. * Sets the gravity of the physics world (m/(s^2))
  59034. * @param gravity Gravity to set
  59035. */
  59036. setGravity(gravity: Vector3): void;
  59037. /**
  59038. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59039. * @param timeStep timestep to use in seconds
  59040. */
  59041. setTimeStep(timeStep: number): void;
  59042. /**
  59043. * 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)
  59044. * @param fixedTimeStep fixedTimeStep to use in seconds
  59045. */
  59046. setFixedTimeStep(fixedTimeStep: number): void;
  59047. /**
  59048. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59049. * @param maxSteps the maximum number of steps by the physics engine per frame
  59050. */
  59051. setMaxSteps(maxSteps: number): void;
  59052. /**
  59053. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59054. * @returns the current timestep in seconds
  59055. */
  59056. getTimeStep(): number;
  59057. /**
  59058. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59059. */
  59060. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59061. private _isImpostorInContact;
  59062. private _isImpostorPairInContact;
  59063. private _stepSimulation;
  59064. /**
  59065. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59066. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59067. * After the step the babylon meshes are set to the position of the physics imposters
  59068. * @param delta amount of time to step forward
  59069. * @param impostors array of imposters to update before/after the step
  59070. */
  59071. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59072. /**
  59073. * Update babylon mesh to match physics world object
  59074. * @param impostor imposter to match
  59075. */
  59076. private _afterSoftStep;
  59077. /**
  59078. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59079. * @param impostor imposter to match
  59080. */
  59081. private _ropeStep;
  59082. /**
  59083. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59084. * @param impostor imposter to match
  59085. */
  59086. private _softbodyOrClothStep;
  59087. private _tmpMatrix;
  59088. /**
  59089. * Applies an impulse on the imposter
  59090. * @param impostor imposter to apply impulse to
  59091. * @param force amount of force to be applied to the imposter
  59092. * @param contactPoint the location to apply the impulse on the imposter
  59093. */
  59094. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59095. /**
  59096. * Applies a force on the imposter
  59097. * @param impostor imposter to apply force
  59098. * @param force amount of force to be applied to the imposter
  59099. * @param contactPoint the location to apply the force on the imposter
  59100. */
  59101. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59102. /**
  59103. * Creates a physics body using the plugin
  59104. * @param impostor the imposter to create the physics body on
  59105. */
  59106. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59107. /**
  59108. * Removes the physics body from the imposter and disposes of the body's memory
  59109. * @param impostor imposter to remove the physics body from
  59110. */
  59111. removePhysicsBody(impostor: PhysicsImpostor): void;
  59112. /**
  59113. * Generates a joint
  59114. * @param impostorJoint the imposter joint to create the joint with
  59115. */
  59116. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59117. /**
  59118. * Removes a joint
  59119. * @param impostorJoint the imposter joint to remove the joint from
  59120. */
  59121. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59122. private _addMeshVerts;
  59123. /**
  59124. * Initialise the soft body vertices to match its object's (mesh) vertices
  59125. * Softbody vertices (nodes) are in world space and to match this
  59126. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59127. * @param impostor to create the softbody for
  59128. */
  59129. private _softVertexData;
  59130. /**
  59131. * Create an impostor's soft body
  59132. * @param impostor to create the softbody for
  59133. */
  59134. private _createSoftbody;
  59135. /**
  59136. * Create cloth for an impostor
  59137. * @param impostor to create the softbody for
  59138. */
  59139. private _createCloth;
  59140. /**
  59141. * Create rope for an impostor
  59142. * @param impostor to create the softbody for
  59143. */
  59144. private _createRope;
  59145. /**
  59146. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59147. * @param impostor to create the custom physics shape for
  59148. */
  59149. private _createCustom;
  59150. private _addHullVerts;
  59151. private _createShape;
  59152. /**
  59153. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59154. * @param impostor imposter containing the physics body and babylon object
  59155. */
  59156. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59157. /**
  59158. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59159. * @param impostor imposter containing the physics body and babylon object
  59160. * @param newPosition new position
  59161. * @param newRotation new rotation
  59162. */
  59163. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59164. /**
  59165. * If this plugin is supported
  59166. * @returns true if its supported
  59167. */
  59168. isSupported(): boolean;
  59169. /**
  59170. * Sets the linear velocity of the physics body
  59171. * @param impostor imposter to set the velocity on
  59172. * @param velocity velocity to set
  59173. */
  59174. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59175. /**
  59176. * Sets the angular velocity of the physics body
  59177. * @param impostor imposter to set the velocity on
  59178. * @param velocity velocity to set
  59179. */
  59180. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59181. /**
  59182. * gets the linear velocity
  59183. * @param impostor imposter to get linear velocity from
  59184. * @returns linear velocity
  59185. */
  59186. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59187. /**
  59188. * gets the angular velocity
  59189. * @param impostor imposter to get angular velocity from
  59190. * @returns angular velocity
  59191. */
  59192. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59193. /**
  59194. * Sets the mass of physics body
  59195. * @param impostor imposter to set the mass on
  59196. * @param mass mass to set
  59197. */
  59198. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59199. /**
  59200. * Gets the mass of the physics body
  59201. * @param impostor imposter to get the mass from
  59202. * @returns mass
  59203. */
  59204. getBodyMass(impostor: PhysicsImpostor): number;
  59205. /**
  59206. * Gets friction of the impostor
  59207. * @param impostor impostor to get friction from
  59208. * @returns friction value
  59209. */
  59210. getBodyFriction(impostor: PhysicsImpostor): number;
  59211. /**
  59212. * Sets friction of the impostor
  59213. * @param impostor impostor to set friction on
  59214. * @param friction friction value
  59215. */
  59216. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59217. /**
  59218. * Gets restitution of the impostor
  59219. * @param impostor impostor to get restitution from
  59220. * @returns restitution value
  59221. */
  59222. getBodyRestitution(impostor: PhysicsImpostor): number;
  59223. /**
  59224. * Sets resitution of the impostor
  59225. * @param impostor impostor to set resitution on
  59226. * @param restitution resitution value
  59227. */
  59228. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59229. /**
  59230. * Gets pressure inside the impostor
  59231. * @param impostor impostor to get pressure from
  59232. * @returns pressure value
  59233. */
  59234. getBodyPressure(impostor: PhysicsImpostor): number;
  59235. /**
  59236. * Sets pressure inside a soft body impostor
  59237. * Cloth and rope must remain 0 pressure
  59238. * @param impostor impostor to set pressure on
  59239. * @param pressure pressure value
  59240. */
  59241. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59242. /**
  59243. * Gets stiffness of the impostor
  59244. * @param impostor impostor to get stiffness from
  59245. * @returns pressure value
  59246. */
  59247. getBodyStiffness(impostor: PhysicsImpostor): number;
  59248. /**
  59249. * Sets stiffness of the impostor
  59250. * @param impostor impostor to set stiffness on
  59251. * @param stiffness stiffness value from 0 to 1
  59252. */
  59253. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59254. /**
  59255. * Gets velocityIterations of the impostor
  59256. * @param impostor impostor to get velocity iterations from
  59257. * @returns velocityIterations value
  59258. */
  59259. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59260. /**
  59261. * Sets velocityIterations of the impostor
  59262. * @param impostor impostor to set velocity iterations on
  59263. * @param velocityIterations velocityIterations value
  59264. */
  59265. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59266. /**
  59267. * Gets positionIterations of the impostor
  59268. * @param impostor impostor to get position iterations from
  59269. * @returns positionIterations value
  59270. */
  59271. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59272. /**
  59273. * Sets positionIterations of the impostor
  59274. * @param impostor impostor to set position on
  59275. * @param positionIterations positionIterations value
  59276. */
  59277. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59278. /**
  59279. * Append an anchor to a cloth object
  59280. * @param impostor is the cloth impostor to add anchor to
  59281. * @param otherImpostor is the rigid impostor to anchor to
  59282. * @param width ratio across width from 0 to 1
  59283. * @param height ratio up height from 0 to 1
  59284. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59285. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59286. */
  59287. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59288. /**
  59289. * Append an hook to a rope object
  59290. * @param impostor is the rope impostor to add hook to
  59291. * @param otherImpostor is the rigid impostor to hook to
  59292. * @param length ratio along the rope from 0 to 1
  59293. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59294. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59295. */
  59296. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59297. /**
  59298. * Sleeps the physics body and stops it from being active
  59299. * @param impostor impostor to sleep
  59300. */
  59301. sleepBody(impostor: PhysicsImpostor): void;
  59302. /**
  59303. * Activates the physics body
  59304. * @param impostor impostor to activate
  59305. */
  59306. wakeUpBody(impostor: PhysicsImpostor): void;
  59307. /**
  59308. * Updates the distance parameters of the joint
  59309. * @param joint joint to update
  59310. * @param maxDistance maximum distance of the joint
  59311. * @param minDistance minimum distance of the joint
  59312. */
  59313. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59314. /**
  59315. * Sets a motor on the joint
  59316. * @param joint joint to set motor on
  59317. * @param speed speed of the motor
  59318. * @param maxForce maximum force of the motor
  59319. * @param motorIndex index of the motor
  59320. */
  59321. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59322. /**
  59323. * Sets the motors limit
  59324. * @param joint joint to set limit on
  59325. * @param upperLimit upper limit
  59326. * @param lowerLimit lower limit
  59327. */
  59328. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59329. /**
  59330. * Syncs the position and rotation of a mesh with the impostor
  59331. * @param mesh mesh to sync
  59332. * @param impostor impostor to update the mesh with
  59333. */
  59334. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59335. /**
  59336. * Gets the radius of the impostor
  59337. * @param impostor impostor to get radius from
  59338. * @returns the radius
  59339. */
  59340. getRadius(impostor: PhysicsImpostor): number;
  59341. /**
  59342. * Gets the box size of the impostor
  59343. * @param impostor impostor to get box size from
  59344. * @param result the resulting box size
  59345. */
  59346. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59347. /**
  59348. * Disposes of the impostor
  59349. */
  59350. dispose(): void;
  59351. /**
  59352. * Does a raycast in the physics world
  59353. * @param from when should the ray start?
  59354. * @param to when should the ray end?
  59355. * @returns PhysicsRaycastResult
  59356. */
  59357. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59358. }
  59359. }
  59360. declare module BABYLON {
  59361. interface AbstractScene {
  59362. /**
  59363. * The list of reflection probes added to the scene
  59364. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59365. */
  59366. reflectionProbes: Array<ReflectionProbe>;
  59367. /**
  59368. * Removes the given reflection probe from this scene.
  59369. * @param toRemove The reflection probe to remove
  59370. * @returns The index of the removed reflection probe
  59371. */
  59372. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59373. /**
  59374. * Adds the given reflection probe to this scene.
  59375. * @param newReflectionProbe The reflection probe to add
  59376. */
  59377. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59378. }
  59379. /**
  59380. * Class used to generate realtime reflection / refraction cube textures
  59381. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59382. */
  59383. export class ReflectionProbe {
  59384. /** defines the name of the probe */
  59385. name: string;
  59386. private _scene;
  59387. private _renderTargetTexture;
  59388. private _projectionMatrix;
  59389. private _viewMatrix;
  59390. private _target;
  59391. private _add;
  59392. private _attachedMesh;
  59393. private _invertYAxis;
  59394. /** Gets or sets probe position (center of the cube map) */
  59395. position: Vector3;
  59396. /**
  59397. * Creates a new reflection probe
  59398. * @param name defines the name of the probe
  59399. * @param size defines the texture resolution (for each face)
  59400. * @param scene defines the hosting scene
  59401. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59402. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59403. */
  59404. constructor(
  59405. /** defines the name of the probe */
  59406. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59407. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59408. get samples(): number;
  59409. set samples(value: number);
  59410. /** Gets or sets the refresh rate to use (on every frame by default) */
  59411. get refreshRate(): number;
  59412. set refreshRate(value: number);
  59413. /**
  59414. * Gets the hosting scene
  59415. * @returns a Scene
  59416. */
  59417. getScene(): Scene;
  59418. /** Gets the internal CubeTexture used to render to */
  59419. get cubeTexture(): RenderTargetTexture;
  59420. /** Gets the list of meshes to render */
  59421. get renderList(): Nullable<AbstractMesh[]>;
  59422. /**
  59423. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59424. * @param mesh defines the mesh to attach to
  59425. */
  59426. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59427. /**
  59428. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59429. * @param renderingGroupId The rendering group id corresponding to its index
  59430. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59431. */
  59432. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59433. /**
  59434. * Clean all associated resources
  59435. */
  59436. dispose(): void;
  59437. /**
  59438. * Converts the reflection probe information to a readable string for debug purpose.
  59439. * @param fullDetails Supports for multiple levels of logging within scene loading
  59440. * @returns the human readable reflection probe info
  59441. */
  59442. toString(fullDetails?: boolean): string;
  59443. /**
  59444. * Get the class name of the relfection probe.
  59445. * @returns "ReflectionProbe"
  59446. */
  59447. getClassName(): string;
  59448. /**
  59449. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59450. * @returns The JSON representation of the texture
  59451. */
  59452. serialize(): any;
  59453. /**
  59454. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59455. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59456. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59457. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59458. * @returns The parsed reflection probe if successful
  59459. */
  59460. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59461. }
  59462. }
  59463. declare module BABYLON {
  59464. /** @hidden */
  59465. export var _BabylonLoaderRegistered: boolean;
  59466. /**
  59467. * Helps setting up some configuration for the babylon file loader.
  59468. */
  59469. export class BabylonFileLoaderConfiguration {
  59470. /**
  59471. * The loader does not allow injecting custom physix engine into the plugins.
  59472. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59473. * So you could set this variable to your engine import to make it work.
  59474. */
  59475. static LoaderInjectedPhysicsEngine: any;
  59476. }
  59477. }
  59478. declare module BABYLON {
  59479. /**
  59480. * The Physically based simple base material of BJS.
  59481. *
  59482. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59483. * It is used as the base class for both the specGloss and metalRough conventions.
  59484. */
  59485. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59486. /**
  59487. * Number of Simultaneous lights allowed on the material.
  59488. */
  59489. maxSimultaneousLights: number;
  59490. /**
  59491. * If sets to true, disables all the lights affecting the material.
  59492. */
  59493. disableLighting: boolean;
  59494. /**
  59495. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59496. */
  59497. environmentTexture: BaseTexture;
  59498. /**
  59499. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59500. */
  59501. invertNormalMapX: boolean;
  59502. /**
  59503. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59504. */
  59505. invertNormalMapY: boolean;
  59506. /**
  59507. * Normal map used in the model.
  59508. */
  59509. normalTexture: BaseTexture;
  59510. /**
  59511. * Emissivie color used to self-illuminate the model.
  59512. */
  59513. emissiveColor: Color3;
  59514. /**
  59515. * Emissivie texture used to self-illuminate the model.
  59516. */
  59517. emissiveTexture: BaseTexture;
  59518. /**
  59519. * Occlusion Channel Strenght.
  59520. */
  59521. occlusionStrength: number;
  59522. /**
  59523. * Occlusion Texture of the material (adding extra occlusion effects).
  59524. */
  59525. occlusionTexture: BaseTexture;
  59526. /**
  59527. * Defines the alpha limits in alpha test mode.
  59528. */
  59529. alphaCutOff: number;
  59530. /**
  59531. * Gets the current double sided mode.
  59532. */
  59533. get doubleSided(): boolean;
  59534. /**
  59535. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59536. */
  59537. set doubleSided(value: boolean);
  59538. /**
  59539. * Stores the pre-calculated light information of a mesh in a texture.
  59540. */
  59541. lightmapTexture: BaseTexture;
  59542. /**
  59543. * If true, the light map contains occlusion information instead of lighting info.
  59544. */
  59545. useLightmapAsShadowmap: boolean;
  59546. /**
  59547. * Instantiates a new PBRMaterial instance.
  59548. *
  59549. * @param name The material name
  59550. * @param scene The scene the material will be use in.
  59551. */
  59552. constructor(name: string, scene: Scene);
  59553. getClassName(): string;
  59554. }
  59555. }
  59556. declare module BABYLON {
  59557. /**
  59558. * The PBR material of BJS following the metal roughness convention.
  59559. *
  59560. * This fits to the PBR convention in the GLTF definition:
  59561. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59562. */
  59563. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59564. /**
  59565. * The base color has two different interpretations depending on the value of metalness.
  59566. * When the material is a metal, the base color is the specific measured reflectance value
  59567. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59568. * of the material.
  59569. */
  59570. baseColor: Color3;
  59571. /**
  59572. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59573. * well as opacity information in the alpha channel.
  59574. */
  59575. baseTexture: BaseTexture;
  59576. /**
  59577. * Specifies the metallic scalar value of the material.
  59578. * Can also be used to scale the metalness values of the metallic texture.
  59579. */
  59580. metallic: number;
  59581. /**
  59582. * Specifies the roughness scalar value of the material.
  59583. * Can also be used to scale the roughness values of the metallic texture.
  59584. */
  59585. roughness: number;
  59586. /**
  59587. * Texture containing both the metallic value in the B channel and the
  59588. * roughness value in the G channel to keep better precision.
  59589. */
  59590. metallicRoughnessTexture: BaseTexture;
  59591. /**
  59592. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59593. *
  59594. * @param name The material name
  59595. * @param scene The scene the material will be use in.
  59596. */
  59597. constructor(name: string, scene: Scene);
  59598. /**
  59599. * Return the currrent class name of the material.
  59600. */
  59601. getClassName(): string;
  59602. /**
  59603. * Makes a duplicate of the current material.
  59604. * @param name - name to use for the new material.
  59605. */
  59606. clone(name: string): PBRMetallicRoughnessMaterial;
  59607. /**
  59608. * Serialize the material to a parsable JSON object.
  59609. */
  59610. serialize(): any;
  59611. /**
  59612. * Parses a JSON object correponding to the serialize function.
  59613. */
  59614. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59615. }
  59616. }
  59617. declare module BABYLON {
  59618. /**
  59619. * The PBR material of BJS following the specular glossiness convention.
  59620. *
  59621. * This fits to the PBR convention in the GLTF definition:
  59622. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59623. */
  59624. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59625. /**
  59626. * Specifies the diffuse color of the material.
  59627. */
  59628. diffuseColor: Color3;
  59629. /**
  59630. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59631. * channel.
  59632. */
  59633. diffuseTexture: BaseTexture;
  59634. /**
  59635. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59636. */
  59637. specularColor: Color3;
  59638. /**
  59639. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59640. */
  59641. glossiness: number;
  59642. /**
  59643. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59644. */
  59645. specularGlossinessTexture: BaseTexture;
  59646. /**
  59647. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59648. *
  59649. * @param name The material name
  59650. * @param scene The scene the material will be use in.
  59651. */
  59652. constructor(name: string, scene: Scene);
  59653. /**
  59654. * Return the currrent class name of the material.
  59655. */
  59656. getClassName(): string;
  59657. /**
  59658. * Makes a duplicate of the current material.
  59659. * @param name - name to use for the new material.
  59660. */
  59661. clone(name: string): PBRSpecularGlossinessMaterial;
  59662. /**
  59663. * Serialize the material to a parsable JSON object.
  59664. */
  59665. serialize(): any;
  59666. /**
  59667. * Parses a JSON object correponding to the serialize function.
  59668. */
  59669. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59670. }
  59671. }
  59672. declare module BABYLON {
  59673. /**
  59674. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59675. * It can help converting any input color in a desired output one. This can then be used to create effects
  59676. * from sepia, black and white to sixties or futuristic rendering...
  59677. *
  59678. * The only supported format is currently 3dl.
  59679. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59680. */
  59681. export class ColorGradingTexture extends BaseTexture {
  59682. /**
  59683. * The texture URL.
  59684. */
  59685. url: string;
  59686. /**
  59687. * Empty line regex stored for GC.
  59688. */
  59689. private static _noneEmptyLineRegex;
  59690. private _textureMatrix;
  59691. private _onLoad;
  59692. /**
  59693. * Instantiates a ColorGradingTexture from the following parameters.
  59694. *
  59695. * @param url The location of the color gradind data (currently only supporting 3dl)
  59696. * @param sceneOrEngine The scene or engine the texture will be used in
  59697. * @param onLoad defines a callback triggered when the texture has been loaded
  59698. */
  59699. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59700. /**
  59701. * Fires the onload event from the constructor if requested.
  59702. */
  59703. private _triggerOnLoad;
  59704. /**
  59705. * Returns the texture matrix used in most of the material.
  59706. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59707. */
  59708. getTextureMatrix(): Matrix;
  59709. /**
  59710. * Occurs when the file being loaded is a .3dl LUT file.
  59711. */
  59712. private load3dlTexture;
  59713. /**
  59714. * Starts the loading process of the texture.
  59715. */
  59716. private loadTexture;
  59717. /**
  59718. * Clones the color gradind texture.
  59719. */
  59720. clone(): ColorGradingTexture;
  59721. /**
  59722. * Called during delayed load for textures.
  59723. */
  59724. delayLoad(): void;
  59725. /**
  59726. * Parses a color grading texture serialized by Babylon.
  59727. * @param parsedTexture The texture information being parsedTexture
  59728. * @param scene The scene to load the texture in
  59729. * @param rootUrl The root url of the data assets to load
  59730. * @return A color gradind texture
  59731. */
  59732. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59733. /**
  59734. * Serializes the LUT texture to json format.
  59735. */
  59736. serialize(): any;
  59737. }
  59738. }
  59739. declare module BABYLON {
  59740. /**
  59741. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59742. */
  59743. export class EquiRectangularCubeTexture extends BaseTexture {
  59744. /** The six faces of the cube. */
  59745. private static _FacesMapping;
  59746. private _noMipmap;
  59747. private _onLoad;
  59748. private _onError;
  59749. /** The size of the cubemap. */
  59750. private _size;
  59751. /** The buffer of the image. */
  59752. private _buffer;
  59753. /** The width of the input image. */
  59754. private _width;
  59755. /** The height of the input image. */
  59756. private _height;
  59757. /** The URL to the image. */
  59758. url: string;
  59759. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59760. coordinatesMode: number;
  59761. /**
  59762. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59763. * @param url The location of the image
  59764. * @param scene The scene the texture will be used in
  59765. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59766. * @param noMipmap Forces to not generate the mipmap if true
  59767. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59768. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59769. * @param onLoad — defines a callback called when texture is loaded
  59770. * @param onError — defines a callback called if there is an error
  59771. */
  59772. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59773. /**
  59774. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59775. */
  59776. private loadImage;
  59777. /**
  59778. * Convert the image buffer into a cubemap and create a CubeTexture.
  59779. */
  59780. private loadTexture;
  59781. /**
  59782. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59783. * @param buffer The ArrayBuffer that should be converted.
  59784. * @returns The buffer as Float32Array.
  59785. */
  59786. private getFloat32ArrayFromArrayBuffer;
  59787. /**
  59788. * Get the current class name of the texture useful for serialization or dynamic coding.
  59789. * @returns "EquiRectangularCubeTexture"
  59790. */
  59791. getClassName(): string;
  59792. /**
  59793. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59794. * @returns A clone of the current EquiRectangularCubeTexture.
  59795. */
  59796. clone(): EquiRectangularCubeTexture;
  59797. }
  59798. }
  59799. declare module BABYLON {
  59800. /**
  59801. * Defines the options related to the creation of an HtmlElementTexture
  59802. */
  59803. export interface IHtmlElementTextureOptions {
  59804. /**
  59805. * Defines wether mip maps should be created or not.
  59806. */
  59807. generateMipMaps?: boolean;
  59808. /**
  59809. * Defines the sampling mode of the texture.
  59810. */
  59811. samplingMode?: number;
  59812. /**
  59813. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59814. */
  59815. engine: Nullable<ThinEngine>;
  59816. /**
  59817. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59818. */
  59819. scene: Nullable<Scene>;
  59820. }
  59821. /**
  59822. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59823. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59824. * is automatically managed.
  59825. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59826. * in your application.
  59827. *
  59828. * As the update is not automatic, you need to call them manually.
  59829. */
  59830. export class HtmlElementTexture extends BaseTexture {
  59831. /**
  59832. * The texture URL.
  59833. */
  59834. element: HTMLVideoElement | HTMLCanvasElement;
  59835. private static readonly DefaultOptions;
  59836. private _textureMatrix;
  59837. private _isVideo;
  59838. private _generateMipMaps;
  59839. private _samplingMode;
  59840. /**
  59841. * Instantiates a HtmlElementTexture from the following parameters.
  59842. *
  59843. * @param name Defines the name of the texture
  59844. * @param element Defines the video or canvas the texture is filled with
  59845. * @param options Defines the other none mandatory texture creation options
  59846. */
  59847. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59848. private _createInternalTexture;
  59849. /**
  59850. * Returns the texture matrix used in most of the material.
  59851. */
  59852. getTextureMatrix(): Matrix;
  59853. /**
  59854. * Updates the content of the texture.
  59855. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59856. */
  59857. update(invertY?: Nullable<boolean>): void;
  59858. }
  59859. }
  59860. declare module BABYLON {
  59861. /**
  59862. * Based on jsTGALoader - Javascript loader for TGA file
  59863. * By Vincent Thibault
  59864. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59865. */
  59866. export class TGATools {
  59867. private static _TYPE_INDEXED;
  59868. private static _TYPE_RGB;
  59869. private static _TYPE_GREY;
  59870. private static _TYPE_RLE_INDEXED;
  59871. private static _TYPE_RLE_RGB;
  59872. private static _TYPE_RLE_GREY;
  59873. private static _ORIGIN_MASK;
  59874. private static _ORIGIN_SHIFT;
  59875. private static _ORIGIN_BL;
  59876. private static _ORIGIN_BR;
  59877. private static _ORIGIN_UL;
  59878. private static _ORIGIN_UR;
  59879. /**
  59880. * Gets the header of a TGA file
  59881. * @param data defines the TGA data
  59882. * @returns the header
  59883. */
  59884. static GetTGAHeader(data: Uint8Array): any;
  59885. /**
  59886. * Uploads TGA content to a Babylon Texture
  59887. * @hidden
  59888. */
  59889. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59890. /** @hidden */
  59891. 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;
  59892. /** @hidden */
  59893. 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;
  59894. /** @hidden */
  59895. 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;
  59896. /** @hidden */
  59897. 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;
  59898. /** @hidden */
  59899. 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;
  59900. /** @hidden */
  59901. 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;
  59902. }
  59903. }
  59904. declare module BABYLON {
  59905. /**
  59906. * Implementation of the TGA Texture Loader.
  59907. * @hidden
  59908. */
  59909. export class _TGATextureLoader implements IInternalTextureLoader {
  59910. /**
  59911. * Defines wether the loader supports cascade loading the different faces.
  59912. */
  59913. readonly supportCascades: boolean;
  59914. /**
  59915. * This returns if the loader support the current file information.
  59916. * @param extension defines the file extension of the file being loaded
  59917. * @returns true if the loader can load the specified file
  59918. */
  59919. canLoad(extension: string): boolean;
  59920. /**
  59921. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59922. * @param data contains the texture data
  59923. * @param texture defines the BabylonJS internal texture
  59924. * @param createPolynomials will be true if polynomials have been requested
  59925. * @param onLoad defines the callback to trigger once the texture is ready
  59926. * @param onError defines the callback to trigger in case of error
  59927. */
  59928. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59929. /**
  59930. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59931. * @param data contains the texture data
  59932. * @param texture defines the BabylonJS internal texture
  59933. * @param callback defines the method to call once ready to upload
  59934. */
  59935. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59936. }
  59937. }
  59938. declare module BABYLON {
  59939. /**
  59940. * Info about the .basis files
  59941. */
  59942. class BasisFileInfo {
  59943. /**
  59944. * If the file has alpha
  59945. */
  59946. hasAlpha: boolean;
  59947. /**
  59948. * Info about each image of the basis file
  59949. */
  59950. images: Array<{
  59951. levels: Array<{
  59952. width: number;
  59953. height: number;
  59954. transcodedPixels: ArrayBufferView;
  59955. }>;
  59956. }>;
  59957. }
  59958. /**
  59959. * Result of transcoding a basis file
  59960. */
  59961. class TranscodeResult {
  59962. /**
  59963. * Info about the .basis file
  59964. */
  59965. fileInfo: BasisFileInfo;
  59966. /**
  59967. * Format to use when loading the file
  59968. */
  59969. format: number;
  59970. }
  59971. /**
  59972. * Configuration options for the Basis transcoder
  59973. */
  59974. export class BasisTranscodeConfiguration {
  59975. /**
  59976. * Supported compression formats used to determine the supported output format of the transcoder
  59977. */
  59978. supportedCompressionFormats?: {
  59979. /**
  59980. * etc1 compression format
  59981. */
  59982. etc1?: boolean;
  59983. /**
  59984. * s3tc compression format
  59985. */
  59986. s3tc?: boolean;
  59987. /**
  59988. * pvrtc compression format
  59989. */
  59990. pvrtc?: boolean;
  59991. /**
  59992. * etc2 compression format
  59993. */
  59994. etc2?: boolean;
  59995. };
  59996. /**
  59997. * If mipmap levels should be loaded for transcoded images (Default: true)
  59998. */
  59999. loadMipmapLevels?: boolean;
  60000. /**
  60001. * Index of a single image to load (Default: all images)
  60002. */
  60003. loadSingleImage?: number;
  60004. }
  60005. /**
  60006. * Used to load .Basis files
  60007. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60008. */
  60009. export class BasisTools {
  60010. private static _IgnoreSupportedFormats;
  60011. /**
  60012. * URL to use when loading the basis transcoder
  60013. */
  60014. static JSModuleURL: string;
  60015. /**
  60016. * URL to use when loading the wasm module for the transcoder
  60017. */
  60018. static WasmModuleURL: string;
  60019. /**
  60020. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60021. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60022. * @returns internal format corresponding to the Basis format
  60023. */
  60024. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60025. private static _WorkerPromise;
  60026. private static _Worker;
  60027. private static _actionId;
  60028. private static _CreateWorkerAsync;
  60029. /**
  60030. * Transcodes a loaded image file to compressed pixel data
  60031. * @param data image data to transcode
  60032. * @param config configuration options for the transcoding
  60033. * @returns a promise resulting in the transcoded image
  60034. */
  60035. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60036. /**
  60037. * Loads a texture from the transcode result
  60038. * @param texture texture load to
  60039. * @param transcodeResult the result of transcoding the basis file to load from
  60040. */
  60041. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60042. }
  60043. }
  60044. declare module BABYLON {
  60045. /**
  60046. * Loader for .basis file format
  60047. */
  60048. export class _BasisTextureLoader implements IInternalTextureLoader {
  60049. /**
  60050. * Defines whether the loader supports cascade loading the different faces.
  60051. */
  60052. readonly supportCascades: boolean;
  60053. /**
  60054. * This returns if the loader support the current file information.
  60055. * @param extension defines the file extension of the file being loaded
  60056. * @returns true if the loader can load the specified file
  60057. */
  60058. canLoad(extension: string): boolean;
  60059. /**
  60060. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60061. * @param data contains the texture data
  60062. * @param texture defines the BabylonJS internal texture
  60063. * @param createPolynomials will be true if polynomials have been requested
  60064. * @param onLoad defines the callback to trigger once the texture is ready
  60065. * @param onError defines the callback to trigger in case of error
  60066. */
  60067. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60068. /**
  60069. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60070. * @param data contains the texture data
  60071. * @param texture defines the BabylonJS internal texture
  60072. * @param callback defines the method to call once ready to upload
  60073. */
  60074. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60075. }
  60076. }
  60077. declare module BABYLON {
  60078. /**
  60079. * Defines the basic options interface of a TexturePacker Frame
  60080. */
  60081. export interface ITexturePackerFrame {
  60082. /**
  60083. * The frame ID
  60084. */
  60085. id: number;
  60086. /**
  60087. * The frames Scale
  60088. */
  60089. scale: Vector2;
  60090. /**
  60091. * The Frames offset
  60092. */
  60093. offset: Vector2;
  60094. }
  60095. /**
  60096. * This is a support class for frame Data on texture packer sets.
  60097. */
  60098. export class TexturePackerFrame implements ITexturePackerFrame {
  60099. /**
  60100. * The frame ID
  60101. */
  60102. id: number;
  60103. /**
  60104. * The frames Scale
  60105. */
  60106. scale: Vector2;
  60107. /**
  60108. * The Frames offset
  60109. */
  60110. offset: Vector2;
  60111. /**
  60112. * Initializes a texture package frame.
  60113. * @param id The numerical frame identifier
  60114. * @param scale Scalar Vector2 for UV frame
  60115. * @param offset Vector2 for the frame position in UV units.
  60116. * @returns TexturePackerFrame
  60117. */
  60118. constructor(id: number, scale: Vector2, offset: Vector2);
  60119. }
  60120. }
  60121. declare module BABYLON {
  60122. /**
  60123. * Defines the basic options interface of a TexturePacker
  60124. */
  60125. export interface ITexturePackerOptions {
  60126. /**
  60127. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60128. */
  60129. map?: string[];
  60130. /**
  60131. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60132. */
  60133. uvsIn?: string;
  60134. /**
  60135. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60136. */
  60137. uvsOut?: string;
  60138. /**
  60139. * number representing the layout style. Defaults to LAYOUT_STRIP
  60140. */
  60141. layout?: number;
  60142. /**
  60143. * number of columns if using custom column count layout(2). This defaults to 4.
  60144. */
  60145. colnum?: number;
  60146. /**
  60147. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60148. */
  60149. updateInputMeshes?: boolean;
  60150. /**
  60151. * boolean flag to dispose all the source textures. Defaults to true.
  60152. */
  60153. disposeSources?: boolean;
  60154. /**
  60155. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60156. */
  60157. fillBlanks?: boolean;
  60158. /**
  60159. * string value representing the context fill style color. Defaults to 'black'.
  60160. */
  60161. customFillColor?: string;
  60162. /**
  60163. * Width and Height Value of each Frame in the TexturePacker Sets
  60164. */
  60165. frameSize?: number;
  60166. /**
  60167. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60168. */
  60169. paddingRatio?: number;
  60170. /**
  60171. * Number that declares the fill method for the padding gutter.
  60172. */
  60173. paddingMode?: number;
  60174. /**
  60175. * If in SUBUV_COLOR padding mode what color to use.
  60176. */
  60177. paddingColor?: Color3 | Color4;
  60178. }
  60179. /**
  60180. * Defines the basic interface of a TexturePacker JSON File
  60181. */
  60182. export interface ITexturePackerJSON {
  60183. /**
  60184. * The frame ID
  60185. */
  60186. name: string;
  60187. /**
  60188. * The base64 channel data
  60189. */
  60190. sets: any;
  60191. /**
  60192. * The options of the Packer
  60193. */
  60194. options: ITexturePackerOptions;
  60195. /**
  60196. * The frame data of the Packer
  60197. */
  60198. frames: Array<number>;
  60199. }
  60200. /**
  60201. * This is a support class that generates a series of packed texture sets.
  60202. * @see https://doc.babylonjs.com/babylon101/materials
  60203. */
  60204. export class TexturePacker {
  60205. /** Packer Layout Constant 0 */
  60206. static readonly LAYOUT_STRIP: number;
  60207. /** Packer Layout Constant 1 */
  60208. static readonly LAYOUT_POWER2: number;
  60209. /** Packer Layout Constant 2 */
  60210. static readonly LAYOUT_COLNUM: number;
  60211. /** Packer Layout Constant 0 */
  60212. static readonly SUBUV_WRAP: number;
  60213. /** Packer Layout Constant 1 */
  60214. static readonly SUBUV_EXTEND: number;
  60215. /** Packer Layout Constant 2 */
  60216. static readonly SUBUV_COLOR: number;
  60217. /** The Name of the Texture Package */
  60218. name: string;
  60219. /** The scene scope of the TexturePacker */
  60220. scene: Scene;
  60221. /** The Meshes to target */
  60222. meshes: AbstractMesh[];
  60223. /** Arguments passed with the Constructor */
  60224. options: ITexturePackerOptions;
  60225. /** The promise that is started upon initialization */
  60226. promise: Nullable<Promise<TexturePacker | string>>;
  60227. /** The Container object for the channel sets that are generated */
  60228. sets: object;
  60229. /** The Container array for the frames that are generated */
  60230. frames: TexturePackerFrame[];
  60231. /** The expected number of textures the system is parsing. */
  60232. private _expecting;
  60233. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60234. private _paddingValue;
  60235. /**
  60236. * Initializes a texture package series from an array of meshes or a single mesh.
  60237. * @param name The name of the package
  60238. * @param meshes The target meshes to compose the package from
  60239. * @param options The arguments that texture packer should follow while building.
  60240. * @param scene The scene which the textures are scoped to.
  60241. * @returns TexturePacker
  60242. */
  60243. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60244. /**
  60245. * Starts the package process
  60246. * @param resolve The promises resolution function
  60247. * @returns TexturePacker
  60248. */
  60249. private _createFrames;
  60250. /**
  60251. * Calculates the Size of the Channel Sets
  60252. * @returns Vector2
  60253. */
  60254. private _calculateSize;
  60255. /**
  60256. * Calculates the UV data for the frames.
  60257. * @param baseSize the base frameSize
  60258. * @param padding the base frame padding
  60259. * @param dtSize size of the Dynamic Texture for that channel
  60260. * @param dtUnits is 1/dtSize
  60261. * @param update flag to update the input meshes
  60262. */
  60263. private _calculateMeshUVFrames;
  60264. /**
  60265. * Calculates the frames Offset.
  60266. * @param index of the frame
  60267. * @returns Vector2
  60268. */
  60269. private _getFrameOffset;
  60270. /**
  60271. * Updates a Mesh to the frame data
  60272. * @param mesh that is the target
  60273. * @param frameID or the frame index
  60274. */
  60275. private _updateMeshUV;
  60276. /**
  60277. * Updates a Meshes materials to use the texture packer channels
  60278. * @param m is the mesh to target
  60279. * @param force all channels on the packer to be set.
  60280. */
  60281. private _updateTextureReferences;
  60282. /**
  60283. * Public method to set a Mesh to a frame
  60284. * @param m that is the target
  60285. * @param frameID or the frame index
  60286. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60287. */
  60288. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60289. /**
  60290. * Starts the async promise to compile the texture packer.
  60291. * @returns Promise<void>
  60292. */
  60293. processAsync(): Promise<void>;
  60294. /**
  60295. * Disposes all textures associated with this packer
  60296. */
  60297. dispose(): void;
  60298. /**
  60299. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60300. * @param imageType is the image type to use.
  60301. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60302. */
  60303. download(imageType?: string, quality?: number): void;
  60304. /**
  60305. * Public method to load a texturePacker JSON file.
  60306. * @param data of the JSON file in string format.
  60307. */
  60308. updateFromJSON(data: string): void;
  60309. }
  60310. }
  60311. declare module BABYLON {
  60312. /**
  60313. * 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.
  60314. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60315. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60316. */
  60317. export class CustomProceduralTexture extends ProceduralTexture {
  60318. private _animate;
  60319. private _time;
  60320. private _config;
  60321. private _texturePath;
  60322. /**
  60323. * Instantiates a new Custom Procedural Texture.
  60324. * 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.
  60325. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60326. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60327. * @param name Define the name of the texture
  60328. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60329. * @param size Define the size of the texture to create
  60330. * @param scene Define the scene the texture belongs to
  60331. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60332. * @param generateMipMaps Define if the texture should creates mip maps or not
  60333. */
  60334. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60335. private _loadJson;
  60336. /**
  60337. * Is the texture ready to be used ? (rendered at least once)
  60338. * @returns true if ready, otherwise, false.
  60339. */
  60340. isReady(): boolean;
  60341. /**
  60342. * Render the texture to its associated render target.
  60343. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60344. */
  60345. render(useCameraPostProcess?: boolean): void;
  60346. /**
  60347. * Update the list of dependant textures samplers in the shader.
  60348. */
  60349. updateTextures(): void;
  60350. /**
  60351. * Update the uniform values of the procedural texture in the shader.
  60352. */
  60353. updateShaderUniforms(): void;
  60354. /**
  60355. * Define if the texture animates or not.
  60356. */
  60357. get animate(): boolean;
  60358. set animate(value: boolean);
  60359. }
  60360. }
  60361. declare module BABYLON {
  60362. /** @hidden */
  60363. export var noisePixelShader: {
  60364. name: string;
  60365. shader: string;
  60366. };
  60367. }
  60368. declare module BABYLON {
  60369. /**
  60370. * Class used to generate noise procedural textures
  60371. */
  60372. export class NoiseProceduralTexture extends ProceduralTexture {
  60373. private _time;
  60374. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60375. brightness: number;
  60376. /** Defines the number of octaves to process */
  60377. octaves: number;
  60378. /** Defines the level of persistence (0.8 by default) */
  60379. persistence: number;
  60380. /** Gets or sets animation speed factor (default is 1) */
  60381. animationSpeedFactor: number;
  60382. /**
  60383. * Creates a new NoiseProceduralTexture
  60384. * @param name defines the name fo the texture
  60385. * @param size defines the size of the texture (default is 256)
  60386. * @param scene defines the hosting scene
  60387. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60388. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60389. */
  60390. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60391. private _updateShaderUniforms;
  60392. protected _getDefines(): string;
  60393. /** Generate the current state of the procedural texture */
  60394. render(useCameraPostProcess?: boolean): void;
  60395. /**
  60396. * Serializes this noise procedural texture
  60397. * @returns a serialized noise procedural texture object
  60398. */
  60399. serialize(): any;
  60400. /**
  60401. * Clone the texture.
  60402. * @returns the cloned texture
  60403. */
  60404. clone(): NoiseProceduralTexture;
  60405. /**
  60406. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60407. * @param parsedTexture defines parsed texture data
  60408. * @param scene defines the current scene
  60409. * @param rootUrl defines the root URL containing noise procedural texture information
  60410. * @returns a parsed NoiseProceduralTexture
  60411. */
  60412. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60413. }
  60414. }
  60415. declare module BABYLON {
  60416. /**
  60417. * Raw cube texture where the raw buffers are passed in
  60418. */
  60419. export class RawCubeTexture extends CubeTexture {
  60420. /**
  60421. * Creates a cube texture where the raw buffers are passed in.
  60422. * @param scene defines the scene the texture is attached to
  60423. * @param data defines the array of data to use to create each face
  60424. * @param size defines the size of the textures
  60425. * @param format defines the format of the data
  60426. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60427. * @param generateMipMaps defines if the engine should generate the mip levels
  60428. * @param invertY defines if data must be stored with Y axis inverted
  60429. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60430. * @param compression defines the compression used (null by default)
  60431. */
  60432. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60433. /**
  60434. * Updates the raw cube texture.
  60435. * @param data defines the data to store
  60436. * @param format defines the data format
  60437. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60438. * @param invertY defines if data must be stored with Y axis inverted
  60439. * @param compression defines the compression used (null by default)
  60440. * @param level defines which level of the texture to update
  60441. */
  60442. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60443. /**
  60444. * Updates a raw cube texture with RGBD encoded data.
  60445. * @param data defines the array of data [mipmap][face] to use to create each face
  60446. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60447. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60448. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60449. * @returns a promsie that resolves when the operation is complete
  60450. */
  60451. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60452. /**
  60453. * Clones the raw cube texture.
  60454. * @return a new cube texture
  60455. */
  60456. clone(): CubeTexture;
  60457. /** @hidden */
  60458. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60459. }
  60460. }
  60461. declare module BABYLON {
  60462. /**
  60463. * Class used to store 2D array textures containing user data
  60464. */
  60465. export class RawTexture2DArray extends Texture {
  60466. /** Gets or sets the texture format to use */
  60467. format: number;
  60468. /**
  60469. * Create a new RawTexture2DArray
  60470. * @param data defines the data of the texture
  60471. * @param width defines the width of the texture
  60472. * @param height defines the height of the texture
  60473. * @param depth defines the number of layers of the texture
  60474. * @param format defines the texture format to use
  60475. * @param scene defines the hosting scene
  60476. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60477. * @param invertY defines if texture must be stored with Y axis inverted
  60478. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60479. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60480. */
  60481. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60482. /** Gets or sets the texture format to use */
  60483. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60484. /**
  60485. * Update the texture with new data
  60486. * @param data defines the data to store in the texture
  60487. */
  60488. update(data: ArrayBufferView): void;
  60489. }
  60490. }
  60491. declare module BABYLON {
  60492. /**
  60493. * Class used to store 3D textures containing user data
  60494. */
  60495. export class RawTexture3D extends Texture {
  60496. /** Gets or sets the texture format to use */
  60497. format: number;
  60498. /**
  60499. * Create a new RawTexture3D
  60500. * @param data defines the data of the texture
  60501. * @param width defines the width of the texture
  60502. * @param height defines the height of the texture
  60503. * @param depth defines the depth of the texture
  60504. * @param format defines the texture format to use
  60505. * @param scene defines the hosting scene
  60506. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60507. * @param invertY defines if texture must be stored with Y axis inverted
  60508. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60509. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60510. */
  60511. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60512. /** Gets or sets the texture format to use */
  60513. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60514. /**
  60515. * Update the texture with new data
  60516. * @param data defines the data to store in the texture
  60517. */
  60518. update(data: ArrayBufferView): void;
  60519. }
  60520. }
  60521. declare module BABYLON {
  60522. /**
  60523. * Creates a refraction texture used by refraction channel of the standard material.
  60524. * It is like a mirror but to see through a material.
  60525. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60526. */
  60527. export class RefractionTexture extends RenderTargetTexture {
  60528. /**
  60529. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60530. * 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.
  60531. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60532. */
  60533. refractionPlane: Plane;
  60534. /**
  60535. * Define how deep under the surface we should see.
  60536. */
  60537. depth: number;
  60538. /**
  60539. * Creates a refraction texture used by refraction channel of the standard material.
  60540. * It is like a mirror but to see through a material.
  60541. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60542. * @param name Define the texture name
  60543. * @param size Define the size of the underlying texture
  60544. * @param scene Define the scene the refraction belongs to
  60545. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60546. */
  60547. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  60548. /**
  60549. * Clone the refraction texture.
  60550. * @returns the cloned texture
  60551. */
  60552. clone(): RefractionTexture;
  60553. /**
  60554. * Serialize the texture to a JSON representation you could use in Parse later on
  60555. * @returns the serialized JSON representation
  60556. */
  60557. serialize(): any;
  60558. }
  60559. }
  60560. declare module BABYLON {
  60561. /**
  60562. * Block used to add support for vertex skinning (bones)
  60563. */
  60564. export class BonesBlock extends NodeMaterialBlock {
  60565. /**
  60566. * Creates a new BonesBlock
  60567. * @param name defines the block name
  60568. */
  60569. constructor(name: string);
  60570. /**
  60571. * Initialize the block and prepare the context for build
  60572. * @param state defines the state that will be used for the build
  60573. */
  60574. initialize(state: NodeMaterialBuildState): void;
  60575. /**
  60576. * Gets the current class name
  60577. * @returns the class name
  60578. */
  60579. getClassName(): string;
  60580. /**
  60581. * Gets the matrix indices input component
  60582. */
  60583. get matricesIndices(): NodeMaterialConnectionPoint;
  60584. /**
  60585. * Gets the matrix weights input component
  60586. */
  60587. get matricesWeights(): NodeMaterialConnectionPoint;
  60588. /**
  60589. * Gets the extra matrix indices input component
  60590. */
  60591. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60592. /**
  60593. * Gets the extra matrix weights input component
  60594. */
  60595. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60596. /**
  60597. * Gets the world input component
  60598. */
  60599. get world(): NodeMaterialConnectionPoint;
  60600. /**
  60601. * Gets the output component
  60602. */
  60603. get output(): NodeMaterialConnectionPoint;
  60604. autoConfigure(material: NodeMaterial): void;
  60605. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60606. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60607. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60608. protected _buildBlock(state: NodeMaterialBuildState): this;
  60609. }
  60610. }
  60611. declare module BABYLON {
  60612. /**
  60613. * Block used to add support for instances
  60614. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60615. */
  60616. export class InstancesBlock extends NodeMaterialBlock {
  60617. /**
  60618. * Creates a new InstancesBlock
  60619. * @param name defines the block name
  60620. */
  60621. constructor(name: string);
  60622. /**
  60623. * Gets the current class name
  60624. * @returns the class name
  60625. */
  60626. getClassName(): string;
  60627. /**
  60628. * Gets the first world row input component
  60629. */
  60630. get world0(): NodeMaterialConnectionPoint;
  60631. /**
  60632. * Gets the second world row input component
  60633. */
  60634. get world1(): NodeMaterialConnectionPoint;
  60635. /**
  60636. * Gets the third world row input component
  60637. */
  60638. get world2(): NodeMaterialConnectionPoint;
  60639. /**
  60640. * Gets the forth world row input component
  60641. */
  60642. get world3(): NodeMaterialConnectionPoint;
  60643. /**
  60644. * Gets the world input component
  60645. */
  60646. get world(): NodeMaterialConnectionPoint;
  60647. /**
  60648. * Gets the output component
  60649. */
  60650. get output(): NodeMaterialConnectionPoint;
  60651. /**
  60652. * Gets the isntanceID component
  60653. */
  60654. get instanceID(): NodeMaterialConnectionPoint;
  60655. autoConfigure(material: NodeMaterial): void;
  60656. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60657. protected _buildBlock(state: NodeMaterialBuildState): this;
  60658. }
  60659. }
  60660. declare module BABYLON {
  60661. /**
  60662. * Block used to add morph targets support to vertex shader
  60663. */
  60664. export class MorphTargetsBlock extends NodeMaterialBlock {
  60665. private _repeatableContentAnchor;
  60666. /**
  60667. * Create a new MorphTargetsBlock
  60668. * @param name defines the block name
  60669. */
  60670. constructor(name: string);
  60671. /**
  60672. * Gets the current class name
  60673. * @returns the class name
  60674. */
  60675. getClassName(): string;
  60676. /**
  60677. * Gets the position input component
  60678. */
  60679. get position(): NodeMaterialConnectionPoint;
  60680. /**
  60681. * Gets the normal input component
  60682. */
  60683. get normal(): NodeMaterialConnectionPoint;
  60684. /**
  60685. * Gets the tangent input component
  60686. */
  60687. get tangent(): NodeMaterialConnectionPoint;
  60688. /**
  60689. * Gets the tangent input component
  60690. */
  60691. get uv(): NodeMaterialConnectionPoint;
  60692. /**
  60693. * Gets the position output component
  60694. */
  60695. get positionOutput(): NodeMaterialConnectionPoint;
  60696. /**
  60697. * Gets the normal output component
  60698. */
  60699. get normalOutput(): NodeMaterialConnectionPoint;
  60700. /**
  60701. * Gets the tangent output component
  60702. */
  60703. get tangentOutput(): NodeMaterialConnectionPoint;
  60704. /**
  60705. * Gets the tangent output component
  60706. */
  60707. get uvOutput(): NodeMaterialConnectionPoint;
  60708. initialize(state: NodeMaterialBuildState): void;
  60709. autoConfigure(material: NodeMaterial): void;
  60710. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60711. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60712. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60713. protected _buildBlock(state: NodeMaterialBuildState): this;
  60714. }
  60715. }
  60716. declare module BABYLON {
  60717. /**
  60718. * Block used to get data information from a light
  60719. */
  60720. export class LightInformationBlock extends NodeMaterialBlock {
  60721. private _lightDataUniformName;
  60722. private _lightColorUniformName;
  60723. private _lightTypeDefineName;
  60724. /**
  60725. * Gets or sets the light associated with this block
  60726. */
  60727. light: Nullable<Light>;
  60728. /**
  60729. * Creates a new LightInformationBlock
  60730. * @param name defines the block name
  60731. */
  60732. constructor(name: string);
  60733. /**
  60734. * Gets the current class name
  60735. * @returns the class name
  60736. */
  60737. getClassName(): string;
  60738. /**
  60739. * Gets the world position input component
  60740. */
  60741. get worldPosition(): NodeMaterialConnectionPoint;
  60742. /**
  60743. * Gets the direction output component
  60744. */
  60745. get direction(): NodeMaterialConnectionPoint;
  60746. /**
  60747. * Gets the direction output component
  60748. */
  60749. get color(): NodeMaterialConnectionPoint;
  60750. /**
  60751. * Gets the direction output component
  60752. */
  60753. get intensity(): NodeMaterialConnectionPoint;
  60754. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60755. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60756. protected _buildBlock(state: NodeMaterialBuildState): this;
  60757. serialize(): any;
  60758. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60759. }
  60760. }
  60761. declare module BABYLON {
  60762. /**
  60763. * Block used to add image processing support to fragment shader
  60764. */
  60765. export class ImageProcessingBlock extends NodeMaterialBlock {
  60766. /**
  60767. * Create a new ImageProcessingBlock
  60768. * @param name defines the block name
  60769. */
  60770. constructor(name: string);
  60771. /**
  60772. * Gets the current class name
  60773. * @returns the class name
  60774. */
  60775. getClassName(): string;
  60776. /**
  60777. * Gets the color input component
  60778. */
  60779. get color(): NodeMaterialConnectionPoint;
  60780. /**
  60781. * Gets the output component
  60782. */
  60783. get output(): NodeMaterialConnectionPoint;
  60784. /**
  60785. * Initialize the block and prepare the context for build
  60786. * @param state defines the state that will be used for the build
  60787. */
  60788. initialize(state: NodeMaterialBuildState): void;
  60789. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  60790. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60791. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60792. protected _buildBlock(state: NodeMaterialBuildState): this;
  60793. }
  60794. }
  60795. declare module BABYLON {
  60796. /**
  60797. * Block used to pertub normals based on a normal map
  60798. */
  60799. export class PerturbNormalBlock extends NodeMaterialBlock {
  60800. private _tangentSpaceParameterName;
  60801. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60802. invertX: boolean;
  60803. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  60804. invertY: boolean;
  60805. /**
  60806. * Create a new PerturbNormalBlock
  60807. * @param name defines the block name
  60808. */
  60809. constructor(name: string);
  60810. /**
  60811. * Gets the current class name
  60812. * @returns the class name
  60813. */
  60814. getClassName(): string;
  60815. /**
  60816. * Gets the world position input component
  60817. */
  60818. get worldPosition(): NodeMaterialConnectionPoint;
  60819. /**
  60820. * Gets the world normal input component
  60821. */
  60822. get worldNormal(): NodeMaterialConnectionPoint;
  60823. /**
  60824. * Gets the world tangent input component
  60825. */
  60826. get worldTangent(): NodeMaterialConnectionPoint;
  60827. /**
  60828. * Gets the uv input component
  60829. */
  60830. get uv(): NodeMaterialConnectionPoint;
  60831. /**
  60832. * Gets the normal map color input component
  60833. */
  60834. get normalMapColor(): NodeMaterialConnectionPoint;
  60835. /**
  60836. * Gets the strength input component
  60837. */
  60838. get strength(): NodeMaterialConnectionPoint;
  60839. /**
  60840. * Gets the output component
  60841. */
  60842. get output(): NodeMaterialConnectionPoint;
  60843. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60844. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60845. autoConfigure(material: NodeMaterial): void;
  60846. protected _buildBlock(state: NodeMaterialBuildState): this;
  60847. protected _dumpPropertiesCode(): string;
  60848. serialize(): any;
  60849. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60850. }
  60851. }
  60852. declare module BABYLON {
  60853. /**
  60854. * Block used to discard a pixel if a value is smaller than a cutoff
  60855. */
  60856. export class DiscardBlock extends NodeMaterialBlock {
  60857. /**
  60858. * Create a new DiscardBlock
  60859. * @param name defines the block name
  60860. */
  60861. constructor(name: string);
  60862. /**
  60863. * Gets the current class name
  60864. * @returns the class name
  60865. */
  60866. getClassName(): string;
  60867. /**
  60868. * Gets the color input component
  60869. */
  60870. get value(): NodeMaterialConnectionPoint;
  60871. /**
  60872. * Gets the cutoff input component
  60873. */
  60874. get cutoff(): NodeMaterialConnectionPoint;
  60875. protected _buildBlock(state: NodeMaterialBuildState): this;
  60876. }
  60877. }
  60878. declare module BABYLON {
  60879. /**
  60880. * Block used to test if the fragment shader is front facing
  60881. */
  60882. export class FrontFacingBlock extends NodeMaterialBlock {
  60883. /**
  60884. * Creates a new FrontFacingBlock
  60885. * @param name defines the block name
  60886. */
  60887. constructor(name: string);
  60888. /**
  60889. * Gets the current class name
  60890. * @returns the class name
  60891. */
  60892. getClassName(): string;
  60893. /**
  60894. * Gets the output component
  60895. */
  60896. get output(): NodeMaterialConnectionPoint;
  60897. protected _buildBlock(state: NodeMaterialBuildState): this;
  60898. }
  60899. }
  60900. declare module BABYLON {
  60901. /**
  60902. * Block used to get the derivative value on x and y of a given input
  60903. */
  60904. export class DerivativeBlock extends NodeMaterialBlock {
  60905. /**
  60906. * Create a new DerivativeBlock
  60907. * @param name defines the block name
  60908. */
  60909. constructor(name: string);
  60910. /**
  60911. * Gets the current class name
  60912. * @returns the class name
  60913. */
  60914. getClassName(): string;
  60915. /**
  60916. * Gets the input component
  60917. */
  60918. get input(): NodeMaterialConnectionPoint;
  60919. /**
  60920. * Gets the derivative output on x
  60921. */
  60922. get dx(): NodeMaterialConnectionPoint;
  60923. /**
  60924. * Gets the derivative output on y
  60925. */
  60926. get dy(): NodeMaterialConnectionPoint;
  60927. protected _buildBlock(state: NodeMaterialBuildState): this;
  60928. }
  60929. }
  60930. declare module BABYLON {
  60931. /**
  60932. * Block used to add support for scene fog
  60933. */
  60934. export class FogBlock extends NodeMaterialBlock {
  60935. private _fogDistanceName;
  60936. private _fogParameters;
  60937. /**
  60938. * Create a new FogBlock
  60939. * @param name defines the block name
  60940. */
  60941. constructor(name: string);
  60942. /**
  60943. * Gets the current class name
  60944. * @returns the class name
  60945. */
  60946. getClassName(): string;
  60947. /**
  60948. * Gets the world position input component
  60949. */
  60950. get worldPosition(): NodeMaterialConnectionPoint;
  60951. /**
  60952. * Gets the view input component
  60953. */
  60954. get view(): NodeMaterialConnectionPoint;
  60955. /**
  60956. * Gets the color input component
  60957. */
  60958. get input(): NodeMaterialConnectionPoint;
  60959. /**
  60960. * Gets the fog color input component
  60961. */
  60962. get fogColor(): NodeMaterialConnectionPoint;
  60963. /**
  60964. * Gets the output component
  60965. */
  60966. get output(): NodeMaterialConnectionPoint;
  60967. autoConfigure(material: NodeMaterial): void;
  60968. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60969. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60970. protected _buildBlock(state: NodeMaterialBuildState): this;
  60971. }
  60972. }
  60973. declare module BABYLON {
  60974. /**
  60975. * Block used to add light in the fragment shader
  60976. */
  60977. export class LightBlock extends NodeMaterialBlock {
  60978. private _lightId;
  60979. /**
  60980. * Gets or sets the light associated with this block
  60981. */
  60982. light: Nullable<Light>;
  60983. /**
  60984. * Create a new LightBlock
  60985. * @param name defines the block name
  60986. */
  60987. constructor(name: string);
  60988. /**
  60989. * Gets the current class name
  60990. * @returns the class name
  60991. */
  60992. getClassName(): string;
  60993. /**
  60994. * Gets the world position input component
  60995. */
  60996. get worldPosition(): NodeMaterialConnectionPoint;
  60997. /**
  60998. * Gets the world normal input component
  60999. */
  61000. get worldNormal(): NodeMaterialConnectionPoint;
  61001. /**
  61002. * Gets the camera (or eye) position component
  61003. */
  61004. get cameraPosition(): NodeMaterialConnectionPoint;
  61005. /**
  61006. * Gets the glossiness component
  61007. */
  61008. get glossiness(): NodeMaterialConnectionPoint;
  61009. /**
  61010. * Gets the glossinness power component
  61011. */
  61012. get glossPower(): NodeMaterialConnectionPoint;
  61013. /**
  61014. * Gets the diffuse color component
  61015. */
  61016. get diffuseColor(): NodeMaterialConnectionPoint;
  61017. /**
  61018. * Gets the specular color component
  61019. */
  61020. get specularColor(): NodeMaterialConnectionPoint;
  61021. /**
  61022. * Gets the diffuse output component
  61023. */
  61024. get diffuseOutput(): NodeMaterialConnectionPoint;
  61025. /**
  61026. * Gets the specular output component
  61027. */
  61028. get specularOutput(): NodeMaterialConnectionPoint;
  61029. /**
  61030. * Gets the shadow output component
  61031. */
  61032. get shadow(): NodeMaterialConnectionPoint;
  61033. autoConfigure(material: NodeMaterial): void;
  61034. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61035. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61036. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61037. private _injectVertexCode;
  61038. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61039. serialize(): any;
  61040. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61041. }
  61042. }
  61043. declare module BABYLON {
  61044. /**
  61045. * Block used to read a reflection texture from a sampler
  61046. */
  61047. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61048. /**
  61049. * Create a new ReflectionTextureBlock
  61050. * @param name defines the block name
  61051. */
  61052. constructor(name: string);
  61053. /**
  61054. * Gets the current class name
  61055. * @returns the class name
  61056. */
  61057. getClassName(): string;
  61058. /**
  61059. * Gets the world position input component
  61060. */
  61061. get position(): NodeMaterialConnectionPoint;
  61062. /**
  61063. * Gets the world position input component
  61064. */
  61065. get worldPosition(): NodeMaterialConnectionPoint;
  61066. /**
  61067. * Gets the world normal input component
  61068. */
  61069. get worldNormal(): NodeMaterialConnectionPoint;
  61070. /**
  61071. * Gets the world input component
  61072. */
  61073. get world(): NodeMaterialConnectionPoint;
  61074. /**
  61075. * Gets the camera (or eye) position component
  61076. */
  61077. get cameraPosition(): NodeMaterialConnectionPoint;
  61078. /**
  61079. * Gets the view input component
  61080. */
  61081. get view(): NodeMaterialConnectionPoint;
  61082. /**
  61083. * Gets the rgb output component
  61084. */
  61085. get rgb(): NodeMaterialConnectionPoint;
  61086. /**
  61087. * Gets the r output component
  61088. */
  61089. get r(): NodeMaterialConnectionPoint;
  61090. /**
  61091. * Gets the g output component
  61092. */
  61093. get g(): NodeMaterialConnectionPoint;
  61094. /**
  61095. * Gets the b output component
  61096. */
  61097. get b(): NodeMaterialConnectionPoint;
  61098. autoConfigure(material: NodeMaterial): void;
  61099. protected _buildBlock(state: NodeMaterialBuildState): this;
  61100. }
  61101. }
  61102. declare module BABYLON {
  61103. /**
  61104. * Block used to add 2 vectors
  61105. */
  61106. export class AddBlock extends NodeMaterialBlock {
  61107. /**
  61108. * Creates a new AddBlock
  61109. * @param name defines the block name
  61110. */
  61111. constructor(name: string);
  61112. /**
  61113. * Gets the current class name
  61114. * @returns the class name
  61115. */
  61116. getClassName(): string;
  61117. /**
  61118. * Gets the left operand input component
  61119. */
  61120. get left(): NodeMaterialConnectionPoint;
  61121. /**
  61122. * Gets the right operand input component
  61123. */
  61124. get right(): NodeMaterialConnectionPoint;
  61125. /**
  61126. * Gets the output component
  61127. */
  61128. get output(): NodeMaterialConnectionPoint;
  61129. protected _buildBlock(state: NodeMaterialBuildState): this;
  61130. }
  61131. }
  61132. declare module BABYLON {
  61133. /**
  61134. * Block used to scale a vector by a float
  61135. */
  61136. export class ScaleBlock extends NodeMaterialBlock {
  61137. /**
  61138. * Creates a new ScaleBlock
  61139. * @param name defines the block name
  61140. */
  61141. constructor(name: string);
  61142. /**
  61143. * Gets the current class name
  61144. * @returns the class name
  61145. */
  61146. getClassName(): string;
  61147. /**
  61148. * Gets the input component
  61149. */
  61150. get input(): NodeMaterialConnectionPoint;
  61151. /**
  61152. * Gets the factor input component
  61153. */
  61154. get factor(): NodeMaterialConnectionPoint;
  61155. /**
  61156. * Gets the output component
  61157. */
  61158. get output(): NodeMaterialConnectionPoint;
  61159. protected _buildBlock(state: NodeMaterialBuildState): this;
  61160. }
  61161. }
  61162. declare module BABYLON {
  61163. /**
  61164. * Block used to clamp a float
  61165. */
  61166. export class ClampBlock extends NodeMaterialBlock {
  61167. /** Gets or sets the minimum range */
  61168. minimum: number;
  61169. /** Gets or sets the maximum range */
  61170. maximum: number;
  61171. /**
  61172. * Creates a new ClampBlock
  61173. * @param name defines the block name
  61174. */
  61175. constructor(name: string);
  61176. /**
  61177. * Gets the current class name
  61178. * @returns the class name
  61179. */
  61180. getClassName(): string;
  61181. /**
  61182. * Gets the value input component
  61183. */
  61184. get value(): NodeMaterialConnectionPoint;
  61185. /**
  61186. * Gets the output component
  61187. */
  61188. get output(): NodeMaterialConnectionPoint;
  61189. protected _buildBlock(state: NodeMaterialBuildState): this;
  61190. protected _dumpPropertiesCode(): string;
  61191. serialize(): any;
  61192. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61193. }
  61194. }
  61195. declare module BABYLON {
  61196. /**
  61197. * Block used to apply a cross product between 2 vectors
  61198. */
  61199. export class CrossBlock extends NodeMaterialBlock {
  61200. /**
  61201. * Creates a new CrossBlock
  61202. * @param name defines the block name
  61203. */
  61204. constructor(name: string);
  61205. /**
  61206. * Gets the current class name
  61207. * @returns the class name
  61208. */
  61209. getClassName(): string;
  61210. /**
  61211. * Gets the left operand input component
  61212. */
  61213. get left(): NodeMaterialConnectionPoint;
  61214. /**
  61215. * Gets the right operand input component
  61216. */
  61217. get right(): NodeMaterialConnectionPoint;
  61218. /**
  61219. * Gets the output component
  61220. */
  61221. get output(): NodeMaterialConnectionPoint;
  61222. protected _buildBlock(state: NodeMaterialBuildState): this;
  61223. }
  61224. }
  61225. declare module BABYLON {
  61226. /**
  61227. * Block used to apply a dot product between 2 vectors
  61228. */
  61229. export class DotBlock extends NodeMaterialBlock {
  61230. /**
  61231. * Creates a new DotBlock
  61232. * @param name defines the block name
  61233. */
  61234. constructor(name: string);
  61235. /**
  61236. * Gets the current class name
  61237. * @returns the class name
  61238. */
  61239. getClassName(): string;
  61240. /**
  61241. * Gets the left operand input component
  61242. */
  61243. get left(): NodeMaterialConnectionPoint;
  61244. /**
  61245. * Gets the right operand input component
  61246. */
  61247. get right(): NodeMaterialConnectionPoint;
  61248. /**
  61249. * Gets the output component
  61250. */
  61251. get output(): NodeMaterialConnectionPoint;
  61252. protected _buildBlock(state: NodeMaterialBuildState): this;
  61253. }
  61254. }
  61255. declare module BABYLON {
  61256. /**
  61257. * Block used to normalize a vector
  61258. */
  61259. export class NormalizeBlock extends NodeMaterialBlock {
  61260. /**
  61261. * Creates a new NormalizeBlock
  61262. * @param name defines the block name
  61263. */
  61264. constructor(name: string);
  61265. /**
  61266. * Gets the current class name
  61267. * @returns the class name
  61268. */
  61269. getClassName(): string;
  61270. /**
  61271. * Gets the input component
  61272. */
  61273. get input(): NodeMaterialConnectionPoint;
  61274. /**
  61275. * Gets the output component
  61276. */
  61277. get output(): NodeMaterialConnectionPoint;
  61278. protected _buildBlock(state: NodeMaterialBuildState): this;
  61279. }
  61280. }
  61281. declare module BABYLON {
  61282. /**
  61283. * Operations supported by the Trigonometry block
  61284. */
  61285. export enum TrigonometryBlockOperations {
  61286. /** Cos */
  61287. Cos = 0,
  61288. /** Sin */
  61289. Sin = 1,
  61290. /** Abs */
  61291. Abs = 2,
  61292. /** Exp */
  61293. Exp = 3,
  61294. /** Exp2 */
  61295. Exp2 = 4,
  61296. /** Round */
  61297. Round = 5,
  61298. /** Floor */
  61299. Floor = 6,
  61300. /** Ceiling */
  61301. Ceiling = 7,
  61302. /** Square root */
  61303. Sqrt = 8,
  61304. /** Log */
  61305. Log = 9,
  61306. /** Tangent */
  61307. Tan = 10,
  61308. /** Arc tangent */
  61309. ArcTan = 11,
  61310. /** Arc cosinus */
  61311. ArcCos = 12,
  61312. /** Arc sinus */
  61313. ArcSin = 13,
  61314. /** Fraction */
  61315. Fract = 14,
  61316. /** Sign */
  61317. Sign = 15,
  61318. /** To radians (from degrees) */
  61319. Radians = 16,
  61320. /** To degrees (from radians) */
  61321. Degrees = 17
  61322. }
  61323. /**
  61324. * Block used to apply trigonometry operation to floats
  61325. */
  61326. export class TrigonometryBlock extends NodeMaterialBlock {
  61327. /**
  61328. * Gets or sets the operation applied by the block
  61329. */
  61330. operation: TrigonometryBlockOperations;
  61331. /**
  61332. * Creates a new TrigonometryBlock
  61333. * @param name defines the block name
  61334. */
  61335. constructor(name: string);
  61336. /**
  61337. * Gets the current class name
  61338. * @returns the class name
  61339. */
  61340. getClassName(): string;
  61341. /**
  61342. * Gets the input component
  61343. */
  61344. get input(): NodeMaterialConnectionPoint;
  61345. /**
  61346. * Gets the output component
  61347. */
  61348. get output(): NodeMaterialConnectionPoint;
  61349. protected _buildBlock(state: NodeMaterialBuildState): this;
  61350. serialize(): any;
  61351. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61352. protected _dumpPropertiesCode(): string;
  61353. }
  61354. }
  61355. declare module BABYLON {
  61356. /**
  61357. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61358. */
  61359. export class ColorMergerBlock extends NodeMaterialBlock {
  61360. /**
  61361. * Create a new ColorMergerBlock
  61362. * @param name defines the block name
  61363. */
  61364. constructor(name: string);
  61365. /**
  61366. * Gets the current class name
  61367. * @returns the class name
  61368. */
  61369. getClassName(): string;
  61370. /**
  61371. * Gets the rgb component (input)
  61372. */
  61373. get rgbIn(): NodeMaterialConnectionPoint;
  61374. /**
  61375. * Gets the r component (input)
  61376. */
  61377. get r(): NodeMaterialConnectionPoint;
  61378. /**
  61379. * Gets the g component (input)
  61380. */
  61381. get g(): NodeMaterialConnectionPoint;
  61382. /**
  61383. * Gets the b component (input)
  61384. */
  61385. get b(): NodeMaterialConnectionPoint;
  61386. /**
  61387. * Gets the a component (input)
  61388. */
  61389. get a(): NodeMaterialConnectionPoint;
  61390. /**
  61391. * Gets the rgba component (output)
  61392. */
  61393. get rgba(): NodeMaterialConnectionPoint;
  61394. /**
  61395. * Gets the rgb component (output)
  61396. */
  61397. get rgbOut(): NodeMaterialConnectionPoint;
  61398. /**
  61399. * Gets the rgb component (output)
  61400. * @deprecated Please use rgbOut instead.
  61401. */
  61402. get rgb(): NodeMaterialConnectionPoint;
  61403. protected _buildBlock(state: NodeMaterialBuildState): this;
  61404. }
  61405. }
  61406. declare module BABYLON {
  61407. /**
  61408. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61409. */
  61410. export class VectorSplitterBlock extends NodeMaterialBlock {
  61411. /**
  61412. * Create a new VectorSplitterBlock
  61413. * @param name defines the block name
  61414. */
  61415. constructor(name: string);
  61416. /**
  61417. * Gets the current class name
  61418. * @returns the class name
  61419. */
  61420. getClassName(): string;
  61421. /**
  61422. * Gets the xyzw component (input)
  61423. */
  61424. get xyzw(): NodeMaterialConnectionPoint;
  61425. /**
  61426. * Gets the xyz component (input)
  61427. */
  61428. get xyzIn(): NodeMaterialConnectionPoint;
  61429. /**
  61430. * Gets the xy component (input)
  61431. */
  61432. get xyIn(): NodeMaterialConnectionPoint;
  61433. /**
  61434. * Gets the xyz component (output)
  61435. */
  61436. get xyzOut(): NodeMaterialConnectionPoint;
  61437. /**
  61438. * Gets the xy component (output)
  61439. */
  61440. get xyOut(): NodeMaterialConnectionPoint;
  61441. /**
  61442. * Gets the x component (output)
  61443. */
  61444. get x(): NodeMaterialConnectionPoint;
  61445. /**
  61446. * Gets the y component (output)
  61447. */
  61448. get y(): NodeMaterialConnectionPoint;
  61449. /**
  61450. * Gets the z component (output)
  61451. */
  61452. get z(): NodeMaterialConnectionPoint;
  61453. /**
  61454. * Gets the w component (output)
  61455. */
  61456. get w(): NodeMaterialConnectionPoint;
  61457. protected _inputRename(name: string): string;
  61458. protected _outputRename(name: string): string;
  61459. protected _buildBlock(state: NodeMaterialBuildState): this;
  61460. }
  61461. }
  61462. declare module BABYLON {
  61463. /**
  61464. * Block used to lerp between 2 values
  61465. */
  61466. export class LerpBlock extends NodeMaterialBlock {
  61467. /**
  61468. * Creates a new LerpBlock
  61469. * @param name defines the block name
  61470. */
  61471. constructor(name: string);
  61472. /**
  61473. * Gets the current class name
  61474. * @returns the class name
  61475. */
  61476. getClassName(): string;
  61477. /**
  61478. * Gets the left operand input component
  61479. */
  61480. get left(): NodeMaterialConnectionPoint;
  61481. /**
  61482. * Gets the right operand input component
  61483. */
  61484. get right(): NodeMaterialConnectionPoint;
  61485. /**
  61486. * Gets the gradient operand input component
  61487. */
  61488. get gradient(): NodeMaterialConnectionPoint;
  61489. /**
  61490. * Gets the output component
  61491. */
  61492. get output(): NodeMaterialConnectionPoint;
  61493. protected _buildBlock(state: NodeMaterialBuildState): this;
  61494. }
  61495. }
  61496. declare module BABYLON {
  61497. /**
  61498. * Block used to divide 2 vectors
  61499. */
  61500. export class DivideBlock extends NodeMaterialBlock {
  61501. /**
  61502. * Creates a new DivideBlock
  61503. * @param name defines the block name
  61504. */
  61505. constructor(name: string);
  61506. /**
  61507. * Gets the current class name
  61508. * @returns the class name
  61509. */
  61510. getClassName(): string;
  61511. /**
  61512. * Gets the left operand input component
  61513. */
  61514. get left(): NodeMaterialConnectionPoint;
  61515. /**
  61516. * Gets the right operand input component
  61517. */
  61518. get right(): NodeMaterialConnectionPoint;
  61519. /**
  61520. * Gets the output component
  61521. */
  61522. get output(): NodeMaterialConnectionPoint;
  61523. protected _buildBlock(state: NodeMaterialBuildState): this;
  61524. }
  61525. }
  61526. declare module BABYLON {
  61527. /**
  61528. * Block used to subtract 2 vectors
  61529. */
  61530. export class SubtractBlock extends NodeMaterialBlock {
  61531. /**
  61532. * Creates a new SubtractBlock
  61533. * @param name defines the block name
  61534. */
  61535. constructor(name: string);
  61536. /**
  61537. * Gets the current class name
  61538. * @returns the class name
  61539. */
  61540. getClassName(): string;
  61541. /**
  61542. * Gets the left operand input component
  61543. */
  61544. get left(): NodeMaterialConnectionPoint;
  61545. /**
  61546. * Gets the right operand input component
  61547. */
  61548. get right(): NodeMaterialConnectionPoint;
  61549. /**
  61550. * Gets the output component
  61551. */
  61552. get output(): NodeMaterialConnectionPoint;
  61553. protected _buildBlock(state: NodeMaterialBuildState): this;
  61554. }
  61555. }
  61556. declare module BABYLON {
  61557. /**
  61558. * Block used to step a value
  61559. */
  61560. export class StepBlock extends NodeMaterialBlock {
  61561. /**
  61562. * Creates a new StepBlock
  61563. * @param name defines the block name
  61564. */
  61565. constructor(name: string);
  61566. /**
  61567. * Gets the current class name
  61568. * @returns the class name
  61569. */
  61570. getClassName(): string;
  61571. /**
  61572. * Gets the value operand input component
  61573. */
  61574. get value(): NodeMaterialConnectionPoint;
  61575. /**
  61576. * Gets the edge operand input component
  61577. */
  61578. get edge(): NodeMaterialConnectionPoint;
  61579. /**
  61580. * Gets the output component
  61581. */
  61582. get output(): NodeMaterialConnectionPoint;
  61583. protected _buildBlock(state: NodeMaterialBuildState): this;
  61584. }
  61585. }
  61586. declare module BABYLON {
  61587. /**
  61588. * Block used to get the opposite (1 - x) of a value
  61589. */
  61590. export class OneMinusBlock extends NodeMaterialBlock {
  61591. /**
  61592. * Creates a new OneMinusBlock
  61593. * @param name defines the block name
  61594. */
  61595. constructor(name: string);
  61596. /**
  61597. * Gets the current class name
  61598. * @returns the class name
  61599. */
  61600. getClassName(): string;
  61601. /**
  61602. * Gets the input component
  61603. */
  61604. get input(): NodeMaterialConnectionPoint;
  61605. /**
  61606. * Gets the output component
  61607. */
  61608. get output(): NodeMaterialConnectionPoint;
  61609. protected _buildBlock(state: NodeMaterialBuildState): this;
  61610. }
  61611. }
  61612. declare module BABYLON {
  61613. /**
  61614. * Block used to get the view direction
  61615. */
  61616. export class ViewDirectionBlock extends NodeMaterialBlock {
  61617. /**
  61618. * Creates a new ViewDirectionBlock
  61619. * @param name defines the block name
  61620. */
  61621. constructor(name: string);
  61622. /**
  61623. * Gets the current class name
  61624. * @returns the class name
  61625. */
  61626. getClassName(): string;
  61627. /**
  61628. * Gets the world position component
  61629. */
  61630. get worldPosition(): NodeMaterialConnectionPoint;
  61631. /**
  61632. * Gets the camera position component
  61633. */
  61634. get cameraPosition(): NodeMaterialConnectionPoint;
  61635. /**
  61636. * Gets the output component
  61637. */
  61638. get output(): NodeMaterialConnectionPoint;
  61639. autoConfigure(material: NodeMaterial): void;
  61640. protected _buildBlock(state: NodeMaterialBuildState): this;
  61641. }
  61642. }
  61643. declare module BABYLON {
  61644. /**
  61645. * Block used to compute fresnel value
  61646. */
  61647. export class FresnelBlock extends NodeMaterialBlock {
  61648. /**
  61649. * Create a new FresnelBlock
  61650. * @param name defines the block name
  61651. */
  61652. constructor(name: string);
  61653. /**
  61654. * Gets the current class name
  61655. * @returns the class name
  61656. */
  61657. getClassName(): string;
  61658. /**
  61659. * Gets the world normal input component
  61660. */
  61661. get worldNormal(): NodeMaterialConnectionPoint;
  61662. /**
  61663. * Gets the view direction input component
  61664. */
  61665. get viewDirection(): NodeMaterialConnectionPoint;
  61666. /**
  61667. * Gets the bias input component
  61668. */
  61669. get bias(): NodeMaterialConnectionPoint;
  61670. /**
  61671. * Gets the camera (or eye) position component
  61672. */
  61673. get power(): NodeMaterialConnectionPoint;
  61674. /**
  61675. * Gets the fresnel output component
  61676. */
  61677. get fresnel(): NodeMaterialConnectionPoint;
  61678. autoConfigure(material: NodeMaterial): void;
  61679. protected _buildBlock(state: NodeMaterialBuildState): this;
  61680. }
  61681. }
  61682. declare module BABYLON {
  61683. /**
  61684. * Block used to get the max of 2 values
  61685. */
  61686. export class MaxBlock extends NodeMaterialBlock {
  61687. /**
  61688. * Creates a new MaxBlock
  61689. * @param name defines the block name
  61690. */
  61691. constructor(name: string);
  61692. /**
  61693. * Gets the current class name
  61694. * @returns the class name
  61695. */
  61696. getClassName(): string;
  61697. /**
  61698. * Gets the left operand input component
  61699. */
  61700. get left(): NodeMaterialConnectionPoint;
  61701. /**
  61702. * Gets the right operand input component
  61703. */
  61704. get right(): NodeMaterialConnectionPoint;
  61705. /**
  61706. * Gets the output component
  61707. */
  61708. get output(): NodeMaterialConnectionPoint;
  61709. protected _buildBlock(state: NodeMaterialBuildState): this;
  61710. }
  61711. }
  61712. declare module BABYLON {
  61713. /**
  61714. * Block used to get the min of 2 values
  61715. */
  61716. export class MinBlock extends NodeMaterialBlock {
  61717. /**
  61718. * Creates a new MinBlock
  61719. * @param name defines the block name
  61720. */
  61721. constructor(name: string);
  61722. /**
  61723. * Gets the current class name
  61724. * @returns the class name
  61725. */
  61726. getClassName(): string;
  61727. /**
  61728. * Gets the left operand input component
  61729. */
  61730. get left(): NodeMaterialConnectionPoint;
  61731. /**
  61732. * Gets the right operand input component
  61733. */
  61734. get right(): NodeMaterialConnectionPoint;
  61735. /**
  61736. * Gets the output component
  61737. */
  61738. get output(): NodeMaterialConnectionPoint;
  61739. protected _buildBlock(state: NodeMaterialBuildState): this;
  61740. }
  61741. }
  61742. declare module BABYLON {
  61743. /**
  61744. * Block used to get the distance between 2 values
  61745. */
  61746. export class DistanceBlock extends NodeMaterialBlock {
  61747. /**
  61748. * Creates a new DistanceBlock
  61749. * @param name defines the block name
  61750. */
  61751. constructor(name: string);
  61752. /**
  61753. * Gets the current class name
  61754. * @returns the class name
  61755. */
  61756. getClassName(): string;
  61757. /**
  61758. * Gets the left operand input component
  61759. */
  61760. get left(): NodeMaterialConnectionPoint;
  61761. /**
  61762. * Gets the right operand input component
  61763. */
  61764. get right(): NodeMaterialConnectionPoint;
  61765. /**
  61766. * Gets the output component
  61767. */
  61768. get output(): NodeMaterialConnectionPoint;
  61769. protected _buildBlock(state: NodeMaterialBuildState): this;
  61770. }
  61771. }
  61772. declare module BABYLON {
  61773. /**
  61774. * Block used to get the length of a vector
  61775. */
  61776. export class LengthBlock extends NodeMaterialBlock {
  61777. /**
  61778. * Creates a new LengthBlock
  61779. * @param name defines the block name
  61780. */
  61781. constructor(name: string);
  61782. /**
  61783. * Gets the current class name
  61784. * @returns the class name
  61785. */
  61786. getClassName(): string;
  61787. /**
  61788. * Gets the value input component
  61789. */
  61790. get value(): NodeMaterialConnectionPoint;
  61791. /**
  61792. * Gets the output component
  61793. */
  61794. get output(): NodeMaterialConnectionPoint;
  61795. protected _buildBlock(state: NodeMaterialBuildState): this;
  61796. }
  61797. }
  61798. declare module BABYLON {
  61799. /**
  61800. * Block used to get negative version of a value (i.e. x * -1)
  61801. */
  61802. export class NegateBlock extends NodeMaterialBlock {
  61803. /**
  61804. * Creates a new NegateBlock
  61805. * @param name defines the block name
  61806. */
  61807. constructor(name: string);
  61808. /**
  61809. * Gets the current class name
  61810. * @returns the class name
  61811. */
  61812. getClassName(): string;
  61813. /**
  61814. * Gets the value input component
  61815. */
  61816. get value(): NodeMaterialConnectionPoint;
  61817. /**
  61818. * Gets the output component
  61819. */
  61820. get output(): NodeMaterialConnectionPoint;
  61821. protected _buildBlock(state: NodeMaterialBuildState): this;
  61822. }
  61823. }
  61824. declare module BABYLON {
  61825. /**
  61826. * Block used to get the value of the first parameter raised to the power of the second
  61827. */
  61828. export class PowBlock extends NodeMaterialBlock {
  61829. /**
  61830. * Creates a new PowBlock
  61831. * @param name defines the block name
  61832. */
  61833. constructor(name: string);
  61834. /**
  61835. * Gets the current class name
  61836. * @returns the class name
  61837. */
  61838. getClassName(): string;
  61839. /**
  61840. * Gets the value operand input component
  61841. */
  61842. get value(): NodeMaterialConnectionPoint;
  61843. /**
  61844. * Gets the power operand input component
  61845. */
  61846. get power(): NodeMaterialConnectionPoint;
  61847. /**
  61848. * Gets the output component
  61849. */
  61850. get output(): NodeMaterialConnectionPoint;
  61851. protected _buildBlock(state: NodeMaterialBuildState): this;
  61852. }
  61853. }
  61854. declare module BABYLON {
  61855. /**
  61856. * Block used to get a random number
  61857. */
  61858. export class RandomNumberBlock extends NodeMaterialBlock {
  61859. /**
  61860. * Creates a new RandomNumberBlock
  61861. * @param name defines the block name
  61862. */
  61863. constructor(name: string);
  61864. /**
  61865. * Gets the current class name
  61866. * @returns the class name
  61867. */
  61868. getClassName(): string;
  61869. /**
  61870. * Gets the seed input component
  61871. */
  61872. get seed(): NodeMaterialConnectionPoint;
  61873. /**
  61874. * Gets the output component
  61875. */
  61876. get output(): NodeMaterialConnectionPoint;
  61877. protected _buildBlock(state: NodeMaterialBuildState): this;
  61878. }
  61879. }
  61880. declare module BABYLON {
  61881. /**
  61882. * Block used to compute arc tangent of 2 values
  61883. */
  61884. export class ArcTan2Block extends NodeMaterialBlock {
  61885. /**
  61886. * Creates a new ArcTan2Block
  61887. * @param name defines the block name
  61888. */
  61889. constructor(name: string);
  61890. /**
  61891. * Gets the current class name
  61892. * @returns the class name
  61893. */
  61894. getClassName(): string;
  61895. /**
  61896. * Gets the x operand input component
  61897. */
  61898. get x(): NodeMaterialConnectionPoint;
  61899. /**
  61900. * Gets the y operand input component
  61901. */
  61902. get y(): NodeMaterialConnectionPoint;
  61903. /**
  61904. * Gets the output component
  61905. */
  61906. get output(): NodeMaterialConnectionPoint;
  61907. protected _buildBlock(state: NodeMaterialBuildState): this;
  61908. }
  61909. }
  61910. declare module BABYLON {
  61911. /**
  61912. * Block used to smooth step a value
  61913. */
  61914. export class SmoothStepBlock extends NodeMaterialBlock {
  61915. /**
  61916. * Creates a new SmoothStepBlock
  61917. * @param name defines the block name
  61918. */
  61919. constructor(name: string);
  61920. /**
  61921. * Gets the current class name
  61922. * @returns the class name
  61923. */
  61924. getClassName(): string;
  61925. /**
  61926. * Gets the value operand input component
  61927. */
  61928. get value(): NodeMaterialConnectionPoint;
  61929. /**
  61930. * Gets the first edge operand input component
  61931. */
  61932. get edge0(): NodeMaterialConnectionPoint;
  61933. /**
  61934. * Gets the second edge operand input component
  61935. */
  61936. get edge1(): NodeMaterialConnectionPoint;
  61937. /**
  61938. * Gets the output component
  61939. */
  61940. get output(): NodeMaterialConnectionPoint;
  61941. protected _buildBlock(state: NodeMaterialBuildState): this;
  61942. }
  61943. }
  61944. declare module BABYLON {
  61945. /**
  61946. * Block used to get the reciprocal (1 / x) of a value
  61947. */
  61948. export class ReciprocalBlock extends NodeMaterialBlock {
  61949. /**
  61950. * Creates a new ReciprocalBlock
  61951. * @param name defines the block name
  61952. */
  61953. constructor(name: string);
  61954. /**
  61955. * Gets the current class name
  61956. * @returns the class name
  61957. */
  61958. getClassName(): string;
  61959. /**
  61960. * Gets the input component
  61961. */
  61962. get input(): NodeMaterialConnectionPoint;
  61963. /**
  61964. * Gets the output component
  61965. */
  61966. get output(): NodeMaterialConnectionPoint;
  61967. protected _buildBlock(state: NodeMaterialBuildState): this;
  61968. }
  61969. }
  61970. declare module BABYLON {
  61971. /**
  61972. * Block used to replace a color by another one
  61973. */
  61974. export class ReplaceColorBlock extends NodeMaterialBlock {
  61975. /**
  61976. * Creates a new ReplaceColorBlock
  61977. * @param name defines the block name
  61978. */
  61979. constructor(name: string);
  61980. /**
  61981. * Gets the current class name
  61982. * @returns the class name
  61983. */
  61984. getClassName(): string;
  61985. /**
  61986. * Gets the value input component
  61987. */
  61988. get value(): NodeMaterialConnectionPoint;
  61989. /**
  61990. * Gets the reference input component
  61991. */
  61992. get reference(): NodeMaterialConnectionPoint;
  61993. /**
  61994. * Gets the distance input component
  61995. */
  61996. get distance(): NodeMaterialConnectionPoint;
  61997. /**
  61998. * Gets the replacement input component
  61999. */
  62000. get replacement(): NodeMaterialConnectionPoint;
  62001. /**
  62002. * Gets the output component
  62003. */
  62004. get output(): NodeMaterialConnectionPoint;
  62005. protected _buildBlock(state: NodeMaterialBuildState): this;
  62006. }
  62007. }
  62008. declare module BABYLON {
  62009. /**
  62010. * Block used to posterize a value
  62011. * @see https://en.wikipedia.org/wiki/Posterization
  62012. */
  62013. export class PosterizeBlock extends NodeMaterialBlock {
  62014. /**
  62015. * Creates a new PosterizeBlock
  62016. * @param name defines the block name
  62017. */
  62018. constructor(name: string);
  62019. /**
  62020. * Gets the current class name
  62021. * @returns the class name
  62022. */
  62023. getClassName(): string;
  62024. /**
  62025. * Gets the value input component
  62026. */
  62027. get value(): NodeMaterialConnectionPoint;
  62028. /**
  62029. * Gets the steps input component
  62030. */
  62031. get steps(): NodeMaterialConnectionPoint;
  62032. /**
  62033. * Gets the output component
  62034. */
  62035. get output(): NodeMaterialConnectionPoint;
  62036. protected _buildBlock(state: NodeMaterialBuildState): this;
  62037. }
  62038. }
  62039. declare module BABYLON {
  62040. /**
  62041. * Operations supported by the Wave block
  62042. */
  62043. export enum WaveBlockKind {
  62044. /** SawTooth */
  62045. SawTooth = 0,
  62046. /** Square */
  62047. Square = 1,
  62048. /** Triangle */
  62049. Triangle = 2
  62050. }
  62051. /**
  62052. * Block used to apply wave operation to floats
  62053. */
  62054. export class WaveBlock extends NodeMaterialBlock {
  62055. /**
  62056. * Gets or sets the kibnd of wave to be applied by the block
  62057. */
  62058. kind: WaveBlockKind;
  62059. /**
  62060. * Creates a new WaveBlock
  62061. * @param name defines the block name
  62062. */
  62063. constructor(name: string);
  62064. /**
  62065. * Gets the current class name
  62066. * @returns the class name
  62067. */
  62068. getClassName(): string;
  62069. /**
  62070. * Gets the input component
  62071. */
  62072. get input(): NodeMaterialConnectionPoint;
  62073. /**
  62074. * Gets the output component
  62075. */
  62076. get output(): NodeMaterialConnectionPoint;
  62077. protected _buildBlock(state: NodeMaterialBuildState): this;
  62078. serialize(): any;
  62079. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62080. }
  62081. }
  62082. declare module BABYLON {
  62083. /**
  62084. * Class used to store a color step for the GradientBlock
  62085. */
  62086. export class GradientBlockColorStep {
  62087. /**
  62088. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62089. */
  62090. step: number;
  62091. /**
  62092. * Gets or sets the color associated with this step
  62093. */
  62094. color: Color3;
  62095. /**
  62096. * Creates a new GradientBlockColorStep
  62097. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62098. * @param color defines the color associated with this step
  62099. */
  62100. constructor(
  62101. /**
  62102. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62103. */
  62104. step: number,
  62105. /**
  62106. * Gets or sets the color associated with this step
  62107. */
  62108. color: Color3);
  62109. }
  62110. /**
  62111. * Block used to return a color from a gradient based on an input value between 0 and 1
  62112. */
  62113. export class GradientBlock extends NodeMaterialBlock {
  62114. /**
  62115. * Gets or sets the list of color steps
  62116. */
  62117. colorSteps: GradientBlockColorStep[];
  62118. /**
  62119. * Creates a new GradientBlock
  62120. * @param name defines the block name
  62121. */
  62122. constructor(name: string);
  62123. /**
  62124. * Gets the current class name
  62125. * @returns the class name
  62126. */
  62127. getClassName(): string;
  62128. /**
  62129. * Gets the gradient input component
  62130. */
  62131. get gradient(): NodeMaterialConnectionPoint;
  62132. /**
  62133. * Gets the output component
  62134. */
  62135. get output(): NodeMaterialConnectionPoint;
  62136. private _writeColorConstant;
  62137. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62138. serialize(): any;
  62139. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62140. protected _dumpPropertiesCode(): string;
  62141. }
  62142. }
  62143. declare module BABYLON {
  62144. /**
  62145. * Block used to normalize lerp between 2 values
  62146. */
  62147. export class NLerpBlock extends NodeMaterialBlock {
  62148. /**
  62149. * Creates a new NLerpBlock
  62150. * @param name defines the block name
  62151. */
  62152. constructor(name: string);
  62153. /**
  62154. * Gets the current class name
  62155. * @returns the class name
  62156. */
  62157. getClassName(): string;
  62158. /**
  62159. * Gets the left operand input component
  62160. */
  62161. get left(): NodeMaterialConnectionPoint;
  62162. /**
  62163. * Gets the right operand input component
  62164. */
  62165. get right(): NodeMaterialConnectionPoint;
  62166. /**
  62167. * Gets the gradient operand input component
  62168. */
  62169. get gradient(): NodeMaterialConnectionPoint;
  62170. /**
  62171. * Gets the output component
  62172. */
  62173. get output(): NodeMaterialConnectionPoint;
  62174. protected _buildBlock(state: NodeMaterialBuildState): this;
  62175. }
  62176. }
  62177. declare module BABYLON {
  62178. /**
  62179. * block used to Generate a Worley Noise 3D Noise Pattern
  62180. */
  62181. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62182. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62183. manhattanDistance: boolean;
  62184. /**
  62185. * Creates a new WorleyNoise3DBlock
  62186. * @param name defines the block name
  62187. */
  62188. constructor(name: string);
  62189. /**
  62190. * Gets the current class name
  62191. * @returns the class name
  62192. */
  62193. getClassName(): string;
  62194. /**
  62195. * Gets the seed input component
  62196. */
  62197. get seed(): NodeMaterialConnectionPoint;
  62198. /**
  62199. * Gets the jitter input component
  62200. */
  62201. get jitter(): NodeMaterialConnectionPoint;
  62202. /**
  62203. * Gets the output component
  62204. */
  62205. get output(): NodeMaterialConnectionPoint;
  62206. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62207. /**
  62208. * Exposes the properties to the UI?
  62209. */
  62210. protected _dumpPropertiesCode(): string;
  62211. /**
  62212. * Exposes the properties to the Seralize?
  62213. */
  62214. serialize(): any;
  62215. /**
  62216. * Exposes the properties to the deseralize?
  62217. */
  62218. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62219. }
  62220. }
  62221. declare module BABYLON {
  62222. /**
  62223. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62224. */
  62225. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62226. /**
  62227. * Creates a new SimplexPerlin3DBlock
  62228. * @param name defines the block name
  62229. */
  62230. constructor(name: string);
  62231. /**
  62232. * Gets the current class name
  62233. * @returns the class name
  62234. */
  62235. getClassName(): string;
  62236. /**
  62237. * Gets the seed operand input component
  62238. */
  62239. get seed(): NodeMaterialConnectionPoint;
  62240. /**
  62241. * Gets the output component
  62242. */
  62243. get output(): NodeMaterialConnectionPoint;
  62244. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62245. }
  62246. }
  62247. declare module BABYLON {
  62248. /**
  62249. * Block used to blend normals
  62250. */
  62251. export class NormalBlendBlock extends NodeMaterialBlock {
  62252. /**
  62253. * Creates a new NormalBlendBlock
  62254. * @param name defines the block name
  62255. */
  62256. constructor(name: string);
  62257. /**
  62258. * Gets the current class name
  62259. * @returns the class name
  62260. */
  62261. getClassName(): string;
  62262. /**
  62263. * Gets the first input component
  62264. */
  62265. get normalMap0(): NodeMaterialConnectionPoint;
  62266. /**
  62267. * Gets the second input component
  62268. */
  62269. get normalMap1(): NodeMaterialConnectionPoint;
  62270. /**
  62271. * Gets the output component
  62272. */
  62273. get output(): NodeMaterialConnectionPoint;
  62274. protected _buildBlock(state: NodeMaterialBuildState): this;
  62275. }
  62276. }
  62277. declare module BABYLON {
  62278. /**
  62279. * Block used to rotate a 2d vector by a given angle
  62280. */
  62281. export class Rotate2dBlock extends NodeMaterialBlock {
  62282. /**
  62283. * Creates a new Rotate2dBlock
  62284. * @param name defines the block name
  62285. */
  62286. constructor(name: string);
  62287. /**
  62288. * Gets the current class name
  62289. * @returns the class name
  62290. */
  62291. getClassName(): string;
  62292. /**
  62293. * Gets the input vector
  62294. */
  62295. get input(): NodeMaterialConnectionPoint;
  62296. /**
  62297. * Gets the input angle
  62298. */
  62299. get angle(): NodeMaterialConnectionPoint;
  62300. /**
  62301. * Gets the output component
  62302. */
  62303. get output(): NodeMaterialConnectionPoint;
  62304. autoConfigure(material: NodeMaterial): void;
  62305. protected _buildBlock(state: NodeMaterialBuildState): this;
  62306. }
  62307. }
  62308. declare module BABYLON {
  62309. /**
  62310. * Block used to get the reflected vector from a direction and a normal
  62311. */
  62312. export class ReflectBlock extends NodeMaterialBlock {
  62313. /**
  62314. * Creates a new ReflectBlock
  62315. * @param name defines the block name
  62316. */
  62317. constructor(name: string);
  62318. /**
  62319. * Gets the current class name
  62320. * @returns the class name
  62321. */
  62322. getClassName(): string;
  62323. /**
  62324. * Gets the incident component
  62325. */
  62326. get incident(): NodeMaterialConnectionPoint;
  62327. /**
  62328. * Gets the normal component
  62329. */
  62330. get normal(): NodeMaterialConnectionPoint;
  62331. /**
  62332. * Gets the output component
  62333. */
  62334. get output(): NodeMaterialConnectionPoint;
  62335. protected _buildBlock(state: NodeMaterialBuildState): this;
  62336. }
  62337. }
  62338. declare module BABYLON {
  62339. /**
  62340. * Block used to get the refracted vector from a direction and a normal
  62341. */
  62342. export class RefractBlock extends NodeMaterialBlock {
  62343. /**
  62344. * Creates a new RefractBlock
  62345. * @param name defines the block name
  62346. */
  62347. constructor(name: string);
  62348. /**
  62349. * Gets the current class name
  62350. * @returns the class name
  62351. */
  62352. getClassName(): string;
  62353. /**
  62354. * Gets the incident component
  62355. */
  62356. get incident(): NodeMaterialConnectionPoint;
  62357. /**
  62358. * Gets the normal component
  62359. */
  62360. get normal(): NodeMaterialConnectionPoint;
  62361. /**
  62362. * Gets the index of refraction component
  62363. */
  62364. get ior(): NodeMaterialConnectionPoint;
  62365. /**
  62366. * Gets the output component
  62367. */
  62368. get output(): NodeMaterialConnectionPoint;
  62369. protected _buildBlock(state: NodeMaterialBuildState): this;
  62370. }
  62371. }
  62372. declare module BABYLON {
  62373. /**
  62374. * Block used to desaturate a color
  62375. */
  62376. export class DesaturateBlock extends NodeMaterialBlock {
  62377. /**
  62378. * Creates a new DesaturateBlock
  62379. * @param name defines the block name
  62380. */
  62381. constructor(name: string);
  62382. /**
  62383. * Gets the current class name
  62384. * @returns the class name
  62385. */
  62386. getClassName(): string;
  62387. /**
  62388. * Gets the color operand input component
  62389. */
  62390. get color(): NodeMaterialConnectionPoint;
  62391. /**
  62392. * Gets the level operand input component
  62393. */
  62394. get level(): NodeMaterialConnectionPoint;
  62395. /**
  62396. * Gets the output component
  62397. */
  62398. get output(): NodeMaterialConnectionPoint;
  62399. protected _buildBlock(state: NodeMaterialBuildState): this;
  62400. }
  62401. }
  62402. declare module BABYLON {
  62403. /**
  62404. * Block used to implement the ambient occlusion module of the PBR material
  62405. */
  62406. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62407. /**
  62408. * Create a new AmbientOcclusionBlock
  62409. * @param name defines the block name
  62410. */
  62411. constructor(name: string);
  62412. /**
  62413. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62414. */
  62415. useAmbientInGrayScale: boolean;
  62416. /**
  62417. * Initialize the block and prepare the context for build
  62418. * @param state defines the state that will be used for the build
  62419. */
  62420. initialize(state: NodeMaterialBuildState): void;
  62421. /**
  62422. * Gets the current class name
  62423. * @returns the class name
  62424. */
  62425. getClassName(): string;
  62426. /**
  62427. * Gets the texture input component
  62428. */
  62429. get texture(): NodeMaterialConnectionPoint;
  62430. /**
  62431. * Gets the texture intensity component
  62432. */
  62433. get intensity(): NodeMaterialConnectionPoint;
  62434. /**
  62435. * Gets the direct light intensity input component
  62436. */
  62437. get directLightIntensity(): NodeMaterialConnectionPoint;
  62438. /**
  62439. * Gets the ambient occlusion object output component
  62440. */
  62441. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62442. /**
  62443. * Gets the main code of the block (fragment side)
  62444. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  62445. * @returns the shader code
  62446. */
  62447. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  62448. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62449. protected _buildBlock(state: NodeMaterialBuildState): this;
  62450. protected _dumpPropertiesCode(): string;
  62451. serialize(): any;
  62452. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62453. }
  62454. }
  62455. declare module BABYLON {
  62456. /**
  62457. * Block used to implement the reflection module of the PBR material
  62458. */
  62459. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  62460. /** @hidden */
  62461. _defineLODReflectionAlpha: string;
  62462. /** @hidden */
  62463. _defineLinearSpecularReflection: string;
  62464. private _vEnvironmentIrradianceName;
  62465. /** @hidden */
  62466. _vReflectionMicrosurfaceInfosName: string;
  62467. /** @hidden */
  62468. _vReflectionInfosName: string;
  62469. private _scene;
  62470. /**
  62471. * The three properties below are set by the main PBR block prior to calling methods of this class.
  62472. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62473. * It's less burden on the user side in the editor part.
  62474. */
  62475. /** @hidden */
  62476. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62477. /** @hidden */
  62478. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62479. /** @hidden */
  62480. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  62481. /**
  62482. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  62483. * diffuse part of the IBL.
  62484. */
  62485. useSphericalHarmonics: boolean;
  62486. /**
  62487. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  62488. */
  62489. forceIrradianceInFragment: boolean;
  62490. /**
  62491. * Create a new ReflectionBlock
  62492. * @param name defines the block name
  62493. */
  62494. constructor(name: string);
  62495. /**
  62496. * Gets the current class name
  62497. * @returns the class name
  62498. */
  62499. getClassName(): string;
  62500. /**
  62501. * Gets the position input component
  62502. */
  62503. get position(): NodeMaterialConnectionPoint;
  62504. /**
  62505. * Gets the world position input component
  62506. */
  62507. get worldPosition(): NodeMaterialConnectionPoint;
  62508. /**
  62509. * Gets the world normal input component
  62510. */
  62511. get worldNormal(): NodeMaterialConnectionPoint;
  62512. /**
  62513. * Gets the world input component
  62514. */
  62515. get world(): NodeMaterialConnectionPoint;
  62516. /**
  62517. * Gets the camera (or eye) position component
  62518. */
  62519. get cameraPosition(): NodeMaterialConnectionPoint;
  62520. /**
  62521. * Gets the view input component
  62522. */
  62523. get view(): NodeMaterialConnectionPoint;
  62524. /**
  62525. * Gets the color input component
  62526. */
  62527. get color(): NodeMaterialConnectionPoint;
  62528. /**
  62529. * Gets the reflection object output component
  62530. */
  62531. get reflection(): NodeMaterialConnectionPoint;
  62532. /**
  62533. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  62534. */
  62535. get hasTexture(): boolean;
  62536. /**
  62537. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  62538. */
  62539. get reflectionColor(): string;
  62540. protected _getTexture(): Nullable<BaseTexture>;
  62541. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62542. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62543. /**
  62544. * Gets the code to inject in the vertex shader
  62545. * @param state current state of the node material building
  62546. * @returns the shader code
  62547. */
  62548. handleVertexSide(state: NodeMaterialBuildState): string;
  62549. /**
  62550. * Gets the main code of the block (fragment side)
  62551. * @param state current state of the node material building
  62552. * @param normalVarName name of the existing variable corresponding to the normal
  62553. * @returns the shader code
  62554. */
  62555. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  62556. protected _buildBlock(state: NodeMaterialBuildState): this;
  62557. protected _dumpPropertiesCode(): string;
  62558. serialize(): any;
  62559. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62560. }
  62561. }
  62562. declare module BABYLON {
  62563. /**
  62564. * Block used to implement the sheen module of the PBR material
  62565. */
  62566. export class SheenBlock extends NodeMaterialBlock {
  62567. /**
  62568. * Create a new SheenBlock
  62569. * @param name defines the block name
  62570. */
  62571. constructor(name: string);
  62572. /**
  62573. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  62574. * It allows the strength of the sheen effect to not depend on the base color of the material,
  62575. * making it easier to setup and tweak the effect
  62576. */
  62577. albedoScaling: boolean;
  62578. /**
  62579. * Defines if the sheen is linked to the sheen color.
  62580. */
  62581. linkSheenWithAlbedo: boolean;
  62582. /**
  62583. * Initialize the block and prepare the context for build
  62584. * @param state defines the state that will be used for the build
  62585. */
  62586. initialize(state: NodeMaterialBuildState): void;
  62587. /**
  62588. * Gets the current class name
  62589. * @returns the class name
  62590. */
  62591. getClassName(): string;
  62592. /**
  62593. * Gets the intensity input component
  62594. */
  62595. get intensity(): NodeMaterialConnectionPoint;
  62596. /**
  62597. * Gets the color input component
  62598. */
  62599. get color(): NodeMaterialConnectionPoint;
  62600. /**
  62601. * Gets the roughness input component
  62602. */
  62603. get roughness(): NodeMaterialConnectionPoint;
  62604. /**
  62605. * Gets the texture input component
  62606. */
  62607. get texture(): NodeMaterialConnectionPoint;
  62608. /**
  62609. * Gets the sheen object output component
  62610. */
  62611. get sheen(): NodeMaterialConnectionPoint;
  62612. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62613. /**
  62614. * Gets the main code of the block (fragment side)
  62615. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62616. * @returns the shader code
  62617. */
  62618. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  62619. protected _buildBlock(state: NodeMaterialBuildState): this;
  62620. protected _dumpPropertiesCode(): string;
  62621. serialize(): any;
  62622. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62623. }
  62624. }
  62625. declare module BABYLON {
  62626. /**
  62627. * Block used to implement the reflectivity module of the PBR material
  62628. */
  62629. export class ReflectivityBlock extends NodeMaterialBlock {
  62630. /**
  62631. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  62632. */
  62633. useAmbientOcclusionFromMetallicTextureRed: boolean;
  62634. /**
  62635. * Specifies if the metallic texture contains the metallness information in its blue channel.
  62636. */
  62637. useMetallnessFromMetallicTextureBlue: boolean;
  62638. /**
  62639. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  62640. */
  62641. useRoughnessFromMetallicTextureAlpha: boolean;
  62642. /**
  62643. * Specifies if the metallic texture contains the roughness information in its green channel.
  62644. */
  62645. useRoughnessFromMetallicTextureGreen: boolean;
  62646. /**
  62647. * Create a new ReflectivityBlock
  62648. * @param name defines the block name
  62649. */
  62650. constructor(name: string);
  62651. /**
  62652. * Initialize the block and prepare the context for build
  62653. * @param state defines the state that will be used for the build
  62654. */
  62655. initialize(state: NodeMaterialBuildState): void;
  62656. /**
  62657. * Gets the current class name
  62658. * @returns the class name
  62659. */
  62660. getClassName(): string;
  62661. /**
  62662. * Gets the metallic input component
  62663. */
  62664. get metallic(): NodeMaterialConnectionPoint;
  62665. /**
  62666. * Gets the roughness input component
  62667. */
  62668. get roughness(): NodeMaterialConnectionPoint;
  62669. /**
  62670. * Gets the texture input component
  62671. */
  62672. get texture(): NodeMaterialConnectionPoint;
  62673. /**
  62674. * Gets the reflectivity object output component
  62675. */
  62676. get reflectivity(): NodeMaterialConnectionPoint;
  62677. /**
  62678. * Gets the main code of the block (fragment side)
  62679. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  62680. * @returns the shader code
  62681. */
  62682. getCode(aoIntensityVarName: string): string;
  62683. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62684. protected _buildBlock(state: NodeMaterialBuildState): this;
  62685. protected _dumpPropertiesCode(): string;
  62686. serialize(): any;
  62687. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62688. }
  62689. }
  62690. declare module BABYLON {
  62691. /**
  62692. * Block used to implement the anisotropy module of the PBR material
  62693. */
  62694. export class AnisotropyBlock extends NodeMaterialBlock {
  62695. /**
  62696. * The two properties below are set by the main PBR block prior to calling methods of this class.
  62697. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62698. * It's less burden on the user side in the editor part.
  62699. */
  62700. /** @hidden */
  62701. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62702. /** @hidden */
  62703. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62704. /**
  62705. * Create a new AnisotropyBlock
  62706. * @param name defines the block name
  62707. */
  62708. constructor(name: string);
  62709. /**
  62710. * Initialize the block and prepare the context for build
  62711. * @param state defines the state that will be used for the build
  62712. */
  62713. initialize(state: NodeMaterialBuildState): void;
  62714. /**
  62715. * Gets the current class name
  62716. * @returns the class name
  62717. */
  62718. getClassName(): string;
  62719. /**
  62720. * Gets the intensity input component
  62721. */
  62722. get intensity(): NodeMaterialConnectionPoint;
  62723. /**
  62724. * Gets the direction input component
  62725. */
  62726. get direction(): NodeMaterialConnectionPoint;
  62727. /**
  62728. * Gets the texture input component
  62729. */
  62730. get texture(): NodeMaterialConnectionPoint;
  62731. /**
  62732. * Gets the uv input component
  62733. */
  62734. get uv(): NodeMaterialConnectionPoint;
  62735. /**
  62736. * Gets the worldTangent input component
  62737. */
  62738. get worldTangent(): NodeMaterialConnectionPoint;
  62739. /**
  62740. * Gets the anisotropy object output component
  62741. */
  62742. get anisotropy(): NodeMaterialConnectionPoint;
  62743. private _generateTBNSpace;
  62744. /**
  62745. * Gets the main code of the block (fragment side)
  62746. * @param state current state of the node material building
  62747. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62748. * @returns the shader code
  62749. */
  62750. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  62751. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62752. protected _buildBlock(state: NodeMaterialBuildState): this;
  62753. }
  62754. }
  62755. declare module BABYLON {
  62756. /**
  62757. * Block used to implement the clear coat module of the PBR material
  62758. */
  62759. export class ClearCoatBlock extends NodeMaterialBlock {
  62760. private _scene;
  62761. /**
  62762. * Create a new ClearCoatBlock
  62763. * @param name defines the block name
  62764. */
  62765. constructor(name: string);
  62766. /**
  62767. * Initialize the block and prepare the context for build
  62768. * @param state defines the state that will be used for the build
  62769. */
  62770. initialize(state: NodeMaterialBuildState): void;
  62771. /**
  62772. * Gets the current class name
  62773. * @returns the class name
  62774. */
  62775. getClassName(): string;
  62776. /**
  62777. * Gets the intensity input component
  62778. */
  62779. get intensity(): NodeMaterialConnectionPoint;
  62780. /**
  62781. * Gets the roughness input component
  62782. */
  62783. get roughness(): NodeMaterialConnectionPoint;
  62784. /**
  62785. * Gets the ior input component
  62786. */
  62787. get ior(): NodeMaterialConnectionPoint;
  62788. /**
  62789. * Gets the texture input component
  62790. */
  62791. get texture(): NodeMaterialConnectionPoint;
  62792. /**
  62793. * Gets the bump texture input component
  62794. */
  62795. get bumpTexture(): NodeMaterialConnectionPoint;
  62796. /**
  62797. * Gets the uv input component
  62798. */
  62799. get uv(): NodeMaterialConnectionPoint;
  62800. /**
  62801. * Gets the tint color input component
  62802. */
  62803. get tintColor(): NodeMaterialConnectionPoint;
  62804. /**
  62805. * Gets the tint "at distance" input component
  62806. */
  62807. get tintAtDistance(): NodeMaterialConnectionPoint;
  62808. /**
  62809. * Gets the tint thickness input component
  62810. */
  62811. get tintThickness(): NodeMaterialConnectionPoint;
  62812. /**
  62813. * Gets the tint texture input component
  62814. */
  62815. get tintTexture(): NodeMaterialConnectionPoint;
  62816. /**
  62817. * Gets the world tangent input component
  62818. */
  62819. get worldTangent(): NodeMaterialConnectionPoint;
  62820. /**
  62821. * Gets the clear coat object output component
  62822. */
  62823. get clearcoat(): NodeMaterialConnectionPoint;
  62824. autoConfigure(material: NodeMaterial): void;
  62825. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62826. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62827. private _generateTBNSpace;
  62828. /**
  62829. * Gets the main code of the block (fragment side)
  62830. * @param state current state of the node material building
  62831. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  62832. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62833. * @param worldPosVarName name of the variable holding the world position
  62834. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62835. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  62836. * @param worldNormalVarName name of the variable holding the world normal
  62837. * @returns the shader code
  62838. */
  62839. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  62840. protected _buildBlock(state: NodeMaterialBuildState): this;
  62841. }
  62842. }
  62843. declare module BABYLON {
  62844. /**
  62845. * Block used to implement the sub surface module of the PBR material
  62846. */
  62847. export class SubSurfaceBlock extends NodeMaterialBlock {
  62848. /**
  62849. * Create a new SubSurfaceBlock
  62850. * @param name defines the block name
  62851. */
  62852. constructor(name: string);
  62853. /**
  62854. * Stores the intensity of the different subsurface effects in the thickness texture.
  62855. * * the green channel is the translucency intensity.
  62856. * * the blue channel is the scattering intensity.
  62857. * * the alpha channel is the refraction intensity.
  62858. */
  62859. useMaskFromThicknessTexture: boolean;
  62860. /**
  62861. * Initialize the block and prepare the context for build
  62862. * @param state defines the state that will be used for the build
  62863. */
  62864. initialize(state: NodeMaterialBuildState): void;
  62865. /**
  62866. * Gets the current class name
  62867. * @returns the class name
  62868. */
  62869. getClassName(): string;
  62870. /**
  62871. * Gets the min thickness input component
  62872. */
  62873. get minThickness(): NodeMaterialConnectionPoint;
  62874. /**
  62875. * Gets the max thickness input component
  62876. */
  62877. get maxThickness(): NodeMaterialConnectionPoint;
  62878. /**
  62879. * Gets the thickness texture component
  62880. */
  62881. get thicknessTexture(): NodeMaterialConnectionPoint;
  62882. /**
  62883. * Gets the tint color input component
  62884. */
  62885. get tintColor(): NodeMaterialConnectionPoint;
  62886. /**
  62887. * Gets the translucency intensity input component
  62888. */
  62889. get translucencyIntensity(): NodeMaterialConnectionPoint;
  62890. /**
  62891. * Gets the translucency diffusion distance input component
  62892. */
  62893. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  62894. /**
  62895. * Gets the refraction object parameters
  62896. */
  62897. get refraction(): NodeMaterialConnectionPoint;
  62898. /**
  62899. * Gets the sub surface object output component
  62900. */
  62901. get subsurface(): NodeMaterialConnectionPoint;
  62902. autoConfigure(material: NodeMaterial): void;
  62903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62904. /**
  62905. * Gets the main code of the block (fragment side)
  62906. * @param state current state of the node material building
  62907. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  62908. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62909. * @param worldPosVarName name of the variable holding the world position
  62910. * @returns the shader code
  62911. */
  62912. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  62913. protected _buildBlock(state: NodeMaterialBuildState): this;
  62914. }
  62915. }
  62916. declare module BABYLON {
  62917. /**
  62918. * Block used to implement the PBR metallic/roughness model
  62919. */
  62920. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  62921. /**
  62922. * Gets or sets the light associated with this block
  62923. */
  62924. light: Nullable<Light>;
  62925. private _lightId;
  62926. private _scene;
  62927. private _environmentBRDFTexture;
  62928. private _environmentBrdfSamplerName;
  62929. private _vNormalWName;
  62930. private _invertNormalName;
  62931. /**
  62932. * Create a new ReflectionBlock
  62933. * @param name defines the block name
  62934. */
  62935. constructor(name: string);
  62936. /**
  62937. * Intensity of the direct lights e.g. the four lights available in your scene.
  62938. * This impacts both the direct diffuse and specular highlights.
  62939. */
  62940. directIntensity: number;
  62941. /**
  62942. * Intensity of the environment e.g. how much the environment will light the object
  62943. * either through harmonics for rough material or through the refelction for shiny ones.
  62944. */
  62945. environmentIntensity: number;
  62946. /**
  62947. * This is a special control allowing the reduction of the specular highlights coming from the
  62948. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  62949. */
  62950. specularIntensity: number;
  62951. /**
  62952. * Defines the falloff type used in this material.
  62953. * It by default is Physical.
  62954. */
  62955. lightFalloff: number;
  62956. /**
  62957. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  62958. */
  62959. useAlphaFromAlbedoTexture: boolean;
  62960. /**
  62961. * Specifies that alpha test should be used
  62962. */
  62963. useAlphaTest: boolean;
  62964. /**
  62965. * Defines the alpha limits in alpha test mode.
  62966. */
  62967. alphaTestCutoff: number;
  62968. /**
  62969. * Specifies that alpha blending should be used
  62970. */
  62971. useAlphaBlending: boolean;
  62972. /**
  62973. * Defines if the alpha value should be determined via the rgb values.
  62974. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  62975. */
  62976. opacityRGB: boolean;
  62977. /**
  62978. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  62979. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  62980. */
  62981. useRadianceOverAlpha: boolean;
  62982. /**
  62983. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  62984. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  62985. */
  62986. useSpecularOverAlpha: boolean;
  62987. /**
  62988. * Enables specular anti aliasing in the PBR shader.
  62989. * It will both interacts on the Geometry for analytical and IBL lighting.
  62990. * It also prefilter the roughness map based on the bump values.
  62991. */
  62992. enableSpecularAntiAliasing: boolean;
  62993. /**
  62994. * Defines if the material uses energy conservation.
  62995. */
  62996. useEnergyConservation: boolean;
  62997. /**
  62998. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  62999. * too much the area relying on ambient texture to define their ambient occlusion.
  63000. */
  63001. useRadianceOcclusion: boolean;
  63002. /**
  63003. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63004. * makes the reflect vector face the model (under horizon).
  63005. */
  63006. useHorizonOcclusion: boolean;
  63007. /**
  63008. * If set to true, no lighting calculations will be applied.
  63009. */
  63010. unlit: boolean;
  63011. /**
  63012. * Force normal to face away from face.
  63013. */
  63014. forceNormalForward: boolean;
  63015. /**
  63016. * Defines the material debug mode.
  63017. * It helps seeing only some components of the material while troubleshooting.
  63018. */
  63019. debugMode: number;
  63020. /**
  63021. * Specify from where on screen the debug mode should start.
  63022. * The value goes from -1 (full screen) to 1 (not visible)
  63023. * It helps with side by side comparison against the final render
  63024. * This defaults to 0
  63025. */
  63026. debugLimit: number;
  63027. /**
  63028. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63029. * You can use the factor to better multiply the final value.
  63030. */
  63031. debugFactor: number;
  63032. /**
  63033. * Initialize the block and prepare the context for build
  63034. * @param state defines the state that will be used for the build
  63035. */
  63036. initialize(state: NodeMaterialBuildState): void;
  63037. /**
  63038. * Gets the current class name
  63039. * @returns the class name
  63040. */
  63041. getClassName(): string;
  63042. /**
  63043. * Gets the world position input component
  63044. */
  63045. get worldPosition(): NodeMaterialConnectionPoint;
  63046. /**
  63047. * Gets the world normal input component
  63048. */
  63049. get worldNormal(): NodeMaterialConnectionPoint;
  63050. /**
  63051. * Gets the perturbed normal input component
  63052. */
  63053. get perturbedNormal(): NodeMaterialConnectionPoint;
  63054. /**
  63055. * Gets the camera position input component
  63056. */
  63057. get cameraPosition(): NodeMaterialConnectionPoint;
  63058. /**
  63059. * Gets the base color input component
  63060. */
  63061. get baseColor(): NodeMaterialConnectionPoint;
  63062. /**
  63063. * Gets the base texture input component
  63064. */
  63065. get baseTexture(): NodeMaterialConnectionPoint;
  63066. /**
  63067. * Gets the opacity texture input component
  63068. */
  63069. get opacityTexture(): NodeMaterialConnectionPoint;
  63070. /**
  63071. * Gets the ambient color input component
  63072. */
  63073. get ambientColor(): NodeMaterialConnectionPoint;
  63074. /**
  63075. * Gets the reflectivity object parameters
  63076. */
  63077. get reflectivity(): NodeMaterialConnectionPoint;
  63078. /**
  63079. * Gets the ambient occlusion object parameters
  63080. */
  63081. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63082. /**
  63083. * Gets the reflection object parameters
  63084. */
  63085. get reflection(): NodeMaterialConnectionPoint;
  63086. /**
  63087. * Gets the sheen object parameters
  63088. */
  63089. get sheen(): NodeMaterialConnectionPoint;
  63090. /**
  63091. * Gets the clear coat object parameters
  63092. */
  63093. get clearcoat(): NodeMaterialConnectionPoint;
  63094. /**
  63095. * Gets the sub surface object parameters
  63096. */
  63097. get subsurface(): NodeMaterialConnectionPoint;
  63098. /**
  63099. * Gets the anisotropy object parameters
  63100. */
  63101. get anisotropy(): NodeMaterialConnectionPoint;
  63102. /**
  63103. * Gets the ambient output component
  63104. */
  63105. get ambient(): NodeMaterialConnectionPoint;
  63106. /**
  63107. * Gets the diffuse output component
  63108. */
  63109. get diffuse(): NodeMaterialConnectionPoint;
  63110. /**
  63111. * Gets the specular output component
  63112. */
  63113. get specular(): NodeMaterialConnectionPoint;
  63114. /**
  63115. * Gets the sheen output component
  63116. */
  63117. get sheenDir(): NodeMaterialConnectionPoint;
  63118. /**
  63119. * Gets the clear coat output component
  63120. */
  63121. get clearcoatDir(): NodeMaterialConnectionPoint;
  63122. /**
  63123. * Gets the indirect diffuse output component
  63124. */
  63125. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63126. /**
  63127. * Gets the indirect specular output component
  63128. */
  63129. get specularIndirect(): NodeMaterialConnectionPoint;
  63130. /**
  63131. * Gets the indirect sheen output component
  63132. */
  63133. get sheenIndirect(): NodeMaterialConnectionPoint;
  63134. /**
  63135. * Gets the indirect clear coat output component
  63136. */
  63137. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63138. /**
  63139. * Gets the refraction output component
  63140. */
  63141. get refraction(): NodeMaterialConnectionPoint;
  63142. /**
  63143. * Gets the global lighting output component
  63144. */
  63145. get lighting(): NodeMaterialConnectionPoint;
  63146. /**
  63147. * Gets the shadow output component
  63148. */
  63149. get shadow(): NodeMaterialConnectionPoint;
  63150. /**
  63151. * Gets the alpha output component
  63152. */
  63153. get alpha(): NodeMaterialConnectionPoint;
  63154. autoConfigure(material: NodeMaterial): void;
  63155. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63156. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63157. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63158. private _injectVertexCode;
  63159. /**
  63160. * Gets the code corresponding to the albedo/opacity module
  63161. * @returns the shader code
  63162. */
  63163. getAlbedoOpacityCode(): string;
  63164. protected _buildBlock(state: NodeMaterialBuildState): this;
  63165. protected _dumpPropertiesCode(): string;
  63166. serialize(): any;
  63167. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63168. }
  63169. }
  63170. declare module BABYLON {
  63171. /**
  63172. * Block used to compute value of one parameter modulo another
  63173. */
  63174. export class ModBlock extends NodeMaterialBlock {
  63175. /**
  63176. * Creates a new ModBlock
  63177. * @param name defines the block name
  63178. */
  63179. constructor(name: string);
  63180. /**
  63181. * Gets the current class name
  63182. * @returns the class name
  63183. */
  63184. getClassName(): string;
  63185. /**
  63186. * Gets the left operand input component
  63187. */
  63188. get left(): NodeMaterialConnectionPoint;
  63189. /**
  63190. * Gets the right operand input component
  63191. */
  63192. get right(): NodeMaterialConnectionPoint;
  63193. /**
  63194. * Gets the output component
  63195. */
  63196. get output(): NodeMaterialConnectionPoint;
  63197. protected _buildBlock(state: NodeMaterialBuildState): this;
  63198. }
  63199. }
  63200. declare module BABYLON {
  63201. /**
  63202. * Helper class to push actions to a pool of workers.
  63203. */
  63204. export class WorkerPool implements IDisposable {
  63205. private _workerInfos;
  63206. private _pendingActions;
  63207. /**
  63208. * Constructor
  63209. * @param workers Array of workers to use for actions
  63210. */
  63211. constructor(workers: Array<Worker>);
  63212. /**
  63213. * Terminates all workers and clears any pending actions.
  63214. */
  63215. dispose(): void;
  63216. /**
  63217. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63218. * pended until a worker has completed its action.
  63219. * @param action The action to perform. Call onComplete when the action is complete.
  63220. */
  63221. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63222. private _execute;
  63223. }
  63224. }
  63225. declare module BABYLON {
  63226. /**
  63227. * Configuration for Draco compression
  63228. */
  63229. export interface IDracoCompressionConfiguration {
  63230. /**
  63231. * Configuration for the decoder.
  63232. */
  63233. decoder: {
  63234. /**
  63235. * The url to the WebAssembly module.
  63236. */
  63237. wasmUrl?: string;
  63238. /**
  63239. * The url to the WebAssembly binary.
  63240. */
  63241. wasmBinaryUrl?: string;
  63242. /**
  63243. * The url to the fallback JavaScript module.
  63244. */
  63245. fallbackUrl?: string;
  63246. };
  63247. }
  63248. /**
  63249. * Draco compression (https://google.github.io/draco/)
  63250. *
  63251. * This class wraps the Draco module.
  63252. *
  63253. * **Encoder**
  63254. *
  63255. * The encoder is not currently implemented.
  63256. *
  63257. * **Decoder**
  63258. *
  63259. * 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.
  63260. *
  63261. * To update the configuration, use the following code:
  63262. * ```javascript
  63263. * DracoCompression.Configuration = {
  63264. * decoder: {
  63265. * wasmUrl: "<url to the WebAssembly library>",
  63266. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63267. * fallbackUrl: "<url to the fallback JavaScript library>",
  63268. * }
  63269. * };
  63270. * ```
  63271. *
  63272. * 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.
  63273. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63274. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63275. *
  63276. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63277. * ```javascript
  63278. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63279. * ```
  63280. *
  63281. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63282. */
  63283. export class DracoCompression implements IDisposable {
  63284. private _workerPoolPromise?;
  63285. private _decoderModulePromise?;
  63286. /**
  63287. * The configuration. Defaults to the following urls:
  63288. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63289. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63290. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63291. */
  63292. static Configuration: IDracoCompressionConfiguration;
  63293. /**
  63294. * Returns true if the decoder configuration is available.
  63295. */
  63296. static get DecoderAvailable(): boolean;
  63297. /**
  63298. * Default number of workers to create when creating the draco compression object.
  63299. */
  63300. static DefaultNumWorkers: number;
  63301. private static GetDefaultNumWorkers;
  63302. private static _Default;
  63303. /**
  63304. * Default instance for the draco compression object.
  63305. */
  63306. static get Default(): DracoCompression;
  63307. /**
  63308. * Constructor
  63309. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63310. */
  63311. constructor(numWorkers?: number);
  63312. /**
  63313. * Stop all async operations and release resources.
  63314. */
  63315. dispose(): void;
  63316. /**
  63317. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63318. * @returns a promise that resolves when ready
  63319. */
  63320. whenReadyAsync(): Promise<void>;
  63321. /**
  63322. * Decode Draco compressed mesh data to vertex data.
  63323. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63324. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63325. * @returns A promise that resolves with the decoded vertex data
  63326. */
  63327. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63328. [kind: string]: number;
  63329. }): Promise<VertexData>;
  63330. }
  63331. }
  63332. declare module BABYLON {
  63333. /**
  63334. * Class for building Constructive Solid Geometry
  63335. */
  63336. export class CSG {
  63337. private polygons;
  63338. /**
  63339. * The world matrix
  63340. */
  63341. matrix: Matrix;
  63342. /**
  63343. * Stores the position
  63344. */
  63345. position: Vector3;
  63346. /**
  63347. * Stores the rotation
  63348. */
  63349. rotation: Vector3;
  63350. /**
  63351. * Stores the rotation quaternion
  63352. */
  63353. rotationQuaternion: Nullable<Quaternion>;
  63354. /**
  63355. * Stores the scaling vector
  63356. */
  63357. scaling: Vector3;
  63358. /**
  63359. * Convert the Mesh to CSG
  63360. * @param mesh The Mesh to convert to CSG
  63361. * @returns A new CSG from the Mesh
  63362. */
  63363. static FromMesh(mesh: Mesh): CSG;
  63364. /**
  63365. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63366. * @param polygons Polygons used to construct a CSG solid
  63367. */
  63368. private static FromPolygons;
  63369. /**
  63370. * Clones, or makes a deep copy, of the CSG
  63371. * @returns A new CSG
  63372. */
  63373. clone(): CSG;
  63374. /**
  63375. * Unions this CSG with another CSG
  63376. * @param csg The CSG to union against this CSG
  63377. * @returns The unioned CSG
  63378. */
  63379. union(csg: CSG): CSG;
  63380. /**
  63381. * Unions this CSG with another CSG in place
  63382. * @param csg The CSG to union against this CSG
  63383. */
  63384. unionInPlace(csg: CSG): void;
  63385. /**
  63386. * Subtracts this CSG with another CSG
  63387. * @param csg The CSG to subtract against this CSG
  63388. * @returns A new CSG
  63389. */
  63390. subtract(csg: CSG): CSG;
  63391. /**
  63392. * Subtracts this CSG with another CSG in place
  63393. * @param csg The CSG to subtact against this CSG
  63394. */
  63395. subtractInPlace(csg: CSG): void;
  63396. /**
  63397. * Intersect this CSG with another CSG
  63398. * @param csg The CSG to intersect against this CSG
  63399. * @returns A new CSG
  63400. */
  63401. intersect(csg: CSG): CSG;
  63402. /**
  63403. * Intersects this CSG with another CSG in place
  63404. * @param csg The CSG to intersect against this CSG
  63405. */
  63406. intersectInPlace(csg: CSG): void;
  63407. /**
  63408. * Return a new CSG solid with solid and empty space switched. This solid is
  63409. * not modified.
  63410. * @returns A new CSG solid with solid and empty space switched
  63411. */
  63412. inverse(): CSG;
  63413. /**
  63414. * Inverses the CSG in place
  63415. */
  63416. inverseInPlace(): void;
  63417. /**
  63418. * This is used to keep meshes transformations so they can be restored
  63419. * when we build back a Babylon Mesh
  63420. * NB : All CSG operations are performed in world coordinates
  63421. * @param csg The CSG to copy the transform attributes from
  63422. * @returns This CSG
  63423. */
  63424. copyTransformAttributes(csg: CSG): CSG;
  63425. /**
  63426. * Build Raw mesh from CSG
  63427. * Coordinates here are in world space
  63428. * @param name The name of the mesh geometry
  63429. * @param scene The Scene
  63430. * @param keepSubMeshes Specifies if the submeshes should be kept
  63431. * @returns A new Mesh
  63432. */
  63433. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63434. /**
  63435. * Build Mesh from CSG taking material and transforms into account
  63436. * @param name The name of the Mesh
  63437. * @param material The material of the Mesh
  63438. * @param scene The Scene
  63439. * @param keepSubMeshes Specifies if submeshes should be kept
  63440. * @returns The new Mesh
  63441. */
  63442. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63443. }
  63444. }
  63445. declare module BABYLON {
  63446. /**
  63447. * Class used to create a trail following a mesh
  63448. */
  63449. export class TrailMesh extends Mesh {
  63450. private _generator;
  63451. private _autoStart;
  63452. private _running;
  63453. private _diameter;
  63454. private _length;
  63455. private _sectionPolygonPointsCount;
  63456. private _sectionVectors;
  63457. private _sectionNormalVectors;
  63458. private _beforeRenderObserver;
  63459. /**
  63460. * @constructor
  63461. * @param name The value used by scene.getMeshByName() to do a lookup.
  63462. * @param generator The mesh or transform node to generate a trail.
  63463. * @param scene The scene to add this mesh to.
  63464. * @param diameter Diameter of trailing mesh. Default is 1.
  63465. * @param length Length of trailing mesh. Default is 60.
  63466. * @param autoStart Automatically start trailing mesh. Default true.
  63467. */
  63468. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63469. /**
  63470. * "TrailMesh"
  63471. * @returns "TrailMesh"
  63472. */
  63473. getClassName(): string;
  63474. private _createMesh;
  63475. /**
  63476. * Start trailing mesh.
  63477. */
  63478. start(): void;
  63479. /**
  63480. * Stop trailing mesh.
  63481. */
  63482. stop(): void;
  63483. /**
  63484. * Update trailing mesh geometry.
  63485. */
  63486. update(): void;
  63487. /**
  63488. * Returns a new TrailMesh object.
  63489. * @param name is a string, the name given to the new mesh
  63490. * @param newGenerator use new generator object for cloned trail mesh
  63491. * @returns a new mesh
  63492. */
  63493. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63494. /**
  63495. * Serializes this trail mesh
  63496. * @param serializationObject object to write serialization to
  63497. */
  63498. serialize(serializationObject: any): void;
  63499. /**
  63500. * Parses a serialized trail mesh
  63501. * @param parsedMesh the serialized mesh
  63502. * @param scene the scene to create the trail mesh in
  63503. * @returns the created trail mesh
  63504. */
  63505. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63506. }
  63507. }
  63508. declare module BABYLON {
  63509. /**
  63510. * Class containing static functions to help procedurally build meshes
  63511. */
  63512. export class TiledBoxBuilder {
  63513. /**
  63514. * Creates a box mesh
  63515. * 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)
  63516. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63518. * * 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
  63519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63520. * @param name defines the name of the mesh
  63521. * @param options defines the options used to create the mesh
  63522. * @param scene defines the hosting scene
  63523. * @returns the box mesh
  63524. */
  63525. static CreateTiledBox(name: string, options: {
  63526. pattern?: number;
  63527. width?: number;
  63528. height?: number;
  63529. depth?: number;
  63530. tileSize?: number;
  63531. tileWidth?: number;
  63532. tileHeight?: number;
  63533. alignHorizontal?: number;
  63534. alignVertical?: number;
  63535. faceUV?: Vector4[];
  63536. faceColors?: Color4[];
  63537. sideOrientation?: number;
  63538. updatable?: boolean;
  63539. }, scene?: Nullable<Scene>): Mesh;
  63540. }
  63541. }
  63542. declare module BABYLON {
  63543. /**
  63544. * Class containing static functions to help procedurally build meshes
  63545. */
  63546. export class TorusKnotBuilder {
  63547. /**
  63548. * Creates a torus knot mesh
  63549. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63550. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63551. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63552. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63554. * * 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
  63555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63556. * @param name defines the name of the mesh
  63557. * @param options defines the options used to create the mesh
  63558. * @param scene defines the hosting scene
  63559. * @returns the torus knot mesh
  63560. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63561. */
  63562. static CreateTorusKnot(name: string, options: {
  63563. radius?: number;
  63564. tube?: number;
  63565. radialSegments?: number;
  63566. tubularSegments?: number;
  63567. p?: number;
  63568. q?: number;
  63569. updatable?: boolean;
  63570. sideOrientation?: number;
  63571. frontUVs?: Vector4;
  63572. backUVs?: Vector4;
  63573. }, scene: any): Mesh;
  63574. }
  63575. }
  63576. declare module BABYLON {
  63577. /**
  63578. * Polygon
  63579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63580. */
  63581. export class Polygon {
  63582. /**
  63583. * Creates a rectangle
  63584. * @param xmin bottom X coord
  63585. * @param ymin bottom Y coord
  63586. * @param xmax top X coord
  63587. * @param ymax top Y coord
  63588. * @returns points that make the resulting rectation
  63589. */
  63590. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63591. /**
  63592. * Creates a circle
  63593. * @param radius radius of circle
  63594. * @param cx scale in x
  63595. * @param cy scale in y
  63596. * @param numberOfSides number of sides that make up the circle
  63597. * @returns points that make the resulting circle
  63598. */
  63599. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63600. /**
  63601. * Creates a polygon from input string
  63602. * @param input Input polygon data
  63603. * @returns the parsed points
  63604. */
  63605. static Parse(input: string): Vector2[];
  63606. /**
  63607. * Starts building a polygon from x and y coordinates
  63608. * @param x x coordinate
  63609. * @param y y coordinate
  63610. * @returns the started path2
  63611. */
  63612. static StartingAt(x: number, y: number): Path2;
  63613. }
  63614. /**
  63615. * Builds a polygon
  63616. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63617. */
  63618. export class PolygonMeshBuilder {
  63619. private _points;
  63620. private _outlinepoints;
  63621. private _holes;
  63622. private _name;
  63623. private _scene;
  63624. private _epoints;
  63625. private _eholes;
  63626. private _addToepoint;
  63627. /**
  63628. * Babylon reference to the earcut plugin.
  63629. */
  63630. bjsEarcut: any;
  63631. /**
  63632. * Creates a PolygonMeshBuilder
  63633. * @param name name of the builder
  63634. * @param contours Path of the polygon
  63635. * @param scene scene to add to when creating the mesh
  63636. * @param earcutInjection can be used to inject your own earcut reference
  63637. */
  63638. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63639. /**
  63640. * Adds a whole within the polygon
  63641. * @param hole Array of points defining the hole
  63642. * @returns this
  63643. */
  63644. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63645. /**
  63646. * Creates the polygon
  63647. * @param updatable If the mesh should be updatable
  63648. * @param depth The depth of the mesh created
  63649. * @returns the created mesh
  63650. */
  63651. build(updatable?: boolean, depth?: number): Mesh;
  63652. /**
  63653. * Creates the polygon
  63654. * @param depth The depth of the mesh created
  63655. * @returns the created VertexData
  63656. */
  63657. buildVertexData(depth?: number): VertexData;
  63658. /**
  63659. * Adds a side to the polygon
  63660. * @param positions points that make the polygon
  63661. * @param normals normals of the polygon
  63662. * @param uvs uvs of the polygon
  63663. * @param indices indices of the polygon
  63664. * @param bounds bounds of the polygon
  63665. * @param points points of the polygon
  63666. * @param depth depth of the polygon
  63667. * @param flip flip of the polygon
  63668. */
  63669. private addSide;
  63670. }
  63671. }
  63672. declare module BABYLON {
  63673. /**
  63674. * Class containing static functions to help procedurally build meshes
  63675. */
  63676. export class PolygonBuilder {
  63677. /**
  63678. * Creates a polygon mesh
  63679. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63680. * * 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
  63681. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63683. * * 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)
  63684. * * Remember you can only change the shape positions, not their number when updating a polygon
  63685. * @param name defines the name of the mesh
  63686. * @param options defines the options used to create the mesh
  63687. * @param scene defines the hosting scene
  63688. * @param earcutInjection can be used to inject your own earcut reference
  63689. * @returns the polygon mesh
  63690. */
  63691. static CreatePolygon(name: string, options: {
  63692. shape: Vector3[];
  63693. holes?: Vector3[][];
  63694. depth?: number;
  63695. faceUV?: Vector4[];
  63696. faceColors?: Color4[];
  63697. updatable?: boolean;
  63698. sideOrientation?: number;
  63699. frontUVs?: Vector4;
  63700. backUVs?: Vector4;
  63701. wrap?: boolean;
  63702. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63703. /**
  63704. * Creates an extruded polygon mesh, with depth in the Y direction.
  63705. * * 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)
  63706. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63707. * @param name defines the name of the mesh
  63708. * @param options defines the options used to create the mesh
  63709. * @param scene defines the hosting scene
  63710. * @param earcutInjection can be used to inject your own earcut reference
  63711. * @returns the polygon mesh
  63712. */
  63713. static ExtrudePolygon(name: string, options: {
  63714. shape: Vector3[];
  63715. holes?: Vector3[][];
  63716. depth?: number;
  63717. faceUV?: Vector4[];
  63718. faceColors?: Color4[];
  63719. updatable?: boolean;
  63720. sideOrientation?: number;
  63721. frontUVs?: Vector4;
  63722. backUVs?: Vector4;
  63723. wrap?: boolean;
  63724. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63725. }
  63726. }
  63727. declare module BABYLON {
  63728. /**
  63729. * Class containing static functions to help procedurally build meshes
  63730. */
  63731. export class LatheBuilder {
  63732. /**
  63733. * Creates lathe mesh.
  63734. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63735. * * 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
  63736. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63737. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63738. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63739. * * 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
  63740. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63741. * * 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
  63742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63743. * * 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
  63744. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63746. * @param name defines the name of the mesh
  63747. * @param options defines the options used to create the mesh
  63748. * @param scene defines the hosting scene
  63749. * @returns the lathe mesh
  63750. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63751. */
  63752. static CreateLathe(name: string, options: {
  63753. shape: Vector3[];
  63754. radius?: number;
  63755. tessellation?: number;
  63756. clip?: number;
  63757. arc?: number;
  63758. closed?: boolean;
  63759. updatable?: boolean;
  63760. sideOrientation?: number;
  63761. frontUVs?: Vector4;
  63762. backUVs?: Vector4;
  63763. cap?: number;
  63764. invertUV?: boolean;
  63765. }, scene?: Nullable<Scene>): Mesh;
  63766. }
  63767. }
  63768. declare module BABYLON {
  63769. /**
  63770. * Class containing static functions to help procedurally build meshes
  63771. */
  63772. export class TiledPlaneBuilder {
  63773. /**
  63774. * Creates a tiled plane mesh
  63775. * * The parameter `pattern` will, depending on value, do nothing or
  63776. * * * flip (reflect about central vertical) alternate tiles across and up
  63777. * * * flip every tile on alternate rows
  63778. * * * rotate (180 degs) alternate tiles across and up
  63779. * * * rotate every tile on alternate rows
  63780. * * * flip and rotate alternate tiles across and up
  63781. * * * flip and rotate every tile on alternate rows
  63782. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63783. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63784. * * 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
  63785. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63786. * * 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)
  63787. * * 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)
  63788. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63789. * @param name defines the name of the mesh
  63790. * @param options defines the options used to create the mesh
  63791. * @param scene defines the hosting scene
  63792. * @returns the box mesh
  63793. */
  63794. static CreateTiledPlane(name: string, options: {
  63795. pattern?: number;
  63796. tileSize?: number;
  63797. tileWidth?: number;
  63798. tileHeight?: number;
  63799. size?: number;
  63800. width?: number;
  63801. height?: number;
  63802. alignHorizontal?: number;
  63803. alignVertical?: number;
  63804. sideOrientation?: number;
  63805. frontUVs?: Vector4;
  63806. backUVs?: Vector4;
  63807. updatable?: boolean;
  63808. }, scene?: Nullable<Scene>): Mesh;
  63809. }
  63810. }
  63811. declare module BABYLON {
  63812. /**
  63813. * Class containing static functions to help procedurally build meshes
  63814. */
  63815. export class TubeBuilder {
  63816. /**
  63817. * Creates a tube mesh.
  63818. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63819. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63820. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63821. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63822. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63823. * * 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)
  63824. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63825. * * 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
  63826. * * 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
  63827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63828. * * 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
  63829. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63831. * @param name defines the name of the mesh
  63832. * @param options defines the options used to create the mesh
  63833. * @param scene defines the hosting scene
  63834. * @returns the tube mesh
  63835. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63836. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63837. */
  63838. static CreateTube(name: string, options: {
  63839. path: Vector3[];
  63840. radius?: number;
  63841. tessellation?: number;
  63842. radiusFunction?: {
  63843. (i: number, distance: number): number;
  63844. };
  63845. cap?: number;
  63846. arc?: number;
  63847. updatable?: boolean;
  63848. sideOrientation?: number;
  63849. frontUVs?: Vector4;
  63850. backUVs?: Vector4;
  63851. instance?: Mesh;
  63852. invertUV?: boolean;
  63853. }, scene?: Nullable<Scene>): Mesh;
  63854. }
  63855. }
  63856. declare module BABYLON {
  63857. /**
  63858. * Class containing static functions to help procedurally build meshes
  63859. */
  63860. export class IcoSphereBuilder {
  63861. /**
  63862. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63863. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63864. * * 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`)
  63865. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63866. * * 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
  63867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63868. * * 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
  63869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63870. * @param name defines the name of the mesh
  63871. * @param options defines the options used to create the mesh
  63872. * @param scene defines the hosting scene
  63873. * @returns the icosahedron mesh
  63874. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63875. */
  63876. static CreateIcoSphere(name: string, options: {
  63877. radius?: number;
  63878. radiusX?: number;
  63879. radiusY?: number;
  63880. radiusZ?: number;
  63881. flat?: boolean;
  63882. subdivisions?: number;
  63883. sideOrientation?: number;
  63884. frontUVs?: Vector4;
  63885. backUVs?: Vector4;
  63886. updatable?: boolean;
  63887. }, scene?: Nullable<Scene>): Mesh;
  63888. }
  63889. }
  63890. declare module BABYLON {
  63891. /**
  63892. * Class containing static functions to help procedurally build meshes
  63893. */
  63894. export class DecalBuilder {
  63895. /**
  63896. * Creates a decal mesh.
  63897. * 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
  63898. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63899. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63900. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63901. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63902. * @param name defines the name of the mesh
  63903. * @param sourceMesh defines the mesh where the decal must be applied
  63904. * @param options defines the options used to create the mesh
  63905. * @param scene defines the hosting scene
  63906. * @returns the decal mesh
  63907. * @see https://doc.babylonjs.com/how_to/decals
  63908. */
  63909. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63910. position?: Vector3;
  63911. normal?: Vector3;
  63912. size?: Vector3;
  63913. angle?: number;
  63914. }): Mesh;
  63915. }
  63916. }
  63917. declare module BABYLON {
  63918. /**
  63919. * Class containing static functions to help procedurally build meshes
  63920. */
  63921. export class MeshBuilder {
  63922. /**
  63923. * Creates a box mesh
  63924. * * The parameter `size` sets the size (float) of each box side (default 1)
  63925. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63926. * * 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)
  63927. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63929. * * 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
  63930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63931. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63932. * @param name defines the name of the mesh
  63933. * @param options defines the options used to create the mesh
  63934. * @param scene defines the hosting scene
  63935. * @returns the box mesh
  63936. */
  63937. static CreateBox(name: string, options: {
  63938. size?: number;
  63939. width?: number;
  63940. height?: number;
  63941. depth?: number;
  63942. faceUV?: Vector4[];
  63943. faceColors?: Color4[];
  63944. sideOrientation?: number;
  63945. frontUVs?: Vector4;
  63946. backUVs?: Vector4;
  63947. wrap?: boolean;
  63948. topBaseAt?: number;
  63949. bottomBaseAt?: number;
  63950. updatable?: boolean;
  63951. }, scene?: Nullable<Scene>): Mesh;
  63952. /**
  63953. * Creates a tiled box mesh
  63954. * * faceTiles sets the pattern, tile size and number of tiles for a face
  63955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63956. * @param name defines the name of the mesh
  63957. * @param options defines the options used to create the mesh
  63958. * @param scene defines the hosting scene
  63959. * @returns the tiled box mesh
  63960. */
  63961. static CreateTiledBox(name: string, options: {
  63962. pattern?: number;
  63963. size?: number;
  63964. width?: number;
  63965. height?: number;
  63966. depth: number;
  63967. tileSize?: number;
  63968. tileWidth?: number;
  63969. tileHeight?: number;
  63970. faceUV?: Vector4[];
  63971. faceColors?: Color4[];
  63972. alignHorizontal?: number;
  63973. alignVertical?: number;
  63974. sideOrientation?: number;
  63975. updatable?: boolean;
  63976. }, scene?: Nullable<Scene>): Mesh;
  63977. /**
  63978. * Creates a sphere mesh
  63979. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  63980. * * 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`)
  63981. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  63982. * * 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
  63983. * * 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)
  63984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63985. * * 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
  63986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63987. * @param name defines the name of the mesh
  63988. * @param options defines the options used to create the mesh
  63989. * @param scene defines the hosting scene
  63990. * @returns the sphere mesh
  63991. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  63992. */
  63993. static CreateSphere(name: string, options: {
  63994. segments?: number;
  63995. diameter?: number;
  63996. diameterX?: number;
  63997. diameterY?: number;
  63998. diameterZ?: number;
  63999. arc?: number;
  64000. slice?: number;
  64001. sideOrientation?: number;
  64002. frontUVs?: Vector4;
  64003. backUVs?: Vector4;
  64004. updatable?: boolean;
  64005. }, scene?: Nullable<Scene>): Mesh;
  64006. /**
  64007. * Creates a plane polygonal mesh. By default, this is a disc
  64008. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64009. * * 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
  64010. * * 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
  64011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64012. * * 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
  64013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64014. * @param name defines the name of the mesh
  64015. * @param options defines the options used to create the mesh
  64016. * @param scene defines the hosting scene
  64017. * @returns the plane polygonal mesh
  64018. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64019. */
  64020. static CreateDisc(name: string, options: {
  64021. radius?: number;
  64022. tessellation?: number;
  64023. arc?: number;
  64024. updatable?: boolean;
  64025. sideOrientation?: number;
  64026. frontUVs?: Vector4;
  64027. backUVs?: Vector4;
  64028. }, scene?: Nullable<Scene>): Mesh;
  64029. /**
  64030. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64031. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64032. * * 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`)
  64033. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64034. * * 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
  64035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64036. * * 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
  64037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64038. * @param name defines the name of the mesh
  64039. * @param options defines the options used to create the mesh
  64040. * @param scene defines the hosting scene
  64041. * @returns the icosahedron mesh
  64042. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64043. */
  64044. static CreateIcoSphere(name: string, options: {
  64045. radius?: number;
  64046. radiusX?: number;
  64047. radiusY?: number;
  64048. radiusZ?: number;
  64049. flat?: boolean;
  64050. subdivisions?: number;
  64051. sideOrientation?: number;
  64052. frontUVs?: Vector4;
  64053. backUVs?: Vector4;
  64054. updatable?: boolean;
  64055. }, scene?: Nullable<Scene>): Mesh;
  64056. /**
  64057. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64058. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64059. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64060. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64061. * * 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
  64062. * * 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
  64063. * * 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
  64064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64065. * * 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
  64066. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64067. * * 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
  64068. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64069. * * 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
  64070. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64072. * @param name defines the name of the mesh
  64073. * @param options defines the options used to create the mesh
  64074. * @param scene defines the hosting scene
  64075. * @returns the ribbon mesh
  64076. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64077. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64078. */
  64079. static CreateRibbon(name: string, options: {
  64080. pathArray: Vector3[][];
  64081. closeArray?: boolean;
  64082. closePath?: boolean;
  64083. offset?: number;
  64084. updatable?: boolean;
  64085. sideOrientation?: number;
  64086. frontUVs?: Vector4;
  64087. backUVs?: Vector4;
  64088. instance?: Mesh;
  64089. invertUV?: boolean;
  64090. uvs?: Vector2[];
  64091. colors?: Color4[];
  64092. }, scene?: Nullable<Scene>): Mesh;
  64093. /**
  64094. * Creates a cylinder or a cone mesh
  64095. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64096. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64097. * * 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.
  64098. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64099. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64100. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64101. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64102. * * 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).
  64103. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64104. * * 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).
  64105. * * 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
  64106. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64107. * * 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
  64108. * * 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.
  64109. * * If `enclose` is false, a ring surface is one element.
  64110. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64111. * * 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
  64112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64113. * * 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
  64114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64115. * @param name defines the name of the mesh
  64116. * @param options defines the options used to create the mesh
  64117. * @param scene defines the hosting scene
  64118. * @returns the cylinder mesh
  64119. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64120. */
  64121. static CreateCylinder(name: string, options: {
  64122. height?: number;
  64123. diameterTop?: number;
  64124. diameterBottom?: number;
  64125. diameter?: number;
  64126. tessellation?: number;
  64127. subdivisions?: number;
  64128. arc?: number;
  64129. faceColors?: Color4[];
  64130. faceUV?: Vector4[];
  64131. updatable?: boolean;
  64132. hasRings?: boolean;
  64133. enclose?: boolean;
  64134. cap?: number;
  64135. sideOrientation?: number;
  64136. frontUVs?: Vector4;
  64137. backUVs?: Vector4;
  64138. }, scene?: Nullable<Scene>): Mesh;
  64139. /**
  64140. * Creates a torus mesh
  64141. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64142. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64143. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64145. * * 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
  64146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64147. * @param name defines the name of the mesh
  64148. * @param options defines the options used to create the mesh
  64149. * @param scene defines the hosting scene
  64150. * @returns the torus mesh
  64151. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64152. */
  64153. static CreateTorus(name: string, options: {
  64154. diameter?: number;
  64155. thickness?: number;
  64156. tessellation?: number;
  64157. updatable?: boolean;
  64158. sideOrientation?: number;
  64159. frontUVs?: Vector4;
  64160. backUVs?: Vector4;
  64161. }, scene?: Nullable<Scene>): Mesh;
  64162. /**
  64163. * Creates a torus knot mesh
  64164. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64165. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64166. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64167. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64169. * * 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
  64170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64171. * @param name defines the name of the mesh
  64172. * @param options defines the options used to create the mesh
  64173. * @param scene defines the hosting scene
  64174. * @returns the torus knot mesh
  64175. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64176. */
  64177. static CreateTorusKnot(name: string, options: {
  64178. radius?: number;
  64179. tube?: number;
  64180. radialSegments?: number;
  64181. tubularSegments?: number;
  64182. p?: number;
  64183. q?: number;
  64184. updatable?: boolean;
  64185. sideOrientation?: number;
  64186. frontUVs?: Vector4;
  64187. backUVs?: Vector4;
  64188. }, scene?: Nullable<Scene>): Mesh;
  64189. /**
  64190. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64191. * * 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
  64192. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64193. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64194. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64195. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64196. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64197. * * 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
  64198. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64200. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64201. * @param name defines the name of the new line system
  64202. * @param options defines the options used to create the line system
  64203. * @param scene defines the hosting scene
  64204. * @returns a new line system mesh
  64205. */
  64206. static CreateLineSystem(name: string, options: {
  64207. lines: Vector3[][];
  64208. updatable?: boolean;
  64209. instance?: Nullable<LinesMesh>;
  64210. colors?: Nullable<Color4[][]>;
  64211. useVertexAlpha?: boolean;
  64212. }, scene: Nullable<Scene>): LinesMesh;
  64213. /**
  64214. * Creates a line mesh
  64215. * 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
  64216. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64217. * * The parameter `points` is an array successive Vector3
  64218. * * 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
  64219. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64220. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64221. * * When updating an instance, remember that only point positions can change, not the number of points
  64222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64223. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64224. * @param name defines the name of the new line system
  64225. * @param options defines the options used to create the line system
  64226. * @param scene defines the hosting scene
  64227. * @returns a new line mesh
  64228. */
  64229. static CreateLines(name: string, options: {
  64230. points: Vector3[];
  64231. updatable?: boolean;
  64232. instance?: Nullable<LinesMesh>;
  64233. colors?: Color4[];
  64234. useVertexAlpha?: boolean;
  64235. }, scene?: Nullable<Scene>): LinesMesh;
  64236. /**
  64237. * Creates a dashed line mesh
  64238. * * 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
  64239. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64240. * * The parameter `points` is an array successive Vector3
  64241. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64242. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64243. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64244. * * 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
  64245. * * When updating an instance, remember that only point positions can change, not the number of points
  64246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64247. * @param name defines the name of the mesh
  64248. * @param options defines the options used to create the mesh
  64249. * @param scene defines the hosting scene
  64250. * @returns the dashed line mesh
  64251. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64252. */
  64253. static CreateDashedLines(name: string, options: {
  64254. points: Vector3[];
  64255. dashSize?: number;
  64256. gapSize?: number;
  64257. dashNb?: number;
  64258. updatable?: boolean;
  64259. instance?: LinesMesh;
  64260. }, scene?: Nullable<Scene>): LinesMesh;
  64261. /**
  64262. * 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.
  64263. * * 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.
  64264. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64265. * * 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.
  64266. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64267. * * 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
  64268. * * 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
  64269. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64271. * * 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
  64272. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64274. * @param name defines the name of the mesh
  64275. * @param options defines the options used to create the mesh
  64276. * @param scene defines the hosting scene
  64277. * @returns the extruded shape mesh
  64278. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64279. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64280. */
  64281. static ExtrudeShape(name: string, options: {
  64282. shape: Vector3[];
  64283. path: Vector3[];
  64284. scale?: number;
  64285. rotation?: number;
  64286. cap?: number;
  64287. updatable?: boolean;
  64288. sideOrientation?: number;
  64289. frontUVs?: Vector4;
  64290. backUVs?: Vector4;
  64291. instance?: Mesh;
  64292. invertUV?: boolean;
  64293. }, scene?: Nullable<Scene>): Mesh;
  64294. /**
  64295. * Creates an custom extruded shape mesh.
  64296. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64297. * * 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.
  64298. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64299. * * 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
  64300. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64301. * * 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
  64302. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64303. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64304. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64305. * * 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
  64306. * * 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
  64307. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64309. * * 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
  64310. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64312. * @param name defines the name of the mesh
  64313. * @param options defines the options used to create the mesh
  64314. * @param scene defines the hosting scene
  64315. * @returns the custom extruded shape mesh
  64316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64317. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64318. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64319. */
  64320. static ExtrudeShapeCustom(name: string, options: {
  64321. shape: Vector3[];
  64322. path: Vector3[];
  64323. scaleFunction?: any;
  64324. rotationFunction?: any;
  64325. ribbonCloseArray?: boolean;
  64326. ribbonClosePath?: boolean;
  64327. cap?: number;
  64328. updatable?: boolean;
  64329. sideOrientation?: number;
  64330. frontUVs?: Vector4;
  64331. backUVs?: Vector4;
  64332. instance?: Mesh;
  64333. invertUV?: boolean;
  64334. }, scene?: Nullable<Scene>): Mesh;
  64335. /**
  64336. * Creates lathe mesh.
  64337. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64338. * * 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
  64339. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64340. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64341. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64342. * * 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
  64343. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64344. * * 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
  64345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64346. * * 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
  64347. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64349. * @param name defines the name of the mesh
  64350. * @param options defines the options used to create the mesh
  64351. * @param scene defines the hosting scene
  64352. * @returns the lathe mesh
  64353. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64354. */
  64355. static CreateLathe(name: string, options: {
  64356. shape: Vector3[];
  64357. radius?: number;
  64358. tessellation?: number;
  64359. clip?: number;
  64360. arc?: number;
  64361. closed?: boolean;
  64362. updatable?: boolean;
  64363. sideOrientation?: number;
  64364. frontUVs?: Vector4;
  64365. backUVs?: Vector4;
  64366. cap?: number;
  64367. invertUV?: boolean;
  64368. }, scene?: Nullable<Scene>): Mesh;
  64369. /**
  64370. * Creates a tiled plane mesh
  64371. * * You can set a limited pattern arrangement with the tiles
  64372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64373. * * 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
  64374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64375. * @param name defines the name of the mesh
  64376. * @param options defines the options used to create the mesh
  64377. * @param scene defines the hosting scene
  64378. * @returns the plane mesh
  64379. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64380. */
  64381. static CreateTiledPlane(name: string, options: {
  64382. pattern?: number;
  64383. tileSize?: number;
  64384. tileWidth?: number;
  64385. tileHeight?: number;
  64386. size?: number;
  64387. width?: number;
  64388. height?: number;
  64389. alignHorizontal?: number;
  64390. alignVertical?: number;
  64391. sideOrientation?: number;
  64392. frontUVs?: Vector4;
  64393. backUVs?: Vector4;
  64394. updatable?: boolean;
  64395. }, scene?: Nullable<Scene>): Mesh;
  64396. /**
  64397. * Creates a plane mesh
  64398. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64399. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64400. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64402. * * 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
  64403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64404. * @param name defines the name of the mesh
  64405. * @param options defines the options used to create the mesh
  64406. * @param scene defines the hosting scene
  64407. * @returns the plane mesh
  64408. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64409. */
  64410. static CreatePlane(name: string, options: {
  64411. size?: number;
  64412. width?: number;
  64413. height?: number;
  64414. sideOrientation?: number;
  64415. frontUVs?: Vector4;
  64416. backUVs?: Vector4;
  64417. updatable?: boolean;
  64418. sourcePlane?: Plane;
  64419. }, scene?: Nullable<Scene>): Mesh;
  64420. /**
  64421. * Creates a ground mesh
  64422. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64423. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64425. * @param name defines the name of the mesh
  64426. * @param options defines the options used to create the mesh
  64427. * @param scene defines the hosting scene
  64428. * @returns the ground mesh
  64429. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64430. */
  64431. static CreateGround(name: string, options: {
  64432. width?: number;
  64433. height?: number;
  64434. subdivisions?: number;
  64435. subdivisionsX?: number;
  64436. subdivisionsY?: number;
  64437. updatable?: boolean;
  64438. }, scene?: Nullable<Scene>): Mesh;
  64439. /**
  64440. * Creates a tiled ground mesh
  64441. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64442. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64443. * * 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
  64444. * * 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
  64445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64446. * @param name defines the name of the mesh
  64447. * @param options defines the options used to create the mesh
  64448. * @param scene defines the hosting scene
  64449. * @returns the tiled ground mesh
  64450. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64451. */
  64452. static CreateTiledGround(name: string, options: {
  64453. xmin: number;
  64454. zmin: number;
  64455. xmax: number;
  64456. zmax: number;
  64457. subdivisions?: {
  64458. w: number;
  64459. h: number;
  64460. };
  64461. precision?: {
  64462. w: number;
  64463. h: number;
  64464. };
  64465. updatable?: boolean;
  64466. }, scene?: Nullable<Scene>): Mesh;
  64467. /**
  64468. * Creates a ground mesh from a height map
  64469. * * The parameter `url` sets the URL of the height map image resource.
  64470. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64471. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64472. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64473. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64474. * * 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.
  64475. * * 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).
  64476. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64478. * @param name defines the name of the mesh
  64479. * @param url defines the url to the height map
  64480. * @param options defines the options used to create the mesh
  64481. * @param scene defines the hosting scene
  64482. * @returns the ground mesh
  64483. * @see https://doc.babylonjs.com/babylon101/height_map
  64484. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64485. */
  64486. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64487. width?: number;
  64488. height?: number;
  64489. subdivisions?: number;
  64490. minHeight?: number;
  64491. maxHeight?: number;
  64492. colorFilter?: Color3;
  64493. alphaFilter?: number;
  64494. updatable?: boolean;
  64495. onReady?: (mesh: GroundMesh) => void;
  64496. }, scene?: Nullable<Scene>): GroundMesh;
  64497. /**
  64498. * Creates a polygon mesh
  64499. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64500. * * 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
  64501. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64503. * * 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)
  64504. * * Remember you can only change the shape positions, not their number when updating a polygon
  64505. * @param name defines the name of the mesh
  64506. * @param options defines the options used to create the mesh
  64507. * @param scene defines the hosting scene
  64508. * @param earcutInjection can be used to inject your own earcut reference
  64509. * @returns the polygon mesh
  64510. */
  64511. static CreatePolygon(name: string, options: {
  64512. shape: Vector3[];
  64513. holes?: Vector3[][];
  64514. depth?: number;
  64515. faceUV?: Vector4[];
  64516. faceColors?: Color4[];
  64517. updatable?: boolean;
  64518. sideOrientation?: number;
  64519. frontUVs?: Vector4;
  64520. backUVs?: Vector4;
  64521. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64522. /**
  64523. * Creates an extruded polygon mesh, with depth in the Y direction.
  64524. * * 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)
  64525. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64526. * @param name defines the name of the mesh
  64527. * @param options defines the options used to create the mesh
  64528. * @param scene defines the hosting scene
  64529. * @param earcutInjection can be used to inject your own earcut reference
  64530. * @returns the polygon mesh
  64531. */
  64532. static ExtrudePolygon(name: string, options: {
  64533. shape: Vector3[];
  64534. holes?: Vector3[][];
  64535. depth?: number;
  64536. faceUV?: Vector4[];
  64537. faceColors?: Color4[];
  64538. updatable?: boolean;
  64539. sideOrientation?: number;
  64540. frontUVs?: Vector4;
  64541. backUVs?: Vector4;
  64542. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64543. /**
  64544. * Creates a tube mesh.
  64545. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64546. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64547. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64548. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64549. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64550. * * 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)
  64551. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64552. * * 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
  64553. * * 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
  64554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64555. * * 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
  64556. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64558. * @param name defines the name of the mesh
  64559. * @param options defines the options used to create the mesh
  64560. * @param scene defines the hosting scene
  64561. * @returns the tube mesh
  64562. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64563. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64564. */
  64565. static CreateTube(name: string, options: {
  64566. path: Vector3[];
  64567. radius?: number;
  64568. tessellation?: number;
  64569. radiusFunction?: {
  64570. (i: number, distance: number): number;
  64571. };
  64572. cap?: number;
  64573. arc?: number;
  64574. updatable?: boolean;
  64575. sideOrientation?: number;
  64576. frontUVs?: Vector4;
  64577. backUVs?: Vector4;
  64578. instance?: Mesh;
  64579. invertUV?: boolean;
  64580. }, scene?: Nullable<Scene>): Mesh;
  64581. /**
  64582. * Creates a polyhedron mesh
  64583. * * 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
  64584. * * The parameter `size` (positive float, default 1) sets the polygon size
  64585. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64586. * * 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`
  64587. * * 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
  64588. * * 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)`)
  64589. * * 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
  64590. * * 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
  64591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64592. * * 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
  64593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64594. * @param name defines the name of the mesh
  64595. * @param options defines the options used to create the mesh
  64596. * @param scene defines the hosting scene
  64597. * @returns the polyhedron mesh
  64598. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64599. */
  64600. static CreatePolyhedron(name: string, options: {
  64601. type?: number;
  64602. size?: number;
  64603. sizeX?: number;
  64604. sizeY?: number;
  64605. sizeZ?: number;
  64606. custom?: any;
  64607. faceUV?: Vector4[];
  64608. faceColors?: Color4[];
  64609. flat?: boolean;
  64610. updatable?: boolean;
  64611. sideOrientation?: number;
  64612. frontUVs?: Vector4;
  64613. backUVs?: Vector4;
  64614. }, scene?: Nullable<Scene>): Mesh;
  64615. /**
  64616. * Creates a decal mesh.
  64617. * 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
  64618. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64619. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64620. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64621. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64622. * @param name defines the name of the mesh
  64623. * @param sourceMesh defines the mesh where the decal must be applied
  64624. * @param options defines the options used to create the mesh
  64625. * @param scene defines the hosting scene
  64626. * @returns the decal mesh
  64627. * @see https://doc.babylonjs.com/how_to/decals
  64628. */
  64629. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64630. position?: Vector3;
  64631. normal?: Vector3;
  64632. size?: Vector3;
  64633. angle?: number;
  64634. }): Mesh;
  64635. }
  64636. }
  64637. declare module BABYLON {
  64638. /**
  64639. * A simplifier interface for future simplification implementations
  64640. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64641. */
  64642. export interface ISimplifier {
  64643. /**
  64644. * Simplification of a given mesh according to the given settings.
  64645. * Since this requires computation, it is assumed that the function runs async.
  64646. * @param settings The settings of the simplification, including quality and distance
  64647. * @param successCallback A callback that will be called after the mesh was simplified.
  64648. * @param errorCallback in case of an error, this callback will be called. optional.
  64649. */
  64650. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64651. }
  64652. /**
  64653. * Expected simplification settings.
  64654. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64655. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64656. */
  64657. export interface ISimplificationSettings {
  64658. /**
  64659. * Gets or sets the expected quality
  64660. */
  64661. quality: number;
  64662. /**
  64663. * Gets or sets the distance when this optimized version should be used
  64664. */
  64665. distance: number;
  64666. /**
  64667. * Gets an already optimized mesh
  64668. */
  64669. optimizeMesh?: boolean;
  64670. }
  64671. /**
  64672. * Class used to specify simplification options
  64673. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64674. */
  64675. export class SimplificationSettings implements ISimplificationSettings {
  64676. /** expected quality */
  64677. quality: number;
  64678. /** distance when this optimized version should be used */
  64679. distance: number;
  64680. /** already optimized mesh */
  64681. optimizeMesh?: boolean | undefined;
  64682. /**
  64683. * Creates a SimplificationSettings
  64684. * @param quality expected quality
  64685. * @param distance distance when this optimized version should be used
  64686. * @param optimizeMesh already optimized mesh
  64687. */
  64688. constructor(
  64689. /** expected quality */
  64690. quality: number,
  64691. /** distance when this optimized version should be used */
  64692. distance: number,
  64693. /** already optimized mesh */
  64694. optimizeMesh?: boolean | undefined);
  64695. }
  64696. /**
  64697. * Interface used to define a simplification task
  64698. */
  64699. export interface ISimplificationTask {
  64700. /**
  64701. * Array of settings
  64702. */
  64703. settings: Array<ISimplificationSettings>;
  64704. /**
  64705. * Simplification type
  64706. */
  64707. simplificationType: SimplificationType;
  64708. /**
  64709. * Mesh to simplify
  64710. */
  64711. mesh: Mesh;
  64712. /**
  64713. * Callback called on success
  64714. */
  64715. successCallback?: () => void;
  64716. /**
  64717. * Defines if parallel processing can be used
  64718. */
  64719. parallelProcessing: boolean;
  64720. }
  64721. /**
  64722. * Queue used to order the simplification tasks
  64723. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64724. */
  64725. export class SimplificationQueue {
  64726. private _simplificationArray;
  64727. /**
  64728. * Gets a boolean indicating that the process is still running
  64729. */
  64730. running: boolean;
  64731. /**
  64732. * Creates a new queue
  64733. */
  64734. constructor();
  64735. /**
  64736. * Adds a new simplification task
  64737. * @param task defines a task to add
  64738. */
  64739. addTask(task: ISimplificationTask): void;
  64740. /**
  64741. * Execute next task
  64742. */
  64743. executeNext(): void;
  64744. /**
  64745. * Execute a simplification task
  64746. * @param task defines the task to run
  64747. */
  64748. runSimplification(task: ISimplificationTask): void;
  64749. private getSimplifier;
  64750. }
  64751. /**
  64752. * The implemented types of simplification
  64753. * At the moment only Quadratic Error Decimation is implemented
  64754. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64755. */
  64756. export enum SimplificationType {
  64757. /** Quadratic error decimation */
  64758. QUADRATIC = 0
  64759. }
  64760. /**
  64761. * An implementation of the Quadratic Error simplification algorithm.
  64762. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  64763. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  64764. * @author RaananW
  64765. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64766. */
  64767. export class QuadraticErrorSimplification implements ISimplifier {
  64768. private _mesh;
  64769. private triangles;
  64770. private vertices;
  64771. private references;
  64772. private _reconstructedMesh;
  64773. /** Gets or sets the number pf sync interations */
  64774. syncIterations: number;
  64775. /** Gets or sets the aggressiveness of the simplifier */
  64776. aggressiveness: number;
  64777. /** Gets or sets the number of allowed iterations for decimation */
  64778. decimationIterations: number;
  64779. /** Gets or sets the espilon to use for bounding box computation */
  64780. boundingBoxEpsilon: number;
  64781. /**
  64782. * Creates a new QuadraticErrorSimplification
  64783. * @param _mesh defines the target mesh
  64784. */
  64785. constructor(_mesh: Mesh);
  64786. /**
  64787. * Simplification of a given mesh according to the given settings.
  64788. * Since this requires computation, it is assumed that the function runs async.
  64789. * @param settings The settings of the simplification, including quality and distance
  64790. * @param successCallback A callback that will be called after the mesh was simplified.
  64791. */
  64792. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  64793. private runDecimation;
  64794. private initWithMesh;
  64795. private init;
  64796. private reconstructMesh;
  64797. private initDecimatedMesh;
  64798. private isFlipped;
  64799. private updateTriangles;
  64800. private identifyBorder;
  64801. private updateMesh;
  64802. private vertexError;
  64803. private calculateError;
  64804. }
  64805. }
  64806. declare module BABYLON {
  64807. interface Scene {
  64808. /** @hidden (Backing field) */
  64809. _simplificationQueue: SimplificationQueue;
  64810. /**
  64811. * Gets or sets the simplification queue attached to the scene
  64812. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64813. */
  64814. simplificationQueue: SimplificationQueue;
  64815. }
  64816. interface Mesh {
  64817. /**
  64818. * Simplify the mesh according to the given array of settings.
  64819. * Function will return immediately and will simplify async
  64820. * @param settings a collection of simplification settings
  64821. * @param parallelProcessing should all levels calculate parallel or one after the other
  64822. * @param simplificationType the type of simplification to run
  64823. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64824. * @returns the current mesh
  64825. */
  64826. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64827. }
  64828. /**
  64829. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64830. * created in a scene
  64831. */
  64832. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64833. /**
  64834. * The component name helpfull to identify the component in the list of scene components.
  64835. */
  64836. readonly name: string;
  64837. /**
  64838. * The scene the component belongs to.
  64839. */
  64840. scene: Scene;
  64841. /**
  64842. * Creates a new instance of the component for the given scene
  64843. * @param scene Defines the scene to register the component in
  64844. */
  64845. constructor(scene: Scene);
  64846. /**
  64847. * Registers the component in a given scene
  64848. */
  64849. register(): void;
  64850. /**
  64851. * Rebuilds the elements related to this component in case of
  64852. * context lost for instance.
  64853. */
  64854. rebuild(): void;
  64855. /**
  64856. * Disposes the component and the associated ressources
  64857. */
  64858. dispose(): void;
  64859. private _beforeCameraUpdate;
  64860. }
  64861. }
  64862. declare module BABYLON {
  64863. /**
  64864. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64865. */
  64866. export interface INavigationEnginePlugin {
  64867. /**
  64868. * plugin name
  64869. */
  64870. name: string;
  64871. /**
  64872. * Creates a navigation mesh
  64873. * @param meshes array of all the geometry used to compute the navigatio mesh
  64874. * @param parameters bunch of parameters used to filter geometry
  64875. */
  64876. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64877. /**
  64878. * Create a navigation mesh debug mesh
  64879. * @param scene is where the mesh will be added
  64880. * @returns debug display mesh
  64881. */
  64882. createDebugNavMesh(scene: Scene): Mesh;
  64883. /**
  64884. * Get a navigation mesh constrained position, closest to the parameter position
  64885. * @param position world position
  64886. * @returns the closest point to position constrained by the navigation mesh
  64887. */
  64888. getClosestPoint(position: Vector3): Vector3;
  64889. /**
  64890. * Get a navigation mesh constrained position, closest to the parameter position
  64891. * @param position world position
  64892. * @param result output the closest point to position constrained by the navigation mesh
  64893. */
  64894. getClosestPointToRef(position: Vector3, result: Vector3): void;
  64895. /**
  64896. * Get a navigation mesh constrained position, within a particular radius
  64897. * @param position world position
  64898. * @param maxRadius the maximum distance to the constrained world position
  64899. * @returns the closest point to position constrained by the navigation mesh
  64900. */
  64901. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64902. /**
  64903. * Get a navigation mesh constrained position, within a particular radius
  64904. * @param position world position
  64905. * @param maxRadius the maximum distance to the constrained world position
  64906. * @param result output the closest point to position constrained by the navigation mesh
  64907. */
  64908. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  64909. /**
  64910. * Compute the final position from a segment made of destination-position
  64911. * @param position world position
  64912. * @param destination world position
  64913. * @returns the resulting point along the navmesh
  64914. */
  64915. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64916. /**
  64917. * Compute the final position from a segment made of destination-position
  64918. * @param position world position
  64919. * @param destination world position
  64920. * @param result output the resulting point along the navmesh
  64921. */
  64922. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  64923. /**
  64924. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64925. * @param start world position
  64926. * @param end world position
  64927. * @returns array containing world position composing the path
  64928. */
  64929. computePath(start: Vector3, end: Vector3): Vector3[];
  64930. /**
  64931. * If this plugin is supported
  64932. * @returns true if plugin is supported
  64933. */
  64934. isSupported(): boolean;
  64935. /**
  64936. * Create a new Crowd so you can add agents
  64937. * @param maxAgents the maximum agent count in the crowd
  64938. * @param maxAgentRadius the maximum radius an agent can have
  64939. * @param scene to attach the crowd to
  64940. * @returns the crowd you can add agents to
  64941. */
  64942. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64943. /**
  64944. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64945. * The queries will try to find a solution within those bounds
  64946. * default is (1,1,1)
  64947. * @param extent x,y,z value that define the extent around the queries point of reference
  64948. */
  64949. setDefaultQueryExtent(extent: Vector3): void;
  64950. /**
  64951. * Get the Bounding box extent specified by setDefaultQueryExtent
  64952. * @returns the box extent values
  64953. */
  64954. getDefaultQueryExtent(): Vector3;
  64955. /**
  64956. * build the navmesh from a previously saved state using getNavmeshData
  64957. * @param data the Uint8Array returned by getNavmeshData
  64958. */
  64959. buildFromNavmeshData(data: Uint8Array): void;
  64960. /**
  64961. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  64962. * @returns data the Uint8Array that can be saved and reused
  64963. */
  64964. getNavmeshData(): Uint8Array;
  64965. /**
  64966. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64967. * @param result output the box extent values
  64968. */
  64969. getDefaultQueryExtentToRef(result: Vector3): void;
  64970. /**
  64971. * Release all resources
  64972. */
  64973. dispose(): void;
  64974. }
  64975. /**
  64976. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  64977. */
  64978. export interface ICrowd {
  64979. /**
  64980. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64981. * You can attach anything to that node. The node position is updated in the scene update tick.
  64982. * @param pos world position that will be constrained by the navigation mesh
  64983. * @param parameters agent parameters
  64984. * @param transform hooked to the agent that will be update by the scene
  64985. * @returns agent index
  64986. */
  64987. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64988. /**
  64989. * Returns the agent position in world space
  64990. * @param index agent index returned by addAgent
  64991. * @returns world space position
  64992. */
  64993. getAgentPosition(index: number): Vector3;
  64994. /**
  64995. * Gets the agent position result in world space
  64996. * @param index agent index returned by addAgent
  64997. * @param result output world space position
  64998. */
  64999. getAgentPositionToRef(index: number, result: Vector3): void;
  65000. /**
  65001. * Gets the agent velocity in world space
  65002. * @param index agent index returned by addAgent
  65003. * @returns world space velocity
  65004. */
  65005. getAgentVelocity(index: number): Vector3;
  65006. /**
  65007. * Gets the agent velocity result in world space
  65008. * @param index agent index returned by addAgent
  65009. * @param result output world space velocity
  65010. */
  65011. getAgentVelocityToRef(index: number, result: Vector3): void;
  65012. /**
  65013. * remove a particular agent previously created
  65014. * @param index agent index returned by addAgent
  65015. */
  65016. removeAgent(index: number): void;
  65017. /**
  65018. * get the list of all agents attached to this crowd
  65019. * @returns list of agent indices
  65020. */
  65021. getAgents(): number[];
  65022. /**
  65023. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65024. * @param deltaTime in seconds
  65025. */
  65026. update(deltaTime: number): void;
  65027. /**
  65028. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65029. * @param index agent index returned by addAgent
  65030. * @param destination targeted world position
  65031. */
  65032. agentGoto(index: number, destination: Vector3): void;
  65033. /**
  65034. * Teleport the agent to a new position
  65035. * @param index agent index returned by addAgent
  65036. * @param destination targeted world position
  65037. */
  65038. agentTeleport(index: number, destination: Vector3): void;
  65039. /**
  65040. * Update agent parameters
  65041. * @param index agent index returned by addAgent
  65042. * @param parameters agent parameters
  65043. */
  65044. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65045. /**
  65046. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65047. * The queries will try to find a solution within those bounds
  65048. * default is (1,1,1)
  65049. * @param extent x,y,z value that define the extent around the queries point of reference
  65050. */
  65051. setDefaultQueryExtent(extent: Vector3): void;
  65052. /**
  65053. * Get the Bounding box extent specified by setDefaultQueryExtent
  65054. * @returns the box extent values
  65055. */
  65056. getDefaultQueryExtent(): Vector3;
  65057. /**
  65058. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65059. * @param result output the box extent values
  65060. */
  65061. getDefaultQueryExtentToRef(result: Vector3): void;
  65062. /**
  65063. * Release all resources
  65064. */
  65065. dispose(): void;
  65066. }
  65067. /**
  65068. * Configures an agent
  65069. */
  65070. export interface IAgentParameters {
  65071. /**
  65072. * Agent radius. [Limit: >= 0]
  65073. */
  65074. radius: number;
  65075. /**
  65076. * Agent height. [Limit: > 0]
  65077. */
  65078. height: number;
  65079. /**
  65080. * Maximum allowed acceleration. [Limit: >= 0]
  65081. */
  65082. maxAcceleration: number;
  65083. /**
  65084. * Maximum allowed speed. [Limit: >= 0]
  65085. */
  65086. maxSpeed: number;
  65087. /**
  65088. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65089. */
  65090. collisionQueryRange: number;
  65091. /**
  65092. * The path visibility optimization range. [Limit: > 0]
  65093. */
  65094. pathOptimizationRange: number;
  65095. /**
  65096. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65097. */
  65098. separationWeight: number;
  65099. }
  65100. /**
  65101. * Configures the navigation mesh creation
  65102. */
  65103. export interface INavMeshParameters {
  65104. /**
  65105. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65106. */
  65107. cs: number;
  65108. /**
  65109. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65110. */
  65111. ch: number;
  65112. /**
  65113. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65114. */
  65115. walkableSlopeAngle: number;
  65116. /**
  65117. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65118. * be considered walkable. [Limit: >= 3] [Units: vx]
  65119. */
  65120. walkableHeight: number;
  65121. /**
  65122. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65123. */
  65124. walkableClimb: number;
  65125. /**
  65126. * The distance to erode/shrink the walkable area of the heightfield away from
  65127. * obstructions. [Limit: >=0] [Units: vx]
  65128. */
  65129. walkableRadius: number;
  65130. /**
  65131. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65132. */
  65133. maxEdgeLen: number;
  65134. /**
  65135. * The maximum distance a simplfied contour's border edges should deviate
  65136. * the original raw contour. [Limit: >=0] [Units: vx]
  65137. */
  65138. maxSimplificationError: number;
  65139. /**
  65140. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65141. */
  65142. minRegionArea: number;
  65143. /**
  65144. * Any regions with a span count smaller than this value will, if possible,
  65145. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65146. */
  65147. mergeRegionArea: number;
  65148. /**
  65149. * The maximum number of vertices allowed for polygons generated during the
  65150. * contour to polygon conversion process. [Limit: >= 3]
  65151. */
  65152. maxVertsPerPoly: number;
  65153. /**
  65154. * Sets the sampling distance to use when generating the detail mesh.
  65155. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65156. */
  65157. detailSampleDist: number;
  65158. /**
  65159. * The maximum distance the detail mesh surface should deviate from heightfield
  65160. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65161. */
  65162. detailSampleMaxError: number;
  65163. }
  65164. }
  65165. declare module BABYLON {
  65166. /**
  65167. * RecastJS navigation plugin
  65168. */
  65169. export class RecastJSPlugin implements INavigationEnginePlugin {
  65170. /**
  65171. * Reference to the Recast library
  65172. */
  65173. bjsRECAST: any;
  65174. /**
  65175. * plugin name
  65176. */
  65177. name: string;
  65178. /**
  65179. * the first navmesh created. We might extend this to support multiple navmeshes
  65180. */
  65181. navMesh: any;
  65182. /**
  65183. * Initializes the recastJS plugin
  65184. * @param recastInjection can be used to inject your own recast reference
  65185. */
  65186. constructor(recastInjection?: any);
  65187. /**
  65188. * Creates a navigation mesh
  65189. * @param meshes array of all the geometry used to compute the navigatio mesh
  65190. * @param parameters bunch of parameters used to filter geometry
  65191. */
  65192. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65193. /**
  65194. * Create a navigation mesh debug mesh
  65195. * @param scene is where the mesh will be added
  65196. * @returns debug display mesh
  65197. */
  65198. createDebugNavMesh(scene: Scene): Mesh;
  65199. /**
  65200. * Get a navigation mesh constrained position, closest to the parameter position
  65201. * @param position world position
  65202. * @returns the closest point to position constrained by the navigation mesh
  65203. */
  65204. getClosestPoint(position: Vector3): Vector3;
  65205. /**
  65206. * Get a navigation mesh constrained position, closest to the parameter position
  65207. * @param position world position
  65208. * @param result output the closest point to position constrained by the navigation mesh
  65209. */
  65210. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65211. /**
  65212. * Get a navigation mesh constrained position, within a particular radius
  65213. * @param position world position
  65214. * @param maxRadius the maximum distance to the constrained world position
  65215. * @returns the closest point to position constrained by the navigation mesh
  65216. */
  65217. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65218. /**
  65219. * Get a navigation mesh constrained position, within a particular radius
  65220. * @param position world position
  65221. * @param maxRadius the maximum distance to the constrained world position
  65222. * @param result output the closest point to position constrained by the navigation mesh
  65223. */
  65224. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65225. /**
  65226. * Compute the final position from a segment made of destination-position
  65227. * @param position world position
  65228. * @param destination world position
  65229. * @returns the resulting point along the navmesh
  65230. */
  65231. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65232. /**
  65233. * Compute the final position from a segment made of destination-position
  65234. * @param position world position
  65235. * @param destination world position
  65236. * @param result output the resulting point along the navmesh
  65237. */
  65238. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65239. /**
  65240. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65241. * @param start world position
  65242. * @param end world position
  65243. * @returns array containing world position composing the path
  65244. */
  65245. computePath(start: Vector3, end: Vector3): Vector3[];
  65246. /**
  65247. * Create a new Crowd so you can add agents
  65248. * @param maxAgents the maximum agent count in the crowd
  65249. * @param maxAgentRadius the maximum radius an agent can have
  65250. * @param scene to attach the crowd to
  65251. * @returns the crowd you can add agents to
  65252. */
  65253. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65254. /**
  65255. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65256. * The queries will try to find a solution within those bounds
  65257. * default is (1,1,1)
  65258. * @param extent x,y,z value that define the extent around the queries point of reference
  65259. */
  65260. setDefaultQueryExtent(extent: Vector3): void;
  65261. /**
  65262. * Get the Bounding box extent specified by setDefaultQueryExtent
  65263. * @returns the box extent values
  65264. */
  65265. getDefaultQueryExtent(): Vector3;
  65266. /**
  65267. * build the navmesh from a previously saved state using getNavmeshData
  65268. * @param data the Uint8Array returned by getNavmeshData
  65269. */
  65270. buildFromNavmeshData(data: Uint8Array): void;
  65271. /**
  65272. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65273. * @returns data the Uint8Array that can be saved and reused
  65274. */
  65275. getNavmeshData(): Uint8Array;
  65276. /**
  65277. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65278. * @param result output the box extent values
  65279. */
  65280. getDefaultQueryExtentToRef(result: Vector3): void;
  65281. /**
  65282. * Disposes
  65283. */
  65284. dispose(): void;
  65285. /**
  65286. * If this plugin is supported
  65287. * @returns true if plugin is supported
  65288. */
  65289. isSupported(): boolean;
  65290. }
  65291. /**
  65292. * Recast detour crowd implementation
  65293. */
  65294. export class RecastJSCrowd implements ICrowd {
  65295. /**
  65296. * Recast/detour plugin
  65297. */
  65298. bjsRECASTPlugin: RecastJSPlugin;
  65299. /**
  65300. * Link to the detour crowd
  65301. */
  65302. recastCrowd: any;
  65303. /**
  65304. * One transform per agent
  65305. */
  65306. transforms: TransformNode[];
  65307. /**
  65308. * All agents created
  65309. */
  65310. agents: number[];
  65311. /**
  65312. * Link to the scene is kept to unregister the crowd from the scene
  65313. */
  65314. private _scene;
  65315. /**
  65316. * Observer for crowd updates
  65317. */
  65318. private _onBeforeAnimationsObserver;
  65319. /**
  65320. * Constructor
  65321. * @param plugin recastJS plugin
  65322. * @param maxAgents the maximum agent count in the crowd
  65323. * @param maxAgentRadius the maximum radius an agent can have
  65324. * @param scene to attach the crowd to
  65325. * @returns the crowd you can add agents to
  65326. */
  65327. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65328. /**
  65329. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65330. * You can attach anything to that node. The node position is updated in the scene update tick.
  65331. * @param pos world position that will be constrained by the navigation mesh
  65332. * @param parameters agent parameters
  65333. * @param transform hooked to the agent that will be update by the scene
  65334. * @returns agent index
  65335. */
  65336. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65337. /**
  65338. * Returns the agent position in world space
  65339. * @param index agent index returned by addAgent
  65340. * @returns world space position
  65341. */
  65342. getAgentPosition(index: number): Vector3;
  65343. /**
  65344. * Returns the agent position result in world space
  65345. * @param index agent index returned by addAgent
  65346. * @param result output world space position
  65347. */
  65348. getAgentPositionToRef(index: number, result: Vector3): void;
  65349. /**
  65350. * Returns the agent velocity in world space
  65351. * @param index agent index returned by addAgent
  65352. * @returns world space velocity
  65353. */
  65354. getAgentVelocity(index: number): Vector3;
  65355. /**
  65356. * Returns the agent velocity result in world space
  65357. * @param index agent index returned by addAgent
  65358. * @param result output world space velocity
  65359. */
  65360. getAgentVelocityToRef(index: number, result: Vector3): void;
  65361. /**
  65362. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65363. * @param index agent index returned by addAgent
  65364. * @param destination targeted world position
  65365. */
  65366. agentGoto(index: number, destination: Vector3): void;
  65367. /**
  65368. * Teleport the agent to a new position
  65369. * @param index agent index returned by addAgent
  65370. * @param destination targeted world position
  65371. */
  65372. agentTeleport(index: number, destination: Vector3): void;
  65373. /**
  65374. * Update agent parameters
  65375. * @param index agent index returned by addAgent
  65376. * @param parameters agent parameters
  65377. */
  65378. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65379. /**
  65380. * remove a particular agent previously created
  65381. * @param index agent index returned by addAgent
  65382. */
  65383. removeAgent(index: number): void;
  65384. /**
  65385. * get the list of all agents attached to this crowd
  65386. * @returns list of agent indices
  65387. */
  65388. getAgents(): number[];
  65389. /**
  65390. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65391. * @param deltaTime in seconds
  65392. */
  65393. update(deltaTime: number): void;
  65394. /**
  65395. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65396. * The queries will try to find a solution within those bounds
  65397. * default is (1,1,1)
  65398. * @param extent x,y,z value that define the extent around the queries point of reference
  65399. */
  65400. setDefaultQueryExtent(extent: Vector3): void;
  65401. /**
  65402. * Get the Bounding box extent specified by setDefaultQueryExtent
  65403. * @returns the box extent values
  65404. */
  65405. getDefaultQueryExtent(): Vector3;
  65406. /**
  65407. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65408. * @param result output the box extent values
  65409. */
  65410. getDefaultQueryExtentToRef(result: Vector3): void;
  65411. /**
  65412. * Release all resources
  65413. */
  65414. dispose(): void;
  65415. }
  65416. }
  65417. declare module BABYLON {
  65418. /**
  65419. * Class used to enable access to IndexedDB
  65420. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65421. */
  65422. export class Database implements IOfflineProvider {
  65423. private _callbackManifestChecked;
  65424. private _currentSceneUrl;
  65425. private _db;
  65426. private _enableSceneOffline;
  65427. private _enableTexturesOffline;
  65428. private _manifestVersionFound;
  65429. private _mustUpdateRessources;
  65430. private _hasReachedQuota;
  65431. private _isSupported;
  65432. private _idbFactory;
  65433. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65434. private static IsUASupportingBlobStorage;
  65435. /**
  65436. * Gets a boolean indicating if Database storate is enabled (off by default)
  65437. */
  65438. static IDBStorageEnabled: boolean;
  65439. /**
  65440. * Gets a boolean indicating if scene must be saved in the database
  65441. */
  65442. get enableSceneOffline(): boolean;
  65443. /**
  65444. * Gets a boolean indicating if textures must be saved in the database
  65445. */
  65446. get enableTexturesOffline(): boolean;
  65447. /**
  65448. * Creates a new Database
  65449. * @param urlToScene defines the url to load the scene
  65450. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65451. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65452. */
  65453. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65454. private static _ParseURL;
  65455. private static _ReturnFullUrlLocation;
  65456. private _checkManifestFile;
  65457. /**
  65458. * Open the database and make it available
  65459. * @param successCallback defines the callback to call on success
  65460. * @param errorCallback defines the callback to call on error
  65461. */
  65462. open(successCallback: () => void, errorCallback: () => void): void;
  65463. /**
  65464. * Loads an image from the database
  65465. * @param url defines the url to load from
  65466. * @param image defines the target DOM image
  65467. */
  65468. loadImage(url: string, image: HTMLImageElement): void;
  65469. private _loadImageFromDBAsync;
  65470. private _saveImageIntoDBAsync;
  65471. private _checkVersionFromDB;
  65472. private _loadVersionFromDBAsync;
  65473. private _saveVersionIntoDBAsync;
  65474. /**
  65475. * Loads a file from database
  65476. * @param url defines the URL to load from
  65477. * @param sceneLoaded defines a callback to call on success
  65478. * @param progressCallBack defines a callback to call when progress changed
  65479. * @param errorCallback defines a callback to call on error
  65480. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65481. */
  65482. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65483. private _loadFileAsync;
  65484. private _saveFileAsync;
  65485. /**
  65486. * Validates if xhr data is correct
  65487. * @param xhr defines the request to validate
  65488. * @param dataType defines the expected data type
  65489. * @returns true if data is correct
  65490. */
  65491. private static _ValidateXHRData;
  65492. }
  65493. }
  65494. declare module BABYLON {
  65495. /** @hidden */
  65496. export var gpuUpdateParticlesPixelShader: {
  65497. name: string;
  65498. shader: string;
  65499. };
  65500. }
  65501. declare module BABYLON {
  65502. /** @hidden */
  65503. export var gpuUpdateParticlesVertexShader: {
  65504. name: string;
  65505. shader: string;
  65506. };
  65507. }
  65508. declare module BABYLON {
  65509. /** @hidden */
  65510. export var clipPlaneFragmentDeclaration2: {
  65511. name: string;
  65512. shader: string;
  65513. };
  65514. }
  65515. declare module BABYLON {
  65516. /** @hidden */
  65517. export var gpuRenderParticlesPixelShader: {
  65518. name: string;
  65519. shader: string;
  65520. };
  65521. }
  65522. declare module BABYLON {
  65523. /** @hidden */
  65524. export var clipPlaneVertexDeclaration2: {
  65525. name: string;
  65526. shader: string;
  65527. };
  65528. }
  65529. declare module BABYLON {
  65530. /** @hidden */
  65531. export var gpuRenderParticlesVertexShader: {
  65532. name: string;
  65533. shader: string;
  65534. };
  65535. }
  65536. declare module BABYLON {
  65537. /**
  65538. * This represents a GPU particle system in Babylon
  65539. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65540. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65541. */
  65542. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65543. /**
  65544. * The layer mask we are rendering the particles through.
  65545. */
  65546. layerMask: number;
  65547. private _capacity;
  65548. private _activeCount;
  65549. private _currentActiveCount;
  65550. private _accumulatedCount;
  65551. private _renderEffect;
  65552. private _updateEffect;
  65553. private _buffer0;
  65554. private _buffer1;
  65555. private _spriteBuffer;
  65556. private _updateVAO;
  65557. private _renderVAO;
  65558. private _targetIndex;
  65559. private _sourceBuffer;
  65560. private _targetBuffer;
  65561. private _engine;
  65562. private _currentRenderId;
  65563. private _started;
  65564. private _stopped;
  65565. private _timeDelta;
  65566. private _randomTexture;
  65567. private _randomTexture2;
  65568. private _attributesStrideSize;
  65569. private _updateEffectOptions;
  65570. private _randomTextureSize;
  65571. private _actualFrame;
  65572. private _customEffect;
  65573. private readonly _rawTextureWidth;
  65574. /**
  65575. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65576. */
  65577. static get IsSupported(): boolean;
  65578. /**
  65579. * An event triggered when the system is disposed.
  65580. */
  65581. onDisposeObservable: Observable<IParticleSystem>;
  65582. /**
  65583. * Gets the maximum number of particles active at the same time.
  65584. * @returns The max number of active particles.
  65585. */
  65586. getCapacity(): number;
  65587. /**
  65588. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65589. * to override the particles.
  65590. */
  65591. forceDepthWrite: boolean;
  65592. /**
  65593. * Gets or set the number of active particles
  65594. */
  65595. get activeParticleCount(): number;
  65596. set activeParticleCount(value: number);
  65597. private _preWarmDone;
  65598. /**
  65599. * Specifies if the particles are updated in emitter local space or world space.
  65600. */
  65601. isLocal: boolean;
  65602. /**
  65603. * Is this system ready to be used/rendered
  65604. * @return true if the system is ready
  65605. */
  65606. isReady(): boolean;
  65607. /**
  65608. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65609. * @returns True if it has been started, otherwise false.
  65610. */
  65611. isStarted(): boolean;
  65612. /**
  65613. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  65614. * @returns True if it has been stopped, otherwise false.
  65615. */
  65616. isStopped(): boolean;
  65617. /**
  65618. * Gets a boolean indicating that the system is stopping
  65619. * @returns true if the system is currently stopping
  65620. */
  65621. isStopping(): boolean;
  65622. /**
  65623. * Gets the number of particles active at the same time.
  65624. * @returns The number of active particles.
  65625. */
  65626. getActiveCount(): number;
  65627. /**
  65628. * Starts the particle system and begins to emit
  65629. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65630. */
  65631. start(delay?: number): void;
  65632. /**
  65633. * Stops the particle system.
  65634. */
  65635. stop(): void;
  65636. /**
  65637. * Remove all active particles
  65638. */
  65639. reset(): void;
  65640. /**
  65641. * Returns the string "GPUParticleSystem"
  65642. * @returns a string containing the class name
  65643. */
  65644. getClassName(): string;
  65645. /**
  65646. * Gets the custom effect used to render the particles
  65647. * @param blendMode Blend mode for which the effect should be retrieved
  65648. * @returns The effect
  65649. */
  65650. getCustomEffect(blendMode?: number): Nullable<Effect>;
  65651. /**
  65652. * Sets the custom effect used to render the particles
  65653. * @param effect The effect to set
  65654. * @param blendMode Blend mode for which the effect should be set
  65655. */
  65656. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  65657. /** @hidden */
  65658. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  65659. /**
  65660. * Observable that will be called just before the particles are drawn
  65661. */
  65662. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  65663. /**
  65664. * Gets the name of the particle vertex shader
  65665. */
  65666. get vertexShaderName(): string;
  65667. private _colorGradientsTexture;
  65668. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65669. /**
  65670. * Adds a new color gradient
  65671. * @param gradient defines the gradient to use (between 0 and 1)
  65672. * @param color1 defines the color to affect to the specified gradient
  65673. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65674. * @returns the current particle system
  65675. */
  65676. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65677. private _refreshColorGradient;
  65678. /** Force the system to rebuild all gradients that need to be resync */
  65679. forceRefreshGradients(): void;
  65680. /**
  65681. * Remove a specific color gradient
  65682. * @param gradient defines the gradient to remove
  65683. * @returns the current particle system
  65684. */
  65685. removeColorGradient(gradient: number): GPUParticleSystem;
  65686. private _angularSpeedGradientsTexture;
  65687. private _sizeGradientsTexture;
  65688. private _velocityGradientsTexture;
  65689. private _limitVelocityGradientsTexture;
  65690. private _dragGradientsTexture;
  65691. private _addFactorGradient;
  65692. /**
  65693. * Adds a new size gradient
  65694. * @param gradient defines the gradient to use (between 0 and 1)
  65695. * @param factor defines the size factor to affect to the specified gradient
  65696. * @returns the current particle system
  65697. */
  65698. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65699. /**
  65700. * Remove a specific size gradient
  65701. * @param gradient defines the gradient to remove
  65702. * @returns the current particle system
  65703. */
  65704. removeSizeGradient(gradient: number): GPUParticleSystem;
  65705. private _refreshFactorGradient;
  65706. /**
  65707. * Adds a new angular speed gradient
  65708. * @param gradient defines the gradient to use (between 0 and 1)
  65709. * @param factor defines the angular speed to affect to the specified gradient
  65710. * @returns the current particle system
  65711. */
  65712. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65713. /**
  65714. * Remove a specific angular speed gradient
  65715. * @param gradient defines the gradient to remove
  65716. * @returns the current particle system
  65717. */
  65718. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65719. /**
  65720. * Adds a new velocity gradient
  65721. * @param gradient defines the gradient to use (between 0 and 1)
  65722. * @param factor defines the velocity to affect to the specified gradient
  65723. * @returns the current particle system
  65724. */
  65725. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65726. /**
  65727. * Remove a specific velocity gradient
  65728. * @param gradient defines the gradient to remove
  65729. * @returns the current particle system
  65730. */
  65731. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65732. /**
  65733. * Adds a new limit velocity gradient
  65734. * @param gradient defines the gradient to use (between 0 and 1)
  65735. * @param factor defines the limit velocity value to affect to the specified gradient
  65736. * @returns the current particle system
  65737. */
  65738. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65739. /**
  65740. * Remove a specific limit velocity gradient
  65741. * @param gradient defines the gradient to remove
  65742. * @returns the current particle system
  65743. */
  65744. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65745. /**
  65746. * Adds a new drag gradient
  65747. * @param gradient defines the gradient to use (between 0 and 1)
  65748. * @param factor defines the drag value to affect to the specified gradient
  65749. * @returns the current particle system
  65750. */
  65751. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65752. /**
  65753. * Remove a specific drag gradient
  65754. * @param gradient defines the gradient to remove
  65755. * @returns the current particle system
  65756. */
  65757. removeDragGradient(gradient: number): GPUParticleSystem;
  65758. /**
  65759. * Not supported by GPUParticleSystem
  65760. * @param gradient defines the gradient to use (between 0 and 1)
  65761. * @param factor defines the emit rate value to affect to the specified gradient
  65762. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65763. * @returns the current particle system
  65764. */
  65765. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65766. /**
  65767. * Not supported by GPUParticleSystem
  65768. * @param gradient defines the gradient to remove
  65769. * @returns the current particle system
  65770. */
  65771. removeEmitRateGradient(gradient: number): IParticleSystem;
  65772. /**
  65773. * Not supported by GPUParticleSystem
  65774. * @param gradient defines the gradient to use (between 0 and 1)
  65775. * @param factor defines the start size value to affect to the specified gradient
  65776. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65777. * @returns the current particle system
  65778. */
  65779. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65780. /**
  65781. * Not supported by GPUParticleSystem
  65782. * @param gradient defines the gradient to remove
  65783. * @returns the current particle system
  65784. */
  65785. removeStartSizeGradient(gradient: number): IParticleSystem;
  65786. /**
  65787. * Not supported by GPUParticleSystem
  65788. * @param gradient defines the gradient to use (between 0 and 1)
  65789. * @param min defines the color remap minimal range
  65790. * @param max defines the color remap maximal range
  65791. * @returns the current particle system
  65792. */
  65793. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65794. /**
  65795. * Not supported by GPUParticleSystem
  65796. * @param gradient defines the gradient to remove
  65797. * @returns the current particle system
  65798. */
  65799. removeColorRemapGradient(): IParticleSystem;
  65800. /**
  65801. * Not supported by GPUParticleSystem
  65802. * @param gradient defines the gradient to use (between 0 and 1)
  65803. * @param min defines the alpha remap minimal range
  65804. * @param max defines the alpha remap maximal range
  65805. * @returns the current particle system
  65806. */
  65807. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65808. /**
  65809. * Not supported by GPUParticleSystem
  65810. * @param gradient defines the gradient to remove
  65811. * @returns the current particle system
  65812. */
  65813. removeAlphaRemapGradient(): IParticleSystem;
  65814. /**
  65815. * Not supported by GPUParticleSystem
  65816. * @param gradient defines the gradient to use (between 0 and 1)
  65817. * @param color defines the color to affect to the specified gradient
  65818. * @returns the current particle system
  65819. */
  65820. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65821. /**
  65822. * Not supported by GPUParticleSystem
  65823. * @param gradient defines the gradient to remove
  65824. * @returns the current particle system
  65825. */
  65826. removeRampGradient(): IParticleSystem;
  65827. /**
  65828. * Not supported by GPUParticleSystem
  65829. * @returns the list of ramp gradients
  65830. */
  65831. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65832. /**
  65833. * Not supported by GPUParticleSystem
  65834. * Gets or sets a boolean indicating that ramp gradients must be used
  65835. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65836. */
  65837. get useRampGradients(): boolean;
  65838. set useRampGradients(value: boolean);
  65839. /**
  65840. * Not supported by GPUParticleSystem
  65841. * @param gradient defines the gradient to use (between 0 and 1)
  65842. * @param factor defines the life time factor to affect to the specified gradient
  65843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65844. * @returns the current particle system
  65845. */
  65846. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65847. /**
  65848. * Not supported by GPUParticleSystem
  65849. * @param gradient defines the gradient to remove
  65850. * @returns the current particle system
  65851. */
  65852. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65853. /**
  65854. * Instantiates a GPU particle system.
  65855. * 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.
  65856. * @param name The name of the particle system
  65857. * @param options The options used to create the system
  65858. * @param scene The scene the particle system belongs to
  65859. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65860. * @param customEffect a custom effect used to change the way particles are rendered by default
  65861. */
  65862. constructor(name: string, options: Partial<{
  65863. capacity: number;
  65864. randomTextureSize: number;
  65865. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  65866. protected _reset(): void;
  65867. private _createUpdateVAO;
  65868. private _createRenderVAO;
  65869. private _initialize;
  65870. /** @hidden */
  65871. _recreateUpdateEffect(): void;
  65872. private _getEffect;
  65873. /**
  65874. * Fill the defines array according to the current settings of the particle system
  65875. * @param defines Array to be updated
  65876. * @param blendMode blend mode to take into account when updating the array
  65877. */
  65878. fillDefines(defines: Array<string>, blendMode?: number): void;
  65879. /**
  65880. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  65881. * @param uniforms Uniforms array to fill
  65882. * @param attributes Attributes array to fill
  65883. * @param samplers Samplers array to fill
  65884. */
  65885. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  65886. /** @hidden */
  65887. _recreateRenderEffect(): Effect;
  65888. /**
  65889. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65890. * @param preWarm defines if we are in the pre-warmimg phase
  65891. */
  65892. animate(preWarm?: boolean): void;
  65893. private _createFactorGradientTexture;
  65894. private _createSizeGradientTexture;
  65895. private _createAngularSpeedGradientTexture;
  65896. private _createVelocityGradientTexture;
  65897. private _createLimitVelocityGradientTexture;
  65898. private _createDragGradientTexture;
  65899. private _createColorGradientTexture;
  65900. /**
  65901. * Renders the particle system in its current state
  65902. * @param preWarm defines if the system should only update the particles but not render them
  65903. * @returns the current number of particles
  65904. */
  65905. render(preWarm?: boolean): number;
  65906. /**
  65907. * Rebuilds the particle system
  65908. */
  65909. rebuild(): void;
  65910. private _releaseBuffers;
  65911. private _releaseVAOs;
  65912. /**
  65913. * Disposes the particle system and free the associated resources
  65914. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65915. */
  65916. dispose(disposeTexture?: boolean): void;
  65917. /**
  65918. * Clones the particle system.
  65919. * @param name The name of the cloned object
  65920. * @param newEmitter The new emitter to use
  65921. * @returns the cloned particle system
  65922. */
  65923. clone(name: string, newEmitter: any): GPUParticleSystem;
  65924. /**
  65925. * Serializes the particle system to a JSON object
  65926. * @param serializeTexture defines if the texture must be serialized as well
  65927. * @returns the JSON object
  65928. */
  65929. serialize(serializeTexture?: boolean): any;
  65930. /**
  65931. * Parses a JSON object to create a GPU particle system.
  65932. * @param parsedParticleSystem The JSON object to parse
  65933. * @param scene The scene to create the particle system in
  65934. * @param rootUrl The root url to use to load external dependencies like texture
  65935. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65936. * @returns the parsed GPU particle system
  65937. */
  65938. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65939. }
  65940. }
  65941. declare module BABYLON {
  65942. /**
  65943. * Represents a set of particle systems working together to create a specific effect
  65944. */
  65945. export class ParticleSystemSet implements IDisposable {
  65946. /**
  65947. * Gets or sets base Assets URL
  65948. */
  65949. static BaseAssetsUrl: string;
  65950. private _emitterCreationOptions;
  65951. private _emitterNode;
  65952. /**
  65953. * Gets the particle system list
  65954. */
  65955. systems: IParticleSystem[];
  65956. /**
  65957. * Gets the emitter node used with this set
  65958. */
  65959. get emitterNode(): Nullable<TransformNode>;
  65960. /**
  65961. * Creates a new emitter mesh as a sphere
  65962. * @param options defines the options used to create the sphere
  65963. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65964. * @param scene defines the hosting scene
  65965. */
  65966. setEmitterAsSphere(options: {
  65967. diameter: number;
  65968. segments: number;
  65969. color: Color3;
  65970. }, renderingGroupId: number, scene: Scene): void;
  65971. /**
  65972. * Starts all particle systems of the set
  65973. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65974. */
  65975. start(emitter?: AbstractMesh): void;
  65976. /**
  65977. * Release all associated resources
  65978. */
  65979. dispose(): void;
  65980. /**
  65981. * Serialize the set into a JSON compatible object
  65982. * @param serializeTexture defines if the texture must be serialized as well
  65983. * @returns a JSON compatible representation of the set
  65984. */
  65985. serialize(serializeTexture?: boolean): any;
  65986. /**
  65987. * Parse a new ParticleSystemSet from a serialized source
  65988. * @param data defines a JSON compatible representation of the set
  65989. * @param scene defines the hosting scene
  65990. * @param gpu defines if we want GPU particles or CPU particles
  65991. * @returns a new ParticleSystemSet
  65992. */
  65993. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  65994. }
  65995. }
  65996. declare module BABYLON {
  65997. /**
  65998. * This class is made for on one-liner static method to help creating particle system set.
  65999. */
  66000. export class ParticleHelper {
  66001. /**
  66002. * Gets or sets base Assets URL
  66003. */
  66004. static BaseAssetsUrl: string;
  66005. /** Define the Url to load snippets */
  66006. static SnippetUrl: string;
  66007. /**
  66008. * Create a default particle system that you can tweak
  66009. * @param emitter defines the emitter to use
  66010. * @param capacity defines the system capacity (default is 500 particles)
  66011. * @param scene defines the hosting scene
  66012. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66013. * @returns the new Particle system
  66014. */
  66015. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66016. /**
  66017. * This is the main static method (one-liner) of this helper to create different particle systems
  66018. * @param type This string represents the type to the particle system to create
  66019. * @param scene The scene where the particle system should live
  66020. * @param gpu If the system will use gpu
  66021. * @returns the ParticleSystemSet created
  66022. */
  66023. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66024. /**
  66025. * Static function used to export a particle system to a ParticleSystemSet variable.
  66026. * Please note that the emitter shape is not exported
  66027. * @param systems defines the particle systems to export
  66028. * @returns the created particle system set
  66029. */
  66030. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66031. /**
  66032. * Creates a particle system from a snippet saved in a remote file
  66033. * @param name defines the name of the particle system to create
  66034. * @param url defines the url to load from
  66035. * @param scene defines the hosting scene
  66036. * @param gpu If the system will use gpu
  66037. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66038. * @returns a promise that will resolve to the new particle system
  66039. */
  66040. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66041. /**
  66042. * Creates a particle system from a snippet saved by the particle system editor
  66043. * @param snippetId defines the snippet to load
  66044. * @param scene defines the hosting scene
  66045. * @param gpu If the system will use gpu
  66046. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66047. * @returns a promise that will resolve to the new particle system
  66048. */
  66049. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66050. }
  66051. }
  66052. declare module BABYLON {
  66053. interface Engine {
  66054. /**
  66055. * Create an effect to use with particle systems.
  66056. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66057. * the particle system for which you want to create a custom effect in the last parameter
  66058. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66059. * @param uniformsNames defines a list of attribute names
  66060. * @param samplers defines an array of string used to represent textures
  66061. * @param defines defines the string containing the defines to use to compile the shaders
  66062. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66063. * @param onCompiled defines a function to call when the effect creation is successful
  66064. * @param onError defines a function to call when the effect creation has failed
  66065. * @param particleSystem the particle system you want to create the effect for
  66066. * @returns the new Effect
  66067. */
  66068. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66069. }
  66070. interface Mesh {
  66071. /**
  66072. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66073. * @returns an array of IParticleSystem
  66074. */
  66075. getEmittedParticleSystems(): IParticleSystem[];
  66076. /**
  66077. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66078. * @returns an array of IParticleSystem
  66079. */
  66080. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66081. }
  66082. /**
  66083. * @hidden
  66084. */
  66085. export var _IDoNeedToBeInTheBuild: number;
  66086. }
  66087. declare module BABYLON {
  66088. /** Defines the 4 color options */
  66089. export enum PointColor {
  66090. /** color value */
  66091. Color = 2,
  66092. /** uv value */
  66093. UV = 1,
  66094. /** random value */
  66095. Random = 0,
  66096. /** stated value */
  66097. Stated = 3
  66098. }
  66099. /**
  66100. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66101. * 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.
  66102. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66103. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66104. *
  66105. * Full documentation here : TO BE ENTERED
  66106. */
  66107. export class PointsCloudSystem implements IDisposable {
  66108. /**
  66109. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66110. * Example : var p = SPS.particles[i];
  66111. */
  66112. particles: CloudPoint[];
  66113. /**
  66114. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66115. */
  66116. nbParticles: number;
  66117. /**
  66118. * This a counter for your own usage. It's not set by any SPS functions.
  66119. */
  66120. counter: number;
  66121. /**
  66122. * The PCS name. This name is also given to the underlying mesh.
  66123. */
  66124. name: string;
  66125. /**
  66126. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66127. */
  66128. mesh: Mesh;
  66129. /**
  66130. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66131. * Please read :
  66132. */
  66133. vars: any;
  66134. /**
  66135. * @hidden
  66136. */
  66137. _size: number;
  66138. private _scene;
  66139. private _promises;
  66140. private _positions;
  66141. private _indices;
  66142. private _normals;
  66143. private _colors;
  66144. private _uvs;
  66145. private _indices32;
  66146. private _positions32;
  66147. private _colors32;
  66148. private _uvs32;
  66149. private _updatable;
  66150. private _isVisibilityBoxLocked;
  66151. private _alwaysVisible;
  66152. private _groups;
  66153. private _groupCounter;
  66154. private _computeParticleColor;
  66155. private _computeParticleTexture;
  66156. private _computeParticleRotation;
  66157. private _computeBoundingBox;
  66158. private _isReady;
  66159. /**
  66160. * Creates a PCS (Points Cloud System) object
  66161. * @param name (String) is the PCS name, this will be the underlying mesh name
  66162. * @param pointSize (number) is the size for each point
  66163. * @param scene (Scene) is the scene in which the PCS is added
  66164. * @param options defines the options of the PCS e.g.
  66165. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66166. */
  66167. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66168. updatable?: boolean;
  66169. });
  66170. /**
  66171. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66172. * If no points were added to the PCS, the returned mesh is just a single point.
  66173. * @returns a promise for the created mesh
  66174. */
  66175. buildMeshAsync(): Promise<Mesh>;
  66176. /**
  66177. * @hidden
  66178. */
  66179. private _buildMesh;
  66180. private _addParticle;
  66181. private _randomUnitVector;
  66182. private _getColorIndicesForCoord;
  66183. private _setPointsColorOrUV;
  66184. private _colorFromTexture;
  66185. private _calculateDensity;
  66186. /**
  66187. * Adds points to the PCS in random positions within a unit sphere
  66188. * @param nb (positive integer) the number of particles to be created from this model
  66189. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66190. * @returns the number of groups in the system
  66191. */
  66192. addPoints(nb: number, pointFunction?: any): number;
  66193. /**
  66194. * Adds points to the PCS from the surface of the model shape
  66195. * @param mesh is any Mesh object that will be used as a surface model for the points
  66196. * @param nb (positive integer) the number of particles to be created from this model
  66197. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66198. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66199. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66200. * @returns the number of groups in the system
  66201. */
  66202. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66203. /**
  66204. * Adds points to the PCS inside the model shape
  66205. * @param mesh is any Mesh object that will be used as a surface model for the points
  66206. * @param nb (positive integer) the number of particles to be created from this model
  66207. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66208. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66209. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66210. * @returns the number of groups in the system
  66211. */
  66212. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66213. /**
  66214. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66215. * This method calls `updateParticle()` for each particle of the SPS.
  66216. * For an animated SPS, it is usually called within the render loop.
  66217. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66218. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66219. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66220. * @returns the PCS.
  66221. */
  66222. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66223. /**
  66224. * Disposes the PCS.
  66225. */
  66226. dispose(): void;
  66227. /**
  66228. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66229. * doc :
  66230. * @returns the PCS.
  66231. */
  66232. refreshVisibleSize(): PointsCloudSystem;
  66233. /**
  66234. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66235. * @param size the size (float) of the visibility box
  66236. * note : this doesn't lock the PCS mesh bounding box.
  66237. * doc :
  66238. */
  66239. setVisibilityBox(size: number): void;
  66240. /**
  66241. * Gets whether the PCS is always visible or not
  66242. * doc :
  66243. */
  66244. get isAlwaysVisible(): boolean;
  66245. /**
  66246. * Sets the PCS as always visible or not
  66247. * doc :
  66248. */
  66249. set isAlwaysVisible(val: boolean);
  66250. /**
  66251. * Tells to `setParticles()` to compute the particle rotations or not
  66252. * Default value : false. The PCS is faster when it's set to false
  66253. * Note : particle rotations are only applied to parent particles
  66254. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66255. */
  66256. set computeParticleRotation(val: boolean);
  66257. /**
  66258. * Tells to `setParticles()` to compute the particle colors or not.
  66259. * Default value : true. The PCS is faster when it's set to false.
  66260. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66261. */
  66262. set computeParticleColor(val: boolean);
  66263. set computeParticleTexture(val: boolean);
  66264. /**
  66265. * Gets if `setParticles()` computes the particle colors or not.
  66266. * Default value : false. The PCS is faster when it's set to false.
  66267. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66268. */
  66269. get computeParticleColor(): boolean;
  66270. /**
  66271. * Gets if `setParticles()` computes the particle textures or not.
  66272. * Default value : false. The PCS is faster when it's set to false.
  66273. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66274. */
  66275. get computeParticleTexture(): boolean;
  66276. /**
  66277. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66278. */
  66279. set computeBoundingBox(val: boolean);
  66280. /**
  66281. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66282. */
  66283. get computeBoundingBox(): boolean;
  66284. /**
  66285. * This function does nothing. It may be overwritten to set all the particle first values.
  66286. * The PCS doesn't call this function, you may have to call it by your own.
  66287. * doc :
  66288. */
  66289. initParticles(): void;
  66290. /**
  66291. * This function does nothing. It may be overwritten to recycle a particle
  66292. * The PCS doesn't call this function, you can to call it
  66293. * doc :
  66294. * @param particle The particle to recycle
  66295. * @returns the recycled particle
  66296. */
  66297. recycleParticle(particle: CloudPoint): CloudPoint;
  66298. /**
  66299. * Updates a particle : this function should be overwritten by the user.
  66300. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66301. * doc :
  66302. * @example : just set a particle position or velocity and recycle conditions
  66303. * @param particle The particle to update
  66304. * @returns the updated particle
  66305. */
  66306. updateParticle(particle: CloudPoint): CloudPoint;
  66307. /**
  66308. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66309. * This does nothing and may be overwritten by the user.
  66310. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66311. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66312. * @param update the boolean update value actually passed to setParticles()
  66313. */
  66314. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66315. /**
  66316. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66317. * This will be passed three parameters.
  66318. * This does nothing and may be overwritten by the user.
  66319. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66320. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66321. * @param update the boolean update value actually passed to setParticles()
  66322. */
  66323. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66324. }
  66325. }
  66326. declare module BABYLON {
  66327. /**
  66328. * Represents one particle of a points cloud system.
  66329. */
  66330. export class CloudPoint {
  66331. /**
  66332. * particle global index
  66333. */
  66334. idx: number;
  66335. /**
  66336. * The color of the particle
  66337. */
  66338. color: Nullable<Color4>;
  66339. /**
  66340. * The world space position of the particle.
  66341. */
  66342. position: Vector3;
  66343. /**
  66344. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66345. */
  66346. rotation: Vector3;
  66347. /**
  66348. * The world space rotation quaternion of the particle.
  66349. */
  66350. rotationQuaternion: Nullable<Quaternion>;
  66351. /**
  66352. * The uv of the particle.
  66353. */
  66354. uv: Nullable<Vector2>;
  66355. /**
  66356. * The current speed of the particle.
  66357. */
  66358. velocity: Vector3;
  66359. /**
  66360. * The pivot point in the particle local space.
  66361. */
  66362. pivot: Vector3;
  66363. /**
  66364. * Must the particle be translated from its pivot point in its local space ?
  66365. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66366. * Default : false
  66367. */
  66368. translateFromPivot: boolean;
  66369. /**
  66370. * Index of this particle in the global "positions" array (Internal use)
  66371. * @hidden
  66372. */
  66373. _pos: number;
  66374. /**
  66375. * @hidden Index of this particle in the global "indices" array (Internal use)
  66376. */
  66377. _ind: number;
  66378. /**
  66379. * Group this particle belongs to
  66380. */
  66381. _group: PointsGroup;
  66382. /**
  66383. * Group id of this particle
  66384. */
  66385. groupId: number;
  66386. /**
  66387. * Index of the particle in its group id (Internal use)
  66388. */
  66389. idxInGroup: number;
  66390. /**
  66391. * @hidden Particle BoundingInfo object (Internal use)
  66392. */
  66393. _boundingInfo: BoundingInfo;
  66394. /**
  66395. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66396. */
  66397. _pcs: PointsCloudSystem;
  66398. /**
  66399. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66400. */
  66401. _stillInvisible: boolean;
  66402. /**
  66403. * @hidden Last computed particle rotation matrix
  66404. */
  66405. _rotationMatrix: number[];
  66406. /**
  66407. * Parent particle Id, if any.
  66408. * Default null.
  66409. */
  66410. parentId: Nullable<number>;
  66411. /**
  66412. * @hidden Internal global position in the PCS.
  66413. */
  66414. _globalPosition: Vector3;
  66415. /**
  66416. * Creates a Point Cloud object.
  66417. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66418. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66419. * @param group (PointsGroup) is the group the particle belongs to
  66420. * @param groupId (integer) is the group identifier in the PCS.
  66421. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66422. * @param pcs defines the PCS it is associated to
  66423. */
  66424. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66425. /**
  66426. * get point size
  66427. */
  66428. get size(): Vector3;
  66429. /**
  66430. * Set point size
  66431. */
  66432. set size(scale: Vector3);
  66433. /**
  66434. * Legacy support, changed quaternion to rotationQuaternion
  66435. */
  66436. get quaternion(): Nullable<Quaternion>;
  66437. /**
  66438. * Legacy support, changed quaternion to rotationQuaternion
  66439. */
  66440. set quaternion(q: Nullable<Quaternion>);
  66441. /**
  66442. * Returns a boolean. True if the particle intersects a mesh, else false
  66443. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66444. * @param target is the object (point or mesh) what the intersection is computed against
  66445. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66446. * @returns true if it intersects
  66447. */
  66448. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66449. /**
  66450. * get the rotation matrix of the particle
  66451. * @hidden
  66452. */
  66453. getRotationMatrix(m: Matrix): void;
  66454. }
  66455. /**
  66456. * Represents a group of points in a points cloud system
  66457. * * PCS internal tool, don't use it manually.
  66458. */
  66459. export class PointsGroup {
  66460. /**
  66461. * The group id
  66462. * @hidden
  66463. */
  66464. groupID: number;
  66465. /**
  66466. * image data for group (internal use)
  66467. * @hidden
  66468. */
  66469. _groupImageData: Nullable<ArrayBufferView>;
  66470. /**
  66471. * Image Width (internal use)
  66472. * @hidden
  66473. */
  66474. _groupImgWidth: number;
  66475. /**
  66476. * Image Height (internal use)
  66477. * @hidden
  66478. */
  66479. _groupImgHeight: number;
  66480. /**
  66481. * Custom position function (internal use)
  66482. * @hidden
  66483. */
  66484. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66485. /**
  66486. * density per facet for surface points
  66487. * @hidden
  66488. */
  66489. _groupDensity: number[];
  66490. /**
  66491. * Only when points are colored by texture carries pointer to texture list array
  66492. * @hidden
  66493. */
  66494. _textureNb: number;
  66495. /**
  66496. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66497. * PCS internal tool, don't use it manually.
  66498. * @hidden
  66499. */
  66500. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66501. }
  66502. }
  66503. declare module BABYLON {
  66504. interface Scene {
  66505. /** @hidden (Backing field) */
  66506. _physicsEngine: Nullable<IPhysicsEngine>;
  66507. /** @hidden */
  66508. _physicsTimeAccumulator: number;
  66509. /**
  66510. * Gets the current physics engine
  66511. * @returns a IPhysicsEngine or null if none attached
  66512. */
  66513. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66514. /**
  66515. * Enables physics to the current scene
  66516. * @param gravity defines the scene's gravity for the physics engine
  66517. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66518. * @return a boolean indicating if the physics engine was initialized
  66519. */
  66520. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66521. /**
  66522. * Disables and disposes the physics engine associated with the scene
  66523. */
  66524. disablePhysicsEngine(): void;
  66525. /**
  66526. * Gets a boolean indicating if there is an active physics engine
  66527. * @returns a boolean indicating if there is an active physics engine
  66528. */
  66529. isPhysicsEnabled(): boolean;
  66530. /**
  66531. * Deletes a physics compound impostor
  66532. * @param compound defines the compound to delete
  66533. */
  66534. deleteCompoundImpostor(compound: any): void;
  66535. /**
  66536. * An event triggered when physic simulation is about to be run
  66537. */
  66538. onBeforePhysicsObservable: Observable<Scene>;
  66539. /**
  66540. * An event triggered when physic simulation has been done
  66541. */
  66542. onAfterPhysicsObservable: Observable<Scene>;
  66543. }
  66544. interface AbstractMesh {
  66545. /** @hidden */
  66546. _physicsImpostor: Nullable<PhysicsImpostor>;
  66547. /**
  66548. * Gets or sets impostor used for physic simulation
  66549. * @see http://doc.babylonjs.com/features/physics_engine
  66550. */
  66551. physicsImpostor: Nullable<PhysicsImpostor>;
  66552. /**
  66553. * Gets the current physics impostor
  66554. * @see http://doc.babylonjs.com/features/physics_engine
  66555. * @returns a physics impostor or null
  66556. */
  66557. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66558. /** Apply a physic impulse to the mesh
  66559. * @param force defines the force to apply
  66560. * @param contactPoint defines where to apply the force
  66561. * @returns the current mesh
  66562. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66563. */
  66564. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66565. /**
  66566. * Creates a physic joint between two meshes
  66567. * @param otherMesh defines the other mesh to use
  66568. * @param pivot1 defines the pivot to use on this mesh
  66569. * @param pivot2 defines the pivot to use on the other mesh
  66570. * @param options defines additional options (can be plugin dependent)
  66571. * @returns the current mesh
  66572. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66573. */
  66574. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66575. /** @hidden */
  66576. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66577. }
  66578. /**
  66579. * Defines the physics engine scene component responsible to manage a physics engine
  66580. */
  66581. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66582. /**
  66583. * The component name helpful to identify the component in the list of scene components.
  66584. */
  66585. readonly name: string;
  66586. /**
  66587. * The scene the component belongs to.
  66588. */
  66589. scene: Scene;
  66590. /**
  66591. * Creates a new instance of the component for the given scene
  66592. * @param scene Defines the scene to register the component in
  66593. */
  66594. constructor(scene: Scene);
  66595. /**
  66596. * Registers the component in a given scene
  66597. */
  66598. register(): void;
  66599. /**
  66600. * Rebuilds the elements related to this component in case of
  66601. * context lost for instance.
  66602. */
  66603. rebuild(): void;
  66604. /**
  66605. * Disposes the component and the associated ressources
  66606. */
  66607. dispose(): void;
  66608. }
  66609. }
  66610. declare module BABYLON {
  66611. /**
  66612. * A helper for physics simulations
  66613. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66614. */
  66615. export class PhysicsHelper {
  66616. private _scene;
  66617. private _physicsEngine;
  66618. /**
  66619. * Initializes the Physics helper
  66620. * @param scene Babylon.js scene
  66621. */
  66622. constructor(scene: Scene);
  66623. /**
  66624. * Applies a radial explosion impulse
  66625. * @param origin the origin of the explosion
  66626. * @param radiusOrEventOptions the radius or the options of radial explosion
  66627. * @param strength the explosion strength
  66628. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66629. * @returns A physics radial explosion event, or null
  66630. */
  66631. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66632. /**
  66633. * Applies a radial explosion force
  66634. * @param origin the origin of the explosion
  66635. * @param radiusOrEventOptions the radius or the options of radial explosion
  66636. * @param strength the explosion strength
  66637. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66638. * @returns A physics radial explosion event, or null
  66639. */
  66640. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66641. /**
  66642. * Creates a gravitational field
  66643. * @param origin the origin of the explosion
  66644. * @param radiusOrEventOptions the radius or the options of radial explosion
  66645. * @param strength the explosion strength
  66646. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66647. * @returns A physics gravitational field event, or null
  66648. */
  66649. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66650. /**
  66651. * Creates a physics updraft event
  66652. * @param origin the origin of the updraft
  66653. * @param radiusOrEventOptions the radius or the options of the updraft
  66654. * @param strength the strength of the updraft
  66655. * @param height the height of the updraft
  66656. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66657. * @returns A physics updraft event, or null
  66658. */
  66659. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66660. /**
  66661. * Creates a physics vortex event
  66662. * @param origin the of the vortex
  66663. * @param radiusOrEventOptions the radius or the options of the vortex
  66664. * @param strength the strength of the vortex
  66665. * @param height the height of the vortex
  66666. * @returns a Physics vortex event, or null
  66667. * A physics vortex event or null
  66668. */
  66669. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66670. }
  66671. /**
  66672. * Represents a physics radial explosion event
  66673. */
  66674. class PhysicsRadialExplosionEvent {
  66675. private _scene;
  66676. private _options;
  66677. private _sphere;
  66678. private _dataFetched;
  66679. /**
  66680. * Initializes a radial explosioin event
  66681. * @param _scene BabylonJS scene
  66682. * @param _options The options for the vortex event
  66683. */
  66684. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66685. /**
  66686. * Returns the data related to the radial explosion event (sphere).
  66687. * @returns The radial explosion event data
  66688. */
  66689. getData(): PhysicsRadialExplosionEventData;
  66690. /**
  66691. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66692. * @param impostor A physics imposter
  66693. * @param origin the origin of the explosion
  66694. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66695. */
  66696. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66697. /**
  66698. * Triggers affecterd impostors callbacks
  66699. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66700. */
  66701. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66702. /**
  66703. * Disposes the sphere.
  66704. * @param force Specifies if the sphere should be disposed by force
  66705. */
  66706. dispose(force?: boolean): void;
  66707. /*** Helpers ***/
  66708. private _prepareSphere;
  66709. private _intersectsWithSphere;
  66710. }
  66711. /**
  66712. * Represents a gravitational field event
  66713. */
  66714. class PhysicsGravitationalFieldEvent {
  66715. private _physicsHelper;
  66716. private _scene;
  66717. private _origin;
  66718. private _options;
  66719. private _tickCallback;
  66720. private _sphere;
  66721. private _dataFetched;
  66722. /**
  66723. * Initializes the physics gravitational field event
  66724. * @param _physicsHelper A physics helper
  66725. * @param _scene BabylonJS scene
  66726. * @param _origin The origin position of the gravitational field event
  66727. * @param _options The options for the vortex event
  66728. */
  66729. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66730. /**
  66731. * Returns the data related to the gravitational field event (sphere).
  66732. * @returns A gravitational field event
  66733. */
  66734. getData(): PhysicsGravitationalFieldEventData;
  66735. /**
  66736. * Enables the gravitational field.
  66737. */
  66738. enable(): void;
  66739. /**
  66740. * Disables the gravitational field.
  66741. */
  66742. disable(): void;
  66743. /**
  66744. * Disposes the sphere.
  66745. * @param force The force to dispose from the gravitational field event
  66746. */
  66747. dispose(force?: boolean): void;
  66748. private _tick;
  66749. }
  66750. /**
  66751. * Represents a physics updraft event
  66752. */
  66753. class PhysicsUpdraftEvent {
  66754. private _scene;
  66755. private _origin;
  66756. private _options;
  66757. private _physicsEngine;
  66758. private _originTop;
  66759. private _originDirection;
  66760. private _tickCallback;
  66761. private _cylinder;
  66762. private _cylinderPosition;
  66763. private _dataFetched;
  66764. /**
  66765. * Initializes the physics updraft event
  66766. * @param _scene BabylonJS scene
  66767. * @param _origin The origin position of the updraft
  66768. * @param _options The options for the updraft event
  66769. */
  66770. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66771. /**
  66772. * Returns the data related to the updraft event (cylinder).
  66773. * @returns A physics updraft event
  66774. */
  66775. getData(): PhysicsUpdraftEventData;
  66776. /**
  66777. * Enables the updraft.
  66778. */
  66779. enable(): void;
  66780. /**
  66781. * Disables the updraft.
  66782. */
  66783. disable(): void;
  66784. /**
  66785. * Disposes the cylinder.
  66786. * @param force Specifies if the updraft should be disposed by force
  66787. */
  66788. dispose(force?: boolean): void;
  66789. private getImpostorHitData;
  66790. private _tick;
  66791. /*** Helpers ***/
  66792. private _prepareCylinder;
  66793. private _intersectsWithCylinder;
  66794. }
  66795. /**
  66796. * Represents a physics vortex event
  66797. */
  66798. class PhysicsVortexEvent {
  66799. private _scene;
  66800. private _origin;
  66801. private _options;
  66802. private _physicsEngine;
  66803. private _originTop;
  66804. private _tickCallback;
  66805. private _cylinder;
  66806. private _cylinderPosition;
  66807. private _dataFetched;
  66808. /**
  66809. * Initializes the physics vortex event
  66810. * @param _scene The BabylonJS scene
  66811. * @param _origin The origin position of the vortex
  66812. * @param _options The options for the vortex event
  66813. */
  66814. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66815. /**
  66816. * Returns the data related to the vortex event (cylinder).
  66817. * @returns The physics vortex event data
  66818. */
  66819. getData(): PhysicsVortexEventData;
  66820. /**
  66821. * Enables the vortex.
  66822. */
  66823. enable(): void;
  66824. /**
  66825. * Disables the cortex.
  66826. */
  66827. disable(): void;
  66828. /**
  66829. * Disposes the sphere.
  66830. * @param force
  66831. */
  66832. dispose(force?: boolean): void;
  66833. private getImpostorHitData;
  66834. private _tick;
  66835. /*** Helpers ***/
  66836. private _prepareCylinder;
  66837. private _intersectsWithCylinder;
  66838. }
  66839. /**
  66840. * Options fot the radial explosion event
  66841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66842. */
  66843. export class PhysicsRadialExplosionEventOptions {
  66844. /**
  66845. * The radius of the sphere for the radial explosion.
  66846. */
  66847. radius: number;
  66848. /**
  66849. * The strenth of the explosion.
  66850. */
  66851. strength: number;
  66852. /**
  66853. * The strenght of the force in correspondence to the distance of the affected object
  66854. */
  66855. falloff: PhysicsRadialImpulseFalloff;
  66856. /**
  66857. * Sphere options for the radial explosion.
  66858. */
  66859. sphere: {
  66860. segments: number;
  66861. diameter: number;
  66862. };
  66863. /**
  66864. * Sphere options for the radial explosion.
  66865. */
  66866. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66867. }
  66868. /**
  66869. * Options fot the updraft event
  66870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66871. */
  66872. export class PhysicsUpdraftEventOptions {
  66873. /**
  66874. * The radius of the cylinder for the vortex
  66875. */
  66876. radius: number;
  66877. /**
  66878. * The strenth of the updraft.
  66879. */
  66880. strength: number;
  66881. /**
  66882. * The height of the cylinder for the updraft.
  66883. */
  66884. height: number;
  66885. /**
  66886. * The mode for the the updraft.
  66887. */
  66888. updraftMode: PhysicsUpdraftMode;
  66889. }
  66890. /**
  66891. * Options fot the vortex event
  66892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66893. */
  66894. export class PhysicsVortexEventOptions {
  66895. /**
  66896. * The radius of the cylinder for the vortex
  66897. */
  66898. radius: number;
  66899. /**
  66900. * The strenth of the vortex.
  66901. */
  66902. strength: number;
  66903. /**
  66904. * The height of the cylinder for the vortex.
  66905. */
  66906. height: number;
  66907. /**
  66908. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66909. */
  66910. centripetalForceThreshold: number;
  66911. /**
  66912. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66913. */
  66914. centripetalForceMultiplier: number;
  66915. /**
  66916. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66917. */
  66918. centrifugalForceMultiplier: number;
  66919. /**
  66920. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66921. */
  66922. updraftForceMultiplier: number;
  66923. }
  66924. /**
  66925. * The strenght of the force in correspondence to the distance of the affected object
  66926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66927. */
  66928. export enum PhysicsRadialImpulseFalloff {
  66929. /** Defines that impulse is constant in strength across it's whole radius */
  66930. Constant = 0,
  66931. /** Defines that impulse gets weaker if it's further from the origin */
  66932. Linear = 1
  66933. }
  66934. /**
  66935. * The strength of the force in correspondence to the distance of the affected object
  66936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66937. */
  66938. export enum PhysicsUpdraftMode {
  66939. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66940. Center = 0,
  66941. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66942. Perpendicular = 1
  66943. }
  66944. /**
  66945. * Interface for a physics hit data
  66946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66947. */
  66948. export interface PhysicsHitData {
  66949. /**
  66950. * The force applied at the contact point
  66951. */
  66952. force: Vector3;
  66953. /**
  66954. * The contact point
  66955. */
  66956. contactPoint: Vector3;
  66957. /**
  66958. * The distance from the origin to the contact point
  66959. */
  66960. distanceFromOrigin: number;
  66961. }
  66962. /**
  66963. * Interface for radial explosion event data
  66964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66965. */
  66966. export interface PhysicsRadialExplosionEventData {
  66967. /**
  66968. * A sphere used for the radial explosion event
  66969. */
  66970. sphere: Mesh;
  66971. }
  66972. /**
  66973. * Interface for gravitational field event data
  66974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66975. */
  66976. export interface PhysicsGravitationalFieldEventData {
  66977. /**
  66978. * A sphere mesh used for the gravitational field event
  66979. */
  66980. sphere: Mesh;
  66981. }
  66982. /**
  66983. * Interface for updraft event data
  66984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66985. */
  66986. export interface PhysicsUpdraftEventData {
  66987. /**
  66988. * A cylinder used for the updraft event
  66989. */
  66990. cylinder: Mesh;
  66991. }
  66992. /**
  66993. * Interface for vortex event data
  66994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66995. */
  66996. export interface PhysicsVortexEventData {
  66997. /**
  66998. * A cylinder used for the vortex event
  66999. */
  67000. cylinder: Mesh;
  67001. }
  67002. /**
  67003. * Interface for an affected physics impostor
  67004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67005. */
  67006. export interface PhysicsAffectedImpostorWithData {
  67007. /**
  67008. * The impostor affected by the effect
  67009. */
  67010. impostor: PhysicsImpostor;
  67011. /**
  67012. * The data about the hit/horce from the explosion
  67013. */
  67014. hitData: PhysicsHitData;
  67015. }
  67016. }
  67017. declare module BABYLON {
  67018. /** @hidden */
  67019. export var blackAndWhitePixelShader: {
  67020. name: string;
  67021. shader: string;
  67022. };
  67023. }
  67024. declare module BABYLON {
  67025. /**
  67026. * Post process used to render in black and white
  67027. */
  67028. export class BlackAndWhitePostProcess extends PostProcess {
  67029. /**
  67030. * Linear about to convert he result to black and white (default: 1)
  67031. */
  67032. degree: number;
  67033. /**
  67034. * Creates a black and white post process
  67035. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67036. * @param name The name of the effect.
  67037. * @param options The required width/height ratio to downsize to before computing the render pass.
  67038. * @param camera The camera to apply the render pass to.
  67039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67040. * @param engine The engine which the post process will be applied. (default: current engine)
  67041. * @param reusable If the post process can be reused on the same frame. (default: false)
  67042. */
  67043. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67044. }
  67045. }
  67046. declare module BABYLON {
  67047. /**
  67048. * This represents a set of one or more post processes in Babylon.
  67049. * A post process can be used to apply a shader to a texture after it is rendered.
  67050. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67051. */
  67052. export class PostProcessRenderEffect {
  67053. private _postProcesses;
  67054. private _getPostProcesses;
  67055. private _singleInstance;
  67056. private _cameras;
  67057. private _indicesForCamera;
  67058. /**
  67059. * Name of the effect
  67060. * @hidden
  67061. */
  67062. _name: string;
  67063. /**
  67064. * Instantiates a post process render effect.
  67065. * A post process can be used to apply a shader to a texture after it is rendered.
  67066. * @param engine The engine the effect is tied to
  67067. * @param name The name of the effect
  67068. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67069. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67070. */
  67071. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67072. /**
  67073. * Checks if all the post processes in the effect are supported.
  67074. */
  67075. get isSupported(): boolean;
  67076. /**
  67077. * Updates the current state of the effect
  67078. * @hidden
  67079. */
  67080. _update(): void;
  67081. /**
  67082. * Attaches the effect on cameras
  67083. * @param cameras The camera to attach to.
  67084. * @hidden
  67085. */
  67086. _attachCameras(cameras: Camera): void;
  67087. /**
  67088. * Attaches the effect on cameras
  67089. * @param cameras The camera to attach to.
  67090. * @hidden
  67091. */
  67092. _attachCameras(cameras: Camera[]): void;
  67093. /**
  67094. * Detaches the effect on cameras
  67095. * @param cameras The camera to detatch from.
  67096. * @hidden
  67097. */
  67098. _detachCameras(cameras: Camera): void;
  67099. /**
  67100. * Detatches the effect on cameras
  67101. * @param cameras The camera to detatch from.
  67102. * @hidden
  67103. */
  67104. _detachCameras(cameras: Camera[]): void;
  67105. /**
  67106. * Enables the effect on given cameras
  67107. * @param cameras The camera to enable.
  67108. * @hidden
  67109. */
  67110. _enable(cameras: Camera): void;
  67111. /**
  67112. * Enables the effect on given cameras
  67113. * @param cameras The camera to enable.
  67114. * @hidden
  67115. */
  67116. _enable(cameras: Nullable<Camera[]>): void;
  67117. /**
  67118. * Disables the effect on the given cameras
  67119. * @param cameras The camera to disable.
  67120. * @hidden
  67121. */
  67122. _disable(cameras: Camera): void;
  67123. /**
  67124. * Disables the effect on the given cameras
  67125. * @param cameras The camera to disable.
  67126. * @hidden
  67127. */
  67128. _disable(cameras: Nullable<Camera[]>): void;
  67129. /**
  67130. * Gets a list of the post processes contained in the effect.
  67131. * @param camera The camera to get the post processes on.
  67132. * @returns The list of the post processes in the effect.
  67133. */
  67134. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67135. }
  67136. }
  67137. declare module BABYLON {
  67138. /** @hidden */
  67139. export var extractHighlightsPixelShader: {
  67140. name: string;
  67141. shader: string;
  67142. };
  67143. }
  67144. declare module BABYLON {
  67145. /**
  67146. * 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.
  67147. */
  67148. export class ExtractHighlightsPostProcess extends PostProcess {
  67149. /**
  67150. * The luminance threshold, pixels below this value will be set to black.
  67151. */
  67152. threshold: number;
  67153. /** @hidden */
  67154. _exposure: number;
  67155. /**
  67156. * Post process which has the input texture to be used when performing highlight extraction
  67157. * @hidden
  67158. */
  67159. _inputPostProcess: Nullable<PostProcess>;
  67160. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67161. }
  67162. }
  67163. declare module BABYLON {
  67164. /** @hidden */
  67165. export var bloomMergePixelShader: {
  67166. name: string;
  67167. shader: string;
  67168. };
  67169. }
  67170. declare module BABYLON {
  67171. /**
  67172. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67173. */
  67174. export class BloomMergePostProcess extends PostProcess {
  67175. /** Weight of the bloom to be added to the original input. */
  67176. weight: number;
  67177. /**
  67178. * Creates a new instance of @see BloomMergePostProcess
  67179. * @param name The name of the effect.
  67180. * @param originalFromInput Post process which's input will be used for the merge.
  67181. * @param blurred Blurred highlights post process which's output will be used.
  67182. * @param weight Weight of the bloom to be added to the original input.
  67183. * @param options The required width/height ratio to downsize to before computing the render pass.
  67184. * @param camera The camera to apply the render pass to.
  67185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67186. * @param engine The engine which the post process will be applied. (default: current engine)
  67187. * @param reusable If the post process can be reused on the same frame. (default: false)
  67188. * @param textureType Type of textures used when performing the post process. (default: 0)
  67189. * @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)
  67190. */
  67191. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67192. /** Weight of the bloom to be added to the original input. */
  67193. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67194. }
  67195. }
  67196. declare module BABYLON {
  67197. /**
  67198. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67199. */
  67200. export class BloomEffect extends PostProcessRenderEffect {
  67201. private bloomScale;
  67202. /**
  67203. * @hidden Internal
  67204. */
  67205. _effects: Array<PostProcess>;
  67206. /**
  67207. * @hidden Internal
  67208. */
  67209. _downscale: ExtractHighlightsPostProcess;
  67210. private _blurX;
  67211. private _blurY;
  67212. private _merge;
  67213. /**
  67214. * The luminance threshold to find bright areas of the image to bloom.
  67215. */
  67216. get threshold(): number;
  67217. set threshold(value: number);
  67218. /**
  67219. * The strength of the bloom.
  67220. */
  67221. get weight(): number;
  67222. set weight(value: number);
  67223. /**
  67224. * Specifies the size of the bloom blur kernel, relative to the final output size
  67225. */
  67226. get kernel(): number;
  67227. set kernel(value: number);
  67228. /**
  67229. * Creates a new instance of @see BloomEffect
  67230. * @param scene The scene the effect belongs to.
  67231. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67232. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67233. * @param bloomWeight The the strength of bloom.
  67234. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67235. * @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)
  67236. */
  67237. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67238. /**
  67239. * Disposes each of the internal effects for a given camera.
  67240. * @param camera The camera to dispose the effect on.
  67241. */
  67242. disposeEffects(camera: Camera): void;
  67243. /**
  67244. * @hidden Internal
  67245. */
  67246. _updateEffects(): void;
  67247. /**
  67248. * Internal
  67249. * @returns if all the contained post processes are ready.
  67250. * @hidden
  67251. */
  67252. _isReady(): boolean;
  67253. }
  67254. }
  67255. declare module BABYLON {
  67256. /** @hidden */
  67257. export var chromaticAberrationPixelShader: {
  67258. name: string;
  67259. shader: string;
  67260. };
  67261. }
  67262. declare module BABYLON {
  67263. /**
  67264. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67265. */
  67266. export class ChromaticAberrationPostProcess extends PostProcess {
  67267. /**
  67268. * The amount of seperation of rgb channels (default: 30)
  67269. */
  67270. aberrationAmount: number;
  67271. /**
  67272. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67273. */
  67274. radialIntensity: number;
  67275. /**
  67276. * 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))
  67277. */
  67278. direction: Vector2;
  67279. /**
  67280. * 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))
  67281. */
  67282. centerPosition: Vector2;
  67283. /**
  67284. * Creates a new instance ChromaticAberrationPostProcess
  67285. * @param name The name of the effect.
  67286. * @param screenWidth The width of the screen to apply the effect on.
  67287. * @param screenHeight The height of the screen to apply the effect on.
  67288. * @param options The required width/height ratio to downsize to before computing the render pass.
  67289. * @param camera The camera to apply the render pass to.
  67290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67291. * @param engine The engine which the post process will be applied. (default: current engine)
  67292. * @param reusable If the post process can be reused on the same frame. (default: false)
  67293. * @param textureType Type of textures used when performing the post process. (default: 0)
  67294. * @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)
  67295. */
  67296. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67297. }
  67298. }
  67299. declare module BABYLON {
  67300. /** @hidden */
  67301. export var circleOfConfusionPixelShader: {
  67302. name: string;
  67303. shader: string;
  67304. };
  67305. }
  67306. declare module BABYLON {
  67307. /**
  67308. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67309. */
  67310. export class CircleOfConfusionPostProcess extends PostProcess {
  67311. /**
  67312. * 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.
  67313. */
  67314. lensSize: number;
  67315. /**
  67316. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67317. */
  67318. fStop: number;
  67319. /**
  67320. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67321. */
  67322. focusDistance: number;
  67323. /**
  67324. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67325. */
  67326. focalLength: number;
  67327. private _depthTexture;
  67328. /**
  67329. * Creates a new instance CircleOfConfusionPostProcess
  67330. * @param name The name of the effect.
  67331. * @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.
  67332. * @param options The required width/height ratio to downsize to before computing the render pass.
  67333. * @param camera The camera to apply the render pass to.
  67334. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67335. * @param engine The engine which the post process will be applied. (default: current engine)
  67336. * @param reusable If the post process can be reused on the same frame. (default: false)
  67337. * @param textureType Type of textures used when performing the post process. (default: 0)
  67338. * @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)
  67339. */
  67340. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67341. /**
  67342. * 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.
  67343. */
  67344. set depthTexture(value: RenderTargetTexture);
  67345. }
  67346. }
  67347. declare module BABYLON {
  67348. /** @hidden */
  67349. export var colorCorrectionPixelShader: {
  67350. name: string;
  67351. shader: string;
  67352. };
  67353. }
  67354. declare module BABYLON {
  67355. /**
  67356. *
  67357. * This post-process allows the modification of rendered colors by using
  67358. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67359. *
  67360. * The object needs to be provided an url to a texture containing the color
  67361. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67362. * Use an image editing software to tweak the LUT to match your needs.
  67363. *
  67364. * For an example of a color LUT, see here:
  67365. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67366. * For explanations on color grading, see here:
  67367. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67368. *
  67369. */
  67370. export class ColorCorrectionPostProcess extends PostProcess {
  67371. private _colorTableTexture;
  67372. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67373. }
  67374. }
  67375. declare module BABYLON {
  67376. /** @hidden */
  67377. export var convolutionPixelShader: {
  67378. name: string;
  67379. shader: string;
  67380. };
  67381. }
  67382. declare module BABYLON {
  67383. /**
  67384. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67385. * input texture to perform effects such as edge detection or sharpening
  67386. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67387. */
  67388. export class ConvolutionPostProcess extends PostProcess {
  67389. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67390. kernel: number[];
  67391. /**
  67392. * Creates a new instance ConvolutionPostProcess
  67393. * @param name The name of the effect.
  67394. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67395. * @param options The required width/height ratio to downsize to before computing the render pass.
  67396. * @param camera The camera to apply the render pass to.
  67397. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67398. * @param engine The engine which the post process will be applied. (default: current engine)
  67399. * @param reusable If the post process can be reused on the same frame. (default: false)
  67400. * @param textureType Type of textures used when performing the post process. (default: 0)
  67401. */
  67402. constructor(name: string,
  67403. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67404. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67405. /**
  67406. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67407. */
  67408. static EdgeDetect0Kernel: number[];
  67409. /**
  67410. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67411. */
  67412. static EdgeDetect1Kernel: number[];
  67413. /**
  67414. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67415. */
  67416. static EdgeDetect2Kernel: number[];
  67417. /**
  67418. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67419. */
  67420. static SharpenKernel: number[];
  67421. /**
  67422. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67423. */
  67424. static EmbossKernel: number[];
  67425. /**
  67426. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67427. */
  67428. static GaussianKernel: number[];
  67429. }
  67430. }
  67431. declare module BABYLON {
  67432. /**
  67433. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67434. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67435. * based on samples that have a large difference in distance than the center pixel.
  67436. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67437. */
  67438. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67439. direction: Vector2;
  67440. /**
  67441. * Creates a new instance CircleOfConfusionPostProcess
  67442. * @param name The name of the effect.
  67443. * @param scene The scene the effect belongs to.
  67444. * @param direction The direction the blur should be applied.
  67445. * @param kernel The size of the kernel used to blur.
  67446. * @param options The required width/height ratio to downsize to before computing the render pass.
  67447. * @param camera The camera to apply the render pass to.
  67448. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67449. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67451. * @param engine The engine which the post process will be applied. (default: current engine)
  67452. * @param reusable If the post process can be reused on the same frame. (default: false)
  67453. * @param textureType Type of textures used when performing the post process. (default: 0)
  67454. * @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)
  67455. */
  67456. 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);
  67457. }
  67458. }
  67459. declare module BABYLON {
  67460. /** @hidden */
  67461. export var depthOfFieldMergePixelShader: {
  67462. name: string;
  67463. shader: string;
  67464. };
  67465. }
  67466. declare module BABYLON {
  67467. /**
  67468. * Options to be set when merging outputs from the default pipeline.
  67469. */
  67470. export class DepthOfFieldMergePostProcessOptions {
  67471. /**
  67472. * The original image to merge on top of
  67473. */
  67474. originalFromInput: PostProcess;
  67475. /**
  67476. * Parameters to perform the merge of the depth of field effect
  67477. */
  67478. depthOfField?: {
  67479. circleOfConfusion: PostProcess;
  67480. blurSteps: Array<PostProcess>;
  67481. };
  67482. /**
  67483. * Parameters to perform the merge of bloom effect
  67484. */
  67485. bloom?: {
  67486. blurred: PostProcess;
  67487. weight: number;
  67488. };
  67489. }
  67490. /**
  67491. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67492. */
  67493. export class DepthOfFieldMergePostProcess extends PostProcess {
  67494. private blurSteps;
  67495. /**
  67496. * Creates a new instance of DepthOfFieldMergePostProcess
  67497. * @param name The name of the effect.
  67498. * @param originalFromInput Post process which's input will be used for the merge.
  67499. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67500. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67501. * @param options The required width/height ratio to downsize to before computing the render pass.
  67502. * @param camera The camera to apply the render pass to.
  67503. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67504. * @param engine The engine which the post process will be applied. (default: current engine)
  67505. * @param reusable If the post process can be reused on the same frame. (default: false)
  67506. * @param textureType Type of textures used when performing the post process. (default: 0)
  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(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);
  67510. /**
  67511. * Updates the effect with the current post process compile time values and recompiles the shader.
  67512. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67513. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67514. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67515. * @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
  67516. * @param onCompiled Called when the shader has been compiled.
  67517. * @param onError Called if there is an error when compiling a shader.
  67518. */
  67519. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67520. }
  67521. }
  67522. declare module BABYLON {
  67523. /**
  67524. * Specifies the level of max blur that should be applied when using the depth of field effect
  67525. */
  67526. export enum DepthOfFieldEffectBlurLevel {
  67527. /**
  67528. * Subtle blur
  67529. */
  67530. Low = 0,
  67531. /**
  67532. * Medium blur
  67533. */
  67534. Medium = 1,
  67535. /**
  67536. * Large blur
  67537. */
  67538. High = 2
  67539. }
  67540. /**
  67541. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67542. */
  67543. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67544. private _circleOfConfusion;
  67545. /**
  67546. * @hidden Internal, blurs from high to low
  67547. */
  67548. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67549. private _depthOfFieldBlurY;
  67550. private _dofMerge;
  67551. /**
  67552. * @hidden Internal post processes in depth of field effect
  67553. */
  67554. _effects: Array<PostProcess>;
  67555. /**
  67556. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67557. */
  67558. set focalLength(value: number);
  67559. get focalLength(): number;
  67560. /**
  67561. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67562. */
  67563. set fStop(value: number);
  67564. get fStop(): number;
  67565. /**
  67566. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67567. */
  67568. set focusDistance(value: number);
  67569. get focusDistance(): number;
  67570. /**
  67571. * 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.
  67572. */
  67573. set lensSize(value: number);
  67574. get lensSize(): number;
  67575. /**
  67576. * Creates a new instance DepthOfFieldEffect
  67577. * @param scene The scene the effect belongs to.
  67578. * @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.
  67579. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67580. * @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)
  67581. */
  67582. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67583. /**
  67584. * Get the current class name of the current effet
  67585. * @returns "DepthOfFieldEffect"
  67586. */
  67587. getClassName(): string;
  67588. /**
  67589. * 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.
  67590. */
  67591. set depthTexture(value: RenderTargetTexture);
  67592. /**
  67593. * Disposes each of the internal effects for a given camera.
  67594. * @param camera The camera to dispose the effect on.
  67595. */
  67596. disposeEffects(camera: Camera): void;
  67597. /**
  67598. * @hidden Internal
  67599. */
  67600. _updateEffects(): void;
  67601. /**
  67602. * Internal
  67603. * @returns if all the contained post processes are ready.
  67604. * @hidden
  67605. */
  67606. _isReady(): boolean;
  67607. }
  67608. }
  67609. declare module BABYLON {
  67610. /** @hidden */
  67611. export var displayPassPixelShader: {
  67612. name: string;
  67613. shader: string;
  67614. };
  67615. }
  67616. declare module BABYLON {
  67617. /**
  67618. * DisplayPassPostProcess which produces an output the same as it's input
  67619. */
  67620. export class DisplayPassPostProcess extends PostProcess {
  67621. /**
  67622. * Creates the DisplayPassPostProcess
  67623. * @param name The name of the effect.
  67624. * @param options The required width/height ratio to downsize to before computing the render pass.
  67625. * @param camera The camera to apply the render pass to.
  67626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67627. * @param engine The engine which the post process will be applied. (default: current engine)
  67628. * @param reusable If the post process can be reused on the same frame. (default: false)
  67629. */
  67630. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67631. }
  67632. }
  67633. declare module BABYLON {
  67634. /** @hidden */
  67635. export var filterPixelShader: {
  67636. name: string;
  67637. shader: string;
  67638. };
  67639. }
  67640. declare module BABYLON {
  67641. /**
  67642. * Applies a kernel filter to the image
  67643. */
  67644. export class FilterPostProcess extends PostProcess {
  67645. /** The matrix to be applied to the image */
  67646. kernelMatrix: Matrix;
  67647. /**
  67648. *
  67649. * @param name The name of the effect.
  67650. * @param kernelMatrix The matrix to be applied to the image
  67651. * @param options The required width/height ratio to downsize to before computing the render pass.
  67652. * @param camera The camera to apply the render pass to.
  67653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67654. * @param engine The engine which the post process will be applied. (default: current engine)
  67655. * @param reusable If the post process can be reused on the same frame. (default: false)
  67656. */
  67657. constructor(name: string,
  67658. /** The matrix to be applied to the image */
  67659. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67660. }
  67661. }
  67662. declare module BABYLON {
  67663. /** @hidden */
  67664. export var fxaaPixelShader: {
  67665. name: string;
  67666. shader: string;
  67667. };
  67668. }
  67669. declare module BABYLON {
  67670. /** @hidden */
  67671. export var fxaaVertexShader: {
  67672. name: string;
  67673. shader: string;
  67674. };
  67675. }
  67676. declare module BABYLON {
  67677. /**
  67678. * Fxaa post process
  67679. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67680. */
  67681. export class FxaaPostProcess extends PostProcess {
  67682. /** @hidden */
  67683. texelWidth: number;
  67684. /** @hidden */
  67685. texelHeight: number;
  67686. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67687. private _getDefines;
  67688. }
  67689. }
  67690. declare module BABYLON {
  67691. /** @hidden */
  67692. export var grainPixelShader: {
  67693. name: string;
  67694. shader: string;
  67695. };
  67696. }
  67697. declare module BABYLON {
  67698. /**
  67699. * The GrainPostProcess adds noise to the image at mid luminance levels
  67700. */
  67701. export class GrainPostProcess extends PostProcess {
  67702. /**
  67703. * The intensity of the grain added (default: 30)
  67704. */
  67705. intensity: number;
  67706. /**
  67707. * If the grain should be randomized on every frame
  67708. */
  67709. animated: boolean;
  67710. /**
  67711. * Creates a new instance of @see GrainPostProcess
  67712. * @param name The name of the effect.
  67713. * @param options The required width/height ratio to downsize to before computing the render pass.
  67714. * @param camera The camera to apply the render pass to.
  67715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67716. * @param engine The engine which the post process will be applied. (default: current engine)
  67717. * @param reusable If the post process can be reused on the same frame. (default: false)
  67718. * @param textureType Type of textures used when performing the post process. (default: 0)
  67719. * @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)
  67720. */
  67721. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67722. }
  67723. }
  67724. declare module BABYLON {
  67725. /** @hidden */
  67726. export var highlightsPixelShader: {
  67727. name: string;
  67728. shader: string;
  67729. };
  67730. }
  67731. declare module BABYLON {
  67732. /**
  67733. * Extracts highlights from the image
  67734. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67735. */
  67736. export class HighlightsPostProcess extends PostProcess {
  67737. /**
  67738. * Extracts highlights from the image
  67739. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67740. * @param name The name of the effect.
  67741. * @param options The required width/height ratio to downsize to before computing the render pass.
  67742. * @param camera The camera to apply the render pass to.
  67743. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67744. * @param engine The engine which the post process will be applied. (default: current engine)
  67745. * @param reusable If the post process can be reused on the same frame. (default: false)
  67746. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67747. */
  67748. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67749. }
  67750. }
  67751. declare module BABYLON {
  67752. /** @hidden */
  67753. export var mrtFragmentDeclaration: {
  67754. name: string;
  67755. shader: string;
  67756. };
  67757. }
  67758. declare module BABYLON {
  67759. /** @hidden */
  67760. export var geometryPixelShader: {
  67761. name: string;
  67762. shader: string;
  67763. };
  67764. }
  67765. declare module BABYLON {
  67766. /** @hidden */
  67767. export var geometryVertexShader: {
  67768. name: string;
  67769. shader: string;
  67770. };
  67771. }
  67772. declare module BABYLON {
  67773. /** @hidden */
  67774. interface ISavedTransformationMatrix {
  67775. world: Matrix;
  67776. viewProjection: Matrix;
  67777. }
  67778. /**
  67779. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67780. */
  67781. export class GeometryBufferRenderer {
  67782. /**
  67783. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67784. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67785. */
  67786. static readonly POSITION_TEXTURE_TYPE: number;
  67787. /**
  67788. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67789. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67790. */
  67791. static readonly VELOCITY_TEXTURE_TYPE: number;
  67792. /**
  67793. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67794. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67795. */
  67796. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67797. /**
  67798. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67799. * in order to compute objects velocities when enableVelocity is set to "true"
  67800. * @hidden
  67801. */
  67802. _previousTransformationMatrices: {
  67803. [index: number]: ISavedTransformationMatrix;
  67804. };
  67805. /**
  67806. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67807. * in order to compute objects velocities when enableVelocity is set to "true"
  67808. * @hidden
  67809. */
  67810. _previousBonesTransformationMatrices: {
  67811. [index: number]: Float32Array;
  67812. };
  67813. /**
  67814. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67815. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67816. */
  67817. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67818. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67819. renderTransparentMeshes: boolean;
  67820. private _scene;
  67821. private _multiRenderTarget;
  67822. private _ratio;
  67823. private _enablePosition;
  67824. private _enableVelocity;
  67825. private _enableReflectivity;
  67826. private _positionIndex;
  67827. private _velocityIndex;
  67828. private _reflectivityIndex;
  67829. protected _effect: Effect;
  67830. protected _cachedDefines: string;
  67831. /**
  67832. * Set the render list (meshes to be rendered) used in the G buffer.
  67833. */
  67834. set renderList(meshes: Mesh[]);
  67835. /**
  67836. * Gets wether or not G buffer are supported by the running hardware.
  67837. * This requires draw buffer supports
  67838. */
  67839. get isSupported(): boolean;
  67840. /**
  67841. * Returns the index of the given texture type in the G-Buffer textures array
  67842. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  67843. * @returns the index of the given texture type in the G-Buffer textures array
  67844. */
  67845. getTextureIndex(textureType: number): number;
  67846. /**
  67847. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  67848. */
  67849. get enablePosition(): boolean;
  67850. /**
  67851. * Sets whether or not objects positions are enabled for the G buffer.
  67852. */
  67853. set enablePosition(enable: boolean);
  67854. /**
  67855. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  67856. */
  67857. get enableVelocity(): boolean;
  67858. /**
  67859. * Sets wether or not objects velocities are enabled for the G buffer.
  67860. */
  67861. set enableVelocity(enable: boolean);
  67862. /**
  67863. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  67864. */
  67865. get enableReflectivity(): boolean;
  67866. /**
  67867. * Sets wether or not objects roughness are enabled for the G buffer.
  67868. */
  67869. set enableReflectivity(enable: boolean);
  67870. /**
  67871. * Gets the scene associated with the buffer.
  67872. */
  67873. get scene(): Scene;
  67874. /**
  67875. * Gets the ratio used by the buffer during its creation.
  67876. * How big is the buffer related to the main canvas.
  67877. */
  67878. get ratio(): number;
  67879. /** @hidden */
  67880. static _SceneComponentInitialization: (scene: Scene) => void;
  67881. /**
  67882. * Creates a new G Buffer for the scene
  67883. * @param scene The scene the buffer belongs to
  67884. * @param ratio How big is the buffer related to the main canvas.
  67885. */
  67886. constructor(scene: Scene, ratio?: number);
  67887. /**
  67888. * Checks wether everything is ready to render a submesh to the G buffer.
  67889. * @param subMesh the submesh to check readiness for
  67890. * @param useInstances is the mesh drawn using instance or not
  67891. * @returns true if ready otherwise false
  67892. */
  67893. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67894. /**
  67895. * Gets the current underlying G Buffer.
  67896. * @returns the buffer
  67897. */
  67898. getGBuffer(): MultiRenderTarget;
  67899. /**
  67900. * Gets the number of samples used to render the buffer (anti aliasing).
  67901. */
  67902. get samples(): number;
  67903. /**
  67904. * Sets the number of samples used to render the buffer (anti aliasing).
  67905. */
  67906. set samples(value: number);
  67907. /**
  67908. * Disposes the renderer and frees up associated resources.
  67909. */
  67910. dispose(): void;
  67911. protected _createRenderTargets(): void;
  67912. private _copyBonesTransformationMatrices;
  67913. }
  67914. }
  67915. declare module BABYLON {
  67916. interface Scene {
  67917. /** @hidden (Backing field) */
  67918. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67919. /**
  67920. * Gets or Sets the current geometry buffer associated to the scene.
  67921. */
  67922. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67923. /**
  67924. * Enables a GeometryBufferRender and associates it with the scene
  67925. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  67926. * @returns the GeometryBufferRenderer
  67927. */
  67928. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  67929. /**
  67930. * Disables the GeometryBufferRender associated with the scene
  67931. */
  67932. disableGeometryBufferRenderer(): void;
  67933. }
  67934. /**
  67935. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  67936. * in several rendering techniques.
  67937. */
  67938. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  67939. /**
  67940. * The component name helpful to identify the component in the list of scene components.
  67941. */
  67942. readonly name: string;
  67943. /**
  67944. * The scene the component belongs to.
  67945. */
  67946. scene: Scene;
  67947. /**
  67948. * Creates a new instance of the component for the given scene
  67949. * @param scene Defines the scene to register the component in
  67950. */
  67951. constructor(scene: Scene);
  67952. /**
  67953. * Registers the component in a given scene
  67954. */
  67955. register(): void;
  67956. /**
  67957. * Rebuilds the elements related to this component in case of
  67958. * context lost for instance.
  67959. */
  67960. rebuild(): void;
  67961. /**
  67962. * Disposes the component and the associated ressources
  67963. */
  67964. dispose(): void;
  67965. private _gatherRenderTargets;
  67966. }
  67967. }
  67968. declare module BABYLON {
  67969. /** @hidden */
  67970. export var motionBlurPixelShader: {
  67971. name: string;
  67972. shader: string;
  67973. };
  67974. }
  67975. declare module BABYLON {
  67976. /**
  67977. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  67978. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  67979. * As an example, all you have to do is to create the post-process:
  67980. * var mb = new BABYLON.MotionBlurPostProcess(
  67981. * 'mb', // The name of the effect.
  67982. * scene, // The scene containing the objects to blur according to their velocity.
  67983. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  67984. * camera // The camera to apply the render pass to.
  67985. * );
  67986. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  67987. */
  67988. export class MotionBlurPostProcess extends PostProcess {
  67989. /**
  67990. * Defines how much the image is blurred by the movement. Default value is equal to 1
  67991. */
  67992. motionStrength: number;
  67993. /**
  67994. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  67995. */
  67996. get motionBlurSamples(): number;
  67997. /**
  67998. * Sets the number of iterations to be used for motion blur quality
  67999. */
  68000. set motionBlurSamples(samples: number);
  68001. private _motionBlurSamples;
  68002. private _geometryBufferRenderer;
  68003. /**
  68004. * Creates a new instance MotionBlurPostProcess
  68005. * @param name The name of the effect.
  68006. * @param scene The scene containing the objects to blur according to their velocity.
  68007. * @param options The required width/height ratio to downsize to before computing the render pass.
  68008. * @param camera The camera to apply the render pass to.
  68009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68010. * @param engine The engine which the post process will be applied. (default: current engine)
  68011. * @param reusable If the post process can be reused on the same frame. (default: false)
  68012. * @param textureType Type of textures used when performing the post process. (default: 0)
  68013. * @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)
  68014. */
  68015. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68016. /**
  68017. * Excludes the given skinned mesh from computing bones velocities.
  68018. * 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.
  68019. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68020. */
  68021. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68022. /**
  68023. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68024. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68025. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68026. */
  68027. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68028. /**
  68029. * Disposes the post process.
  68030. * @param camera The camera to dispose the post process on.
  68031. */
  68032. dispose(camera?: Camera): void;
  68033. }
  68034. }
  68035. declare module BABYLON {
  68036. /** @hidden */
  68037. export var refractionPixelShader: {
  68038. name: string;
  68039. shader: string;
  68040. };
  68041. }
  68042. declare module BABYLON {
  68043. /**
  68044. * Post process which applies a refractin texture
  68045. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68046. */
  68047. export class RefractionPostProcess extends PostProcess {
  68048. /** the base color of the refraction (used to taint the rendering) */
  68049. color: Color3;
  68050. /** simulated refraction depth */
  68051. depth: number;
  68052. /** the coefficient of the base color (0 to remove base color tainting) */
  68053. colorLevel: number;
  68054. private _refTexture;
  68055. private _ownRefractionTexture;
  68056. /**
  68057. * Gets or sets the refraction texture
  68058. * Please note that you are responsible for disposing the texture if you set it manually
  68059. */
  68060. get refractionTexture(): Texture;
  68061. set refractionTexture(value: Texture);
  68062. /**
  68063. * Initializes the RefractionPostProcess
  68064. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68065. * @param name The name of the effect.
  68066. * @param refractionTextureUrl Url of the refraction texture to use
  68067. * @param color the base color of the refraction (used to taint the rendering)
  68068. * @param depth simulated refraction depth
  68069. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68070. * @param camera The camera to apply the render pass to.
  68071. * @param options The required width/height ratio to downsize to before computing the render pass.
  68072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68073. * @param engine The engine which the post process will be applied. (default: current engine)
  68074. * @param reusable If the post process can be reused on the same frame. (default: false)
  68075. */
  68076. constructor(name: string, refractionTextureUrl: string,
  68077. /** the base color of the refraction (used to taint the rendering) */
  68078. color: Color3,
  68079. /** simulated refraction depth */
  68080. depth: number,
  68081. /** the coefficient of the base color (0 to remove base color tainting) */
  68082. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68083. /**
  68084. * Disposes of the post process
  68085. * @param camera Camera to dispose post process on
  68086. */
  68087. dispose(camera: Camera): void;
  68088. }
  68089. }
  68090. declare module BABYLON {
  68091. /** @hidden */
  68092. export var sharpenPixelShader: {
  68093. name: string;
  68094. shader: string;
  68095. };
  68096. }
  68097. declare module BABYLON {
  68098. /**
  68099. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68100. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68101. */
  68102. export class SharpenPostProcess extends PostProcess {
  68103. /**
  68104. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68105. */
  68106. colorAmount: number;
  68107. /**
  68108. * How much sharpness should be applied (default: 0.3)
  68109. */
  68110. edgeAmount: number;
  68111. /**
  68112. * Creates a new instance ConvolutionPostProcess
  68113. * @param name The name of the effect.
  68114. * @param options The required width/height ratio to downsize to before computing the render pass.
  68115. * @param camera The camera to apply the render pass to.
  68116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68117. * @param engine The engine which the post process will be applied. (default: current engine)
  68118. * @param reusable If the post process can be reused on the same frame. (default: false)
  68119. * @param textureType Type of textures used when performing the post process. (default: 0)
  68120. * @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)
  68121. */
  68122. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68123. }
  68124. }
  68125. declare module BABYLON {
  68126. /**
  68127. * PostProcessRenderPipeline
  68128. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68129. */
  68130. export class PostProcessRenderPipeline {
  68131. private engine;
  68132. private _renderEffects;
  68133. private _renderEffectsForIsolatedPass;
  68134. /**
  68135. * List of inspectable custom properties (used by the Inspector)
  68136. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68137. */
  68138. inspectableCustomProperties: IInspectable[];
  68139. /**
  68140. * @hidden
  68141. */
  68142. protected _cameras: Camera[];
  68143. /** @hidden */
  68144. _name: string;
  68145. /**
  68146. * Gets pipeline name
  68147. */
  68148. get name(): string;
  68149. /** Gets the list of attached cameras */
  68150. get cameras(): Camera[];
  68151. /**
  68152. * Initializes a PostProcessRenderPipeline
  68153. * @param engine engine to add the pipeline to
  68154. * @param name name of the pipeline
  68155. */
  68156. constructor(engine: Engine, name: string);
  68157. /**
  68158. * Gets the class name
  68159. * @returns "PostProcessRenderPipeline"
  68160. */
  68161. getClassName(): string;
  68162. /**
  68163. * If all the render effects in the pipeline are supported
  68164. */
  68165. get isSupported(): boolean;
  68166. /**
  68167. * Adds an effect to the pipeline
  68168. * @param renderEffect the effect to add
  68169. */
  68170. addEffect(renderEffect: PostProcessRenderEffect): void;
  68171. /** @hidden */
  68172. _rebuild(): void;
  68173. /** @hidden */
  68174. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68175. /** @hidden */
  68176. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68177. /** @hidden */
  68178. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68179. /** @hidden */
  68180. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68181. /** @hidden */
  68182. _attachCameras(cameras: Camera, unique: boolean): void;
  68183. /** @hidden */
  68184. _attachCameras(cameras: Camera[], unique: boolean): void;
  68185. /** @hidden */
  68186. _detachCameras(cameras: Camera): void;
  68187. /** @hidden */
  68188. _detachCameras(cameras: Nullable<Camera[]>): void;
  68189. /** @hidden */
  68190. _update(): void;
  68191. /** @hidden */
  68192. _reset(): void;
  68193. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68194. /**
  68195. * Disposes of the pipeline
  68196. */
  68197. dispose(): void;
  68198. }
  68199. }
  68200. declare module BABYLON {
  68201. /**
  68202. * PostProcessRenderPipelineManager class
  68203. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68204. */
  68205. export class PostProcessRenderPipelineManager {
  68206. private _renderPipelines;
  68207. /**
  68208. * Initializes a PostProcessRenderPipelineManager
  68209. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68210. */
  68211. constructor();
  68212. /**
  68213. * Gets the list of supported render pipelines
  68214. */
  68215. get supportedPipelines(): PostProcessRenderPipeline[];
  68216. /**
  68217. * Adds a pipeline to the manager
  68218. * @param renderPipeline The pipeline to add
  68219. */
  68220. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68221. /**
  68222. * Attaches a camera to the pipeline
  68223. * @param renderPipelineName The name of the pipeline to attach to
  68224. * @param cameras the camera to attach
  68225. * @param unique if the camera can be attached multiple times to the pipeline
  68226. */
  68227. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68228. /**
  68229. * Detaches a camera from the pipeline
  68230. * @param renderPipelineName The name of the pipeline to detach from
  68231. * @param cameras the camera to detach
  68232. */
  68233. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68234. /**
  68235. * Enables an effect by name on a pipeline
  68236. * @param renderPipelineName the name of the pipeline to enable the effect in
  68237. * @param renderEffectName the name of the effect to enable
  68238. * @param cameras the cameras that the effect should be enabled on
  68239. */
  68240. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68241. /**
  68242. * Disables an effect by name on a pipeline
  68243. * @param renderPipelineName the name of the pipeline to disable the effect in
  68244. * @param renderEffectName the name of the effect to disable
  68245. * @param cameras the cameras that the effect should be disabled on
  68246. */
  68247. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68248. /**
  68249. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68250. */
  68251. update(): void;
  68252. /** @hidden */
  68253. _rebuild(): void;
  68254. /**
  68255. * Disposes of the manager and pipelines
  68256. */
  68257. dispose(): void;
  68258. }
  68259. }
  68260. declare module BABYLON {
  68261. interface Scene {
  68262. /** @hidden (Backing field) */
  68263. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68264. /**
  68265. * Gets the postprocess render pipeline manager
  68266. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68267. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68268. */
  68269. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68270. }
  68271. /**
  68272. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68273. */
  68274. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68275. /**
  68276. * The component name helpfull to identify the component in the list of scene components.
  68277. */
  68278. readonly name: string;
  68279. /**
  68280. * The scene the component belongs to.
  68281. */
  68282. scene: Scene;
  68283. /**
  68284. * Creates a new instance of the component for the given scene
  68285. * @param scene Defines the scene to register the component in
  68286. */
  68287. constructor(scene: Scene);
  68288. /**
  68289. * Registers the component in a given scene
  68290. */
  68291. register(): void;
  68292. /**
  68293. * Rebuilds the elements related to this component in case of
  68294. * context lost for instance.
  68295. */
  68296. rebuild(): void;
  68297. /**
  68298. * Disposes the component and the associated ressources
  68299. */
  68300. dispose(): void;
  68301. private _gatherRenderTargets;
  68302. }
  68303. }
  68304. declare module BABYLON {
  68305. /**
  68306. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68307. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68308. */
  68309. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68310. private _scene;
  68311. private _camerasToBeAttached;
  68312. /**
  68313. * ID of the sharpen post process,
  68314. */
  68315. private readonly SharpenPostProcessId;
  68316. /**
  68317. * @ignore
  68318. * ID of the image processing post process;
  68319. */
  68320. readonly ImageProcessingPostProcessId: string;
  68321. /**
  68322. * @ignore
  68323. * ID of the Fast Approximate Anti-Aliasing post process;
  68324. */
  68325. readonly FxaaPostProcessId: string;
  68326. /**
  68327. * ID of the chromatic aberration post process,
  68328. */
  68329. private readonly ChromaticAberrationPostProcessId;
  68330. /**
  68331. * ID of the grain post process
  68332. */
  68333. private readonly GrainPostProcessId;
  68334. /**
  68335. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68336. */
  68337. sharpen: SharpenPostProcess;
  68338. private _sharpenEffect;
  68339. private bloom;
  68340. /**
  68341. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68342. */
  68343. depthOfField: DepthOfFieldEffect;
  68344. /**
  68345. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68346. */
  68347. fxaa: FxaaPostProcess;
  68348. /**
  68349. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68350. */
  68351. imageProcessing: ImageProcessingPostProcess;
  68352. /**
  68353. * Chromatic aberration post process which will shift rgb colors in the image
  68354. */
  68355. chromaticAberration: ChromaticAberrationPostProcess;
  68356. private _chromaticAberrationEffect;
  68357. /**
  68358. * Grain post process which add noise to the image
  68359. */
  68360. grain: GrainPostProcess;
  68361. private _grainEffect;
  68362. /**
  68363. * Glow post process which adds a glow to emissive areas of the image
  68364. */
  68365. private _glowLayer;
  68366. /**
  68367. * Animations which can be used to tweak settings over a period of time
  68368. */
  68369. animations: Animation[];
  68370. private _imageProcessingConfigurationObserver;
  68371. private _sharpenEnabled;
  68372. private _bloomEnabled;
  68373. private _depthOfFieldEnabled;
  68374. private _depthOfFieldBlurLevel;
  68375. private _fxaaEnabled;
  68376. private _imageProcessingEnabled;
  68377. private _defaultPipelineTextureType;
  68378. private _bloomScale;
  68379. private _chromaticAberrationEnabled;
  68380. private _grainEnabled;
  68381. private _buildAllowed;
  68382. /**
  68383. * Gets active scene
  68384. */
  68385. get scene(): Scene;
  68386. /**
  68387. * Enable or disable the sharpen process from the pipeline
  68388. */
  68389. set sharpenEnabled(enabled: boolean);
  68390. get sharpenEnabled(): boolean;
  68391. private _resizeObserver;
  68392. private _hardwareScaleLevel;
  68393. private _bloomKernel;
  68394. /**
  68395. * Specifies the size of the bloom blur kernel, relative to the final output size
  68396. */
  68397. get bloomKernel(): number;
  68398. set bloomKernel(value: number);
  68399. /**
  68400. * Specifies the weight of the bloom in the final rendering
  68401. */
  68402. private _bloomWeight;
  68403. /**
  68404. * Specifies the luma threshold for the area that will be blurred by the bloom
  68405. */
  68406. private _bloomThreshold;
  68407. private _hdr;
  68408. /**
  68409. * The strength of the bloom.
  68410. */
  68411. set bloomWeight(value: number);
  68412. get bloomWeight(): number;
  68413. /**
  68414. * The strength of the bloom.
  68415. */
  68416. set bloomThreshold(value: number);
  68417. get bloomThreshold(): number;
  68418. /**
  68419. * The scale of the bloom, lower value will provide better performance.
  68420. */
  68421. set bloomScale(value: number);
  68422. get bloomScale(): number;
  68423. /**
  68424. * Enable or disable the bloom from the pipeline
  68425. */
  68426. set bloomEnabled(enabled: boolean);
  68427. get bloomEnabled(): boolean;
  68428. private _rebuildBloom;
  68429. /**
  68430. * If the depth of field is enabled.
  68431. */
  68432. get depthOfFieldEnabled(): boolean;
  68433. set depthOfFieldEnabled(enabled: boolean);
  68434. /**
  68435. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68436. */
  68437. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68438. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68439. /**
  68440. * If the anti aliasing is enabled.
  68441. */
  68442. set fxaaEnabled(enabled: boolean);
  68443. get fxaaEnabled(): boolean;
  68444. private _samples;
  68445. /**
  68446. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68447. */
  68448. set samples(sampleCount: number);
  68449. get samples(): number;
  68450. /**
  68451. * If image processing is enabled.
  68452. */
  68453. set imageProcessingEnabled(enabled: boolean);
  68454. get imageProcessingEnabled(): boolean;
  68455. /**
  68456. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68457. */
  68458. set glowLayerEnabled(enabled: boolean);
  68459. get glowLayerEnabled(): boolean;
  68460. /**
  68461. * Gets the glow layer (or null if not defined)
  68462. */
  68463. get glowLayer(): Nullable<GlowLayer>;
  68464. /**
  68465. * Enable or disable the chromaticAberration process from the pipeline
  68466. */
  68467. set chromaticAberrationEnabled(enabled: boolean);
  68468. get chromaticAberrationEnabled(): boolean;
  68469. /**
  68470. * Enable or disable the grain process from the pipeline
  68471. */
  68472. set grainEnabled(enabled: boolean);
  68473. get grainEnabled(): boolean;
  68474. /**
  68475. * @constructor
  68476. * @param name - The rendering pipeline name (default: "")
  68477. * @param hdr - If high dynamic range textures should be used (default: true)
  68478. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68479. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68480. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68481. */
  68482. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68483. /**
  68484. * Get the class name
  68485. * @returns "DefaultRenderingPipeline"
  68486. */
  68487. getClassName(): string;
  68488. /**
  68489. * Force the compilation of the entire pipeline.
  68490. */
  68491. prepare(): void;
  68492. private _hasCleared;
  68493. private _prevPostProcess;
  68494. private _prevPrevPostProcess;
  68495. private _setAutoClearAndTextureSharing;
  68496. private _depthOfFieldSceneObserver;
  68497. private _buildPipeline;
  68498. private _disposePostProcesses;
  68499. /**
  68500. * Adds a camera to the pipeline
  68501. * @param camera the camera to be added
  68502. */
  68503. addCamera(camera: Camera): void;
  68504. /**
  68505. * Removes a camera from the pipeline
  68506. * @param camera the camera to remove
  68507. */
  68508. removeCamera(camera: Camera): void;
  68509. /**
  68510. * Dispose of the pipeline and stop all post processes
  68511. */
  68512. dispose(): void;
  68513. /**
  68514. * Serialize the rendering pipeline (Used when exporting)
  68515. * @returns the serialized object
  68516. */
  68517. serialize(): any;
  68518. /**
  68519. * Parse the serialized pipeline
  68520. * @param source Source pipeline.
  68521. * @param scene The scene to load the pipeline to.
  68522. * @param rootUrl The URL of the serialized pipeline.
  68523. * @returns An instantiated pipeline from the serialized object.
  68524. */
  68525. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68526. }
  68527. }
  68528. declare module BABYLON {
  68529. /** @hidden */
  68530. export var lensHighlightsPixelShader: {
  68531. name: string;
  68532. shader: string;
  68533. };
  68534. }
  68535. declare module BABYLON {
  68536. /** @hidden */
  68537. export var depthOfFieldPixelShader: {
  68538. name: string;
  68539. shader: string;
  68540. };
  68541. }
  68542. declare module BABYLON {
  68543. /**
  68544. * BABYLON.JS Chromatic Aberration GLSL Shader
  68545. * Author: Olivier Guyot
  68546. * Separates very slightly R, G and B colors on the edges of the screen
  68547. * Inspired by Francois Tarlier & Martins Upitis
  68548. */
  68549. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68550. /**
  68551. * @ignore
  68552. * The chromatic aberration PostProcess id in the pipeline
  68553. */
  68554. LensChromaticAberrationEffect: string;
  68555. /**
  68556. * @ignore
  68557. * The highlights enhancing PostProcess id in the pipeline
  68558. */
  68559. HighlightsEnhancingEffect: string;
  68560. /**
  68561. * @ignore
  68562. * The depth-of-field PostProcess id in the pipeline
  68563. */
  68564. LensDepthOfFieldEffect: string;
  68565. private _scene;
  68566. private _depthTexture;
  68567. private _grainTexture;
  68568. private _chromaticAberrationPostProcess;
  68569. private _highlightsPostProcess;
  68570. private _depthOfFieldPostProcess;
  68571. private _edgeBlur;
  68572. private _grainAmount;
  68573. private _chromaticAberration;
  68574. private _distortion;
  68575. private _highlightsGain;
  68576. private _highlightsThreshold;
  68577. private _dofDistance;
  68578. private _dofAperture;
  68579. private _dofDarken;
  68580. private _dofPentagon;
  68581. private _blurNoise;
  68582. /**
  68583. * @constructor
  68584. *
  68585. * Effect parameters are as follow:
  68586. * {
  68587. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68588. * edge_blur: number; // from 0 to x (1 for realism)
  68589. * distortion: number; // from 0 to x (1 for realism)
  68590. * grain_amount: number; // from 0 to 1
  68591. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68592. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68593. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68594. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68595. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68596. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68597. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68598. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68599. * }
  68600. * Note: if an effect parameter is unset, effect is disabled
  68601. *
  68602. * @param name The rendering pipeline name
  68603. * @param parameters - An object containing all parameters (see above)
  68604. * @param scene The scene linked to this pipeline
  68605. * @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)
  68606. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68607. */
  68608. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68609. /**
  68610. * Get the class name
  68611. * @returns "LensRenderingPipeline"
  68612. */
  68613. getClassName(): string;
  68614. /**
  68615. * Gets associated scene
  68616. */
  68617. get scene(): Scene;
  68618. /**
  68619. * Gets or sets the edge blur
  68620. */
  68621. get edgeBlur(): number;
  68622. set edgeBlur(value: number);
  68623. /**
  68624. * Gets or sets the grain amount
  68625. */
  68626. get grainAmount(): number;
  68627. set grainAmount(value: number);
  68628. /**
  68629. * Gets or sets the chromatic aberration amount
  68630. */
  68631. get chromaticAberration(): number;
  68632. set chromaticAberration(value: number);
  68633. /**
  68634. * Gets or sets the depth of field aperture
  68635. */
  68636. get dofAperture(): number;
  68637. set dofAperture(value: number);
  68638. /**
  68639. * Gets or sets the edge distortion
  68640. */
  68641. get edgeDistortion(): number;
  68642. set edgeDistortion(value: number);
  68643. /**
  68644. * Gets or sets the depth of field distortion
  68645. */
  68646. get dofDistortion(): number;
  68647. set dofDistortion(value: number);
  68648. /**
  68649. * Gets or sets the darken out of focus amount
  68650. */
  68651. get darkenOutOfFocus(): number;
  68652. set darkenOutOfFocus(value: number);
  68653. /**
  68654. * Gets or sets a boolean indicating if blur noise is enabled
  68655. */
  68656. get blurNoise(): boolean;
  68657. set blurNoise(value: boolean);
  68658. /**
  68659. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68660. */
  68661. get pentagonBokeh(): boolean;
  68662. set pentagonBokeh(value: boolean);
  68663. /**
  68664. * Gets or sets the highlight grain amount
  68665. */
  68666. get highlightsGain(): number;
  68667. set highlightsGain(value: number);
  68668. /**
  68669. * Gets or sets the highlight threshold
  68670. */
  68671. get highlightsThreshold(): number;
  68672. set highlightsThreshold(value: number);
  68673. /**
  68674. * Sets the amount of blur at the edges
  68675. * @param amount blur amount
  68676. */
  68677. setEdgeBlur(amount: number): void;
  68678. /**
  68679. * Sets edge blur to 0
  68680. */
  68681. disableEdgeBlur(): void;
  68682. /**
  68683. * Sets the amout of grain
  68684. * @param amount Amount of grain
  68685. */
  68686. setGrainAmount(amount: number): void;
  68687. /**
  68688. * Set grain amount to 0
  68689. */
  68690. disableGrain(): void;
  68691. /**
  68692. * Sets the chromatic aberration amount
  68693. * @param amount amount of chromatic aberration
  68694. */
  68695. setChromaticAberration(amount: number): void;
  68696. /**
  68697. * Sets chromatic aberration amount to 0
  68698. */
  68699. disableChromaticAberration(): void;
  68700. /**
  68701. * Sets the EdgeDistortion amount
  68702. * @param amount amount of EdgeDistortion
  68703. */
  68704. setEdgeDistortion(amount: number): void;
  68705. /**
  68706. * Sets edge distortion to 0
  68707. */
  68708. disableEdgeDistortion(): void;
  68709. /**
  68710. * Sets the FocusDistance amount
  68711. * @param amount amount of FocusDistance
  68712. */
  68713. setFocusDistance(amount: number): void;
  68714. /**
  68715. * Disables depth of field
  68716. */
  68717. disableDepthOfField(): void;
  68718. /**
  68719. * Sets the Aperture amount
  68720. * @param amount amount of Aperture
  68721. */
  68722. setAperture(amount: number): void;
  68723. /**
  68724. * Sets the DarkenOutOfFocus amount
  68725. * @param amount amount of DarkenOutOfFocus
  68726. */
  68727. setDarkenOutOfFocus(amount: number): void;
  68728. private _pentagonBokehIsEnabled;
  68729. /**
  68730. * Creates a pentagon bokeh effect
  68731. */
  68732. enablePentagonBokeh(): void;
  68733. /**
  68734. * Disables the pentagon bokeh effect
  68735. */
  68736. disablePentagonBokeh(): void;
  68737. /**
  68738. * Enables noise blur
  68739. */
  68740. enableNoiseBlur(): void;
  68741. /**
  68742. * Disables noise blur
  68743. */
  68744. disableNoiseBlur(): void;
  68745. /**
  68746. * Sets the HighlightsGain amount
  68747. * @param amount amount of HighlightsGain
  68748. */
  68749. setHighlightsGain(amount: number): void;
  68750. /**
  68751. * Sets the HighlightsThreshold amount
  68752. * @param amount amount of HighlightsThreshold
  68753. */
  68754. setHighlightsThreshold(amount: number): void;
  68755. /**
  68756. * Disables highlights
  68757. */
  68758. disableHighlights(): void;
  68759. /**
  68760. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68761. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68762. */
  68763. dispose(disableDepthRender?: boolean): void;
  68764. private _createChromaticAberrationPostProcess;
  68765. private _createHighlightsPostProcess;
  68766. private _createDepthOfFieldPostProcess;
  68767. private _createGrainTexture;
  68768. }
  68769. }
  68770. declare module BABYLON {
  68771. /** @hidden */
  68772. export var ssao2PixelShader: {
  68773. name: string;
  68774. shader: string;
  68775. };
  68776. }
  68777. declare module BABYLON {
  68778. /** @hidden */
  68779. export var ssaoCombinePixelShader: {
  68780. name: string;
  68781. shader: string;
  68782. };
  68783. }
  68784. declare module BABYLON {
  68785. /**
  68786. * Render pipeline to produce ssao effect
  68787. */
  68788. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  68789. /**
  68790. * @ignore
  68791. * The PassPostProcess id in the pipeline that contains the original scene color
  68792. */
  68793. SSAOOriginalSceneColorEffect: string;
  68794. /**
  68795. * @ignore
  68796. * The SSAO PostProcess id in the pipeline
  68797. */
  68798. SSAORenderEffect: string;
  68799. /**
  68800. * @ignore
  68801. * The horizontal blur PostProcess id in the pipeline
  68802. */
  68803. SSAOBlurHRenderEffect: string;
  68804. /**
  68805. * @ignore
  68806. * The vertical blur PostProcess id in the pipeline
  68807. */
  68808. SSAOBlurVRenderEffect: string;
  68809. /**
  68810. * @ignore
  68811. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68812. */
  68813. SSAOCombineRenderEffect: string;
  68814. /**
  68815. * The output strength of the SSAO post-process. Default value is 1.0.
  68816. */
  68817. totalStrength: number;
  68818. /**
  68819. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  68820. */
  68821. maxZ: number;
  68822. /**
  68823. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  68824. */
  68825. minZAspect: number;
  68826. private _samples;
  68827. /**
  68828. * Number of samples used for the SSAO calculations. Default value is 8
  68829. */
  68830. set samples(n: number);
  68831. get samples(): number;
  68832. private _textureSamples;
  68833. /**
  68834. * Number of samples to use for antialiasing
  68835. */
  68836. set textureSamples(n: number);
  68837. get textureSamples(): number;
  68838. /**
  68839. * Ratio object used for SSAO ratio and blur ratio
  68840. */
  68841. private _ratio;
  68842. /**
  68843. * Dynamically generated sphere sampler.
  68844. */
  68845. private _sampleSphere;
  68846. /**
  68847. * Blur filter offsets
  68848. */
  68849. private _samplerOffsets;
  68850. private _expensiveBlur;
  68851. /**
  68852. * If bilateral blur should be used
  68853. */
  68854. set expensiveBlur(b: boolean);
  68855. get expensiveBlur(): boolean;
  68856. /**
  68857. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  68858. */
  68859. radius: number;
  68860. /**
  68861. * The base color of the SSAO post-process
  68862. * The final result is "base + ssao" between [0, 1]
  68863. */
  68864. base: number;
  68865. /**
  68866. * Support test.
  68867. */
  68868. static get IsSupported(): boolean;
  68869. private _scene;
  68870. private _depthTexture;
  68871. private _normalTexture;
  68872. private _randomTexture;
  68873. private _originalColorPostProcess;
  68874. private _ssaoPostProcess;
  68875. private _blurHPostProcess;
  68876. private _blurVPostProcess;
  68877. private _ssaoCombinePostProcess;
  68878. /**
  68879. * Gets active scene
  68880. */
  68881. get scene(): Scene;
  68882. /**
  68883. * @constructor
  68884. * @param name The rendering pipeline name
  68885. * @param scene The scene linked to this pipeline
  68886. * @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 }
  68887. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68888. */
  68889. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68890. /**
  68891. * Get the class name
  68892. * @returns "SSAO2RenderingPipeline"
  68893. */
  68894. getClassName(): string;
  68895. /**
  68896. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68897. */
  68898. dispose(disableGeometryBufferRenderer?: boolean): void;
  68899. private _createBlurPostProcess;
  68900. /** @hidden */
  68901. _rebuild(): void;
  68902. private _bits;
  68903. private _radicalInverse_VdC;
  68904. private _hammersley;
  68905. private _hemisphereSample_uniform;
  68906. private _generateHemisphere;
  68907. private _createSSAOPostProcess;
  68908. private _createSSAOCombinePostProcess;
  68909. private _createRandomTexture;
  68910. /**
  68911. * Serialize the rendering pipeline (Used when exporting)
  68912. * @returns the serialized object
  68913. */
  68914. serialize(): any;
  68915. /**
  68916. * Parse the serialized pipeline
  68917. * @param source Source pipeline.
  68918. * @param scene The scene to load the pipeline to.
  68919. * @param rootUrl The URL of the serialized pipeline.
  68920. * @returns An instantiated pipeline from the serialized object.
  68921. */
  68922. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  68923. }
  68924. }
  68925. declare module BABYLON {
  68926. /** @hidden */
  68927. export var ssaoPixelShader: {
  68928. name: string;
  68929. shader: string;
  68930. };
  68931. }
  68932. declare module BABYLON {
  68933. /**
  68934. * Render pipeline to produce ssao effect
  68935. */
  68936. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  68937. /**
  68938. * @ignore
  68939. * The PassPostProcess id in the pipeline that contains the original scene color
  68940. */
  68941. SSAOOriginalSceneColorEffect: string;
  68942. /**
  68943. * @ignore
  68944. * The SSAO PostProcess id in the pipeline
  68945. */
  68946. SSAORenderEffect: string;
  68947. /**
  68948. * @ignore
  68949. * The horizontal blur PostProcess id in the pipeline
  68950. */
  68951. SSAOBlurHRenderEffect: string;
  68952. /**
  68953. * @ignore
  68954. * The vertical blur PostProcess id in the pipeline
  68955. */
  68956. SSAOBlurVRenderEffect: string;
  68957. /**
  68958. * @ignore
  68959. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68960. */
  68961. SSAOCombineRenderEffect: string;
  68962. /**
  68963. * The output strength of the SSAO post-process. Default value is 1.0.
  68964. */
  68965. totalStrength: number;
  68966. /**
  68967. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  68968. */
  68969. radius: number;
  68970. /**
  68971. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  68972. * Must not be equal to fallOff and superior to fallOff.
  68973. * Default value is 0.0075
  68974. */
  68975. area: number;
  68976. /**
  68977. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  68978. * Must not be equal to area and inferior to area.
  68979. * Default value is 0.000001
  68980. */
  68981. fallOff: number;
  68982. /**
  68983. * The base color of the SSAO post-process
  68984. * The final result is "base + ssao" between [0, 1]
  68985. */
  68986. base: number;
  68987. private _scene;
  68988. private _depthTexture;
  68989. private _randomTexture;
  68990. private _originalColorPostProcess;
  68991. private _ssaoPostProcess;
  68992. private _blurHPostProcess;
  68993. private _blurVPostProcess;
  68994. private _ssaoCombinePostProcess;
  68995. private _firstUpdate;
  68996. /**
  68997. * Gets active scene
  68998. */
  68999. get scene(): Scene;
  69000. /**
  69001. * @constructor
  69002. * @param name - The rendering pipeline name
  69003. * @param scene - The scene linked to this pipeline
  69004. * @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 }
  69005. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69006. */
  69007. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69008. /**
  69009. * Get the class name
  69010. * @returns "SSAORenderingPipeline"
  69011. */
  69012. getClassName(): string;
  69013. /**
  69014. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69015. */
  69016. dispose(disableDepthRender?: boolean): void;
  69017. private _createBlurPostProcess;
  69018. /** @hidden */
  69019. _rebuild(): void;
  69020. private _createSSAOPostProcess;
  69021. private _createSSAOCombinePostProcess;
  69022. private _createRandomTexture;
  69023. }
  69024. }
  69025. declare module BABYLON {
  69026. /** @hidden */
  69027. export var screenSpaceReflectionPixelShader: {
  69028. name: string;
  69029. shader: string;
  69030. };
  69031. }
  69032. declare module BABYLON {
  69033. /**
  69034. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69035. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69036. */
  69037. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69038. /**
  69039. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69040. */
  69041. threshold: number;
  69042. /**
  69043. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69044. */
  69045. strength: number;
  69046. /**
  69047. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69048. */
  69049. reflectionSpecularFalloffExponent: number;
  69050. /**
  69051. * 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]
  69052. */
  69053. step: number;
  69054. /**
  69055. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69056. */
  69057. roughnessFactor: number;
  69058. private _geometryBufferRenderer;
  69059. private _enableSmoothReflections;
  69060. private _reflectionSamples;
  69061. private _smoothSteps;
  69062. /**
  69063. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69064. * @param name The name of the effect.
  69065. * @param scene The scene containing the objects to calculate reflections.
  69066. * @param options The required width/height ratio to downsize to before computing the render pass.
  69067. * @param camera The camera to apply the render pass to.
  69068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69069. * @param engine The engine which the post process will be applied. (default: current engine)
  69070. * @param reusable If the post process can be reused on the same frame. (default: false)
  69071. * @param textureType Type of textures used when performing the post process. (default: 0)
  69072. * @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)
  69073. */
  69074. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69075. /**
  69076. * Gets wether or not smoothing reflections is enabled.
  69077. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69078. */
  69079. get enableSmoothReflections(): boolean;
  69080. /**
  69081. * Sets wether or not smoothing reflections is enabled.
  69082. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69083. */
  69084. set enableSmoothReflections(enabled: boolean);
  69085. /**
  69086. * Gets the number of samples taken while computing reflections. More samples count is high,
  69087. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69088. */
  69089. get reflectionSamples(): number;
  69090. /**
  69091. * Sets the number of samples taken while computing reflections. More samples count is high,
  69092. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69093. */
  69094. set reflectionSamples(samples: number);
  69095. /**
  69096. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69097. * more the post-process will require GPU power and can generate a drop in FPS.
  69098. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69099. */
  69100. get smoothSteps(): number;
  69101. set smoothSteps(steps: number);
  69102. private _updateEffectDefines;
  69103. }
  69104. }
  69105. declare module BABYLON {
  69106. /** @hidden */
  69107. export var standardPixelShader: {
  69108. name: string;
  69109. shader: string;
  69110. };
  69111. }
  69112. declare module BABYLON {
  69113. /**
  69114. * Standard rendering pipeline
  69115. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69116. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69117. */
  69118. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69119. /**
  69120. * Public members
  69121. */
  69122. /**
  69123. * Post-process which contains the original scene color before the pipeline applies all the effects
  69124. */
  69125. originalPostProcess: Nullable<PostProcess>;
  69126. /**
  69127. * Post-process used to down scale an image x4
  69128. */
  69129. downSampleX4PostProcess: Nullable<PostProcess>;
  69130. /**
  69131. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69132. */
  69133. brightPassPostProcess: Nullable<PostProcess>;
  69134. /**
  69135. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69136. */
  69137. blurHPostProcesses: PostProcess[];
  69138. /**
  69139. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69140. */
  69141. blurVPostProcesses: PostProcess[];
  69142. /**
  69143. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69144. */
  69145. textureAdderPostProcess: Nullable<PostProcess>;
  69146. /**
  69147. * Post-process used to create volumetric lighting effect
  69148. */
  69149. volumetricLightPostProcess: Nullable<PostProcess>;
  69150. /**
  69151. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69152. */
  69153. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69154. /**
  69155. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69156. */
  69157. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69158. /**
  69159. * Post-process used to merge the volumetric light effect and the real scene color
  69160. */
  69161. volumetricLightMergePostProces: Nullable<PostProcess>;
  69162. /**
  69163. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69164. */
  69165. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69166. /**
  69167. * Base post-process used to calculate the average luminance of the final image for HDR
  69168. */
  69169. luminancePostProcess: Nullable<PostProcess>;
  69170. /**
  69171. * Post-processes used to create down sample post-processes in order to get
  69172. * the average luminance of the final image for HDR
  69173. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69174. */
  69175. luminanceDownSamplePostProcesses: PostProcess[];
  69176. /**
  69177. * Post-process used to create a HDR effect (light adaptation)
  69178. */
  69179. hdrPostProcess: Nullable<PostProcess>;
  69180. /**
  69181. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69182. */
  69183. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69184. /**
  69185. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69186. */
  69187. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69188. /**
  69189. * Post-process used to merge the final HDR post-process and the real scene color
  69190. */
  69191. hdrFinalPostProcess: Nullable<PostProcess>;
  69192. /**
  69193. * Post-process used to create a lens flare effect
  69194. */
  69195. lensFlarePostProcess: Nullable<PostProcess>;
  69196. /**
  69197. * Post-process that merges the result of the lens flare post-process and the real scene color
  69198. */
  69199. lensFlareComposePostProcess: Nullable<PostProcess>;
  69200. /**
  69201. * Post-process used to create a motion blur effect
  69202. */
  69203. motionBlurPostProcess: Nullable<PostProcess>;
  69204. /**
  69205. * Post-process used to create a depth of field effect
  69206. */
  69207. depthOfFieldPostProcess: Nullable<PostProcess>;
  69208. /**
  69209. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69210. */
  69211. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69212. /**
  69213. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69214. */
  69215. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69216. /**
  69217. * Represents the brightness threshold in order to configure the illuminated surfaces
  69218. */
  69219. brightThreshold: number;
  69220. /**
  69221. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69222. */
  69223. blurWidth: number;
  69224. /**
  69225. * Sets if the blur for highlighted surfaces must be only horizontal
  69226. */
  69227. horizontalBlur: boolean;
  69228. /**
  69229. * Gets the overall exposure used by the pipeline
  69230. */
  69231. get exposure(): number;
  69232. /**
  69233. * Sets the overall exposure used by the pipeline
  69234. */
  69235. set exposure(value: number);
  69236. /**
  69237. * Texture used typically to simulate "dirty" on camera lens
  69238. */
  69239. lensTexture: Nullable<Texture>;
  69240. /**
  69241. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69242. */
  69243. volumetricLightCoefficient: number;
  69244. /**
  69245. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69246. */
  69247. volumetricLightPower: number;
  69248. /**
  69249. * Used the set the blur intensity to smooth the volumetric lights
  69250. */
  69251. volumetricLightBlurScale: number;
  69252. /**
  69253. * Light (spot or directional) used to generate the volumetric lights rays
  69254. * The source light must have a shadow generate so the pipeline can get its
  69255. * depth map
  69256. */
  69257. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69258. /**
  69259. * For eye adaptation, represents the minimum luminance the eye can see
  69260. */
  69261. hdrMinimumLuminance: number;
  69262. /**
  69263. * For eye adaptation, represents the decrease luminance speed
  69264. */
  69265. hdrDecreaseRate: number;
  69266. /**
  69267. * For eye adaptation, represents the increase luminance speed
  69268. */
  69269. hdrIncreaseRate: number;
  69270. /**
  69271. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69272. */
  69273. get hdrAutoExposure(): boolean;
  69274. /**
  69275. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69276. */
  69277. set hdrAutoExposure(value: boolean);
  69278. /**
  69279. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69280. */
  69281. lensColorTexture: Nullable<Texture>;
  69282. /**
  69283. * The overall strengh for the lens flare effect
  69284. */
  69285. lensFlareStrength: number;
  69286. /**
  69287. * Dispersion coefficient for lens flare ghosts
  69288. */
  69289. lensFlareGhostDispersal: number;
  69290. /**
  69291. * Main lens flare halo width
  69292. */
  69293. lensFlareHaloWidth: number;
  69294. /**
  69295. * Based on the lens distortion effect, defines how much the lens flare result
  69296. * is distorted
  69297. */
  69298. lensFlareDistortionStrength: number;
  69299. /**
  69300. * Configures the blur intensity used for for lens flare (halo)
  69301. */
  69302. lensFlareBlurWidth: number;
  69303. /**
  69304. * Lens star texture must be used to simulate rays on the flares and is available
  69305. * in the documentation
  69306. */
  69307. lensStarTexture: Nullable<Texture>;
  69308. /**
  69309. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69310. * flare effect by taking account of the dirt texture
  69311. */
  69312. lensFlareDirtTexture: Nullable<Texture>;
  69313. /**
  69314. * Represents the focal length for the depth of field effect
  69315. */
  69316. depthOfFieldDistance: number;
  69317. /**
  69318. * Represents the blur intensity for the blurred part of the depth of field effect
  69319. */
  69320. depthOfFieldBlurWidth: number;
  69321. /**
  69322. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69323. */
  69324. get motionStrength(): number;
  69325. /**
  69326. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69327. */
  69328. set motionStrength(strength: number);
  69329. /**
  69330. * Gets wether or not the motion blur post-process is object based or screen based.
  69331. */
  69332. get objectBasedMotionBlur(): boolean;
  69333. /**
  69334. * Sets wether or not the motion blur post-process should be object based or screen based
  69335. */
  69336. set objectBasedMotionBlur(value: boolean);
  69337. /**
  69338. * List of animations for the pipeline (IAnimatable implementation)
  69339. */
  69340. animations: Animation[];
  69341. /**
  69342. * Private members
  69343. */
  69344. private _scene;
  69345. private _currentDepthOfFieldSource;
  69346. private _basePostProcess;
  69347. private _fixedExposure;
  69348. private _currentExposure;
  69349. private _hdrAutoExposure;
  69350. private _hdrCurrentLuminance;
  69351. private _motionStrength;
  69352. private _isObjectBasedMotionBlur;
  69353. private _floatTextureType;
  69354. private _camerasToBeAttached;
  69355. private _ratio;
  69356. private _bloomEnabled;
  69357. private _depthOfFieldEnabled;
  69358. private _vlsEnabled;
  69359. private _lensFlareEnabled;
  69360. private _hdrEnabled;
  69361. private _motionBlurEnabled;
  69362. private _fxaaEnabled;
  69363. private _screenSpaceReflectionsEnabled;
  69364. private _motionBlurSamples;
  69365. private _volumetricLightStepsCount;
  69366. private _samples;
  69367. /**
  69368. * @ignore
  69369. * Specifies if the bloom pipeline is enabled
  69370. */
  69371. get BloomEnabled(): boolean;
  69372. set BloomEnabled(enabled: boolean);
  69373. /**
  69374. * @ignore
  69375. * Specifies if the depth of field pipeline is enabed
  69376. */
  69377. get DepthOfFieldEnabled(): boolean;
  69378. set DepthOfFieldEnabled(enabled: boolean);
  69379. /**
  69380. * @ignore
  69381. * Specifies if the lens flare pipeline is enabed
  69382. */
  69383. get LensFlareEnabled(): boolean;
  69384. set LensFlareEnabled(enabled: boolean);
  69385. /**
  69386. * @ignore
  69387. * Specifies if the HDR pipeline is enabled
  69388. */
  69389. get HDREnabled(): boolean;
  69390. set HDREnabled(enabled: boolean);
  69391. /**
  69392. * @ignore
  69393. * Specifies if the volumetric lights scattering effect is enabled
  69394. */
  69395. get VLSEnabled(): boolean;
  69396. set VLSEnabled(enabled: boolean);
  69397. /**
  69398. * @ignore
  69399. * Specifies if the motion blur effect is enabled
  69400. */
  69401. get MotionBlurEnabled(): boolean;
  69402. set MotionBlurEnabled(enabled: boolean);
  69403. /**
  69404. * Specifies if anti-aliasing is enabled
  69405. */
  69406. get fxaaEnabled(): boolean;
  69407. set fxaaEnabled(enabled: boolean);
  69408. /**
  69409. * Specifies if screen space reflections are enabled.
  69410. */
  69411. get screenSpaceReflectionsEnabled(): boolean;
  69412. set screenSpaceReflectionsEnabled(enabled: boolean);
  69413. /**
  69414. * Specifies the number of steps used to calculate the volumetric lights
  69415. * Typically in interval [50, 200]
  69416. */
  69417. get volumetricLightStepsCount(): number;
  69418. set volumetricLightStepsCount(count: number);
  69419. /**
  69420. * Specifies the number of samples used for the motion blur effect
  69421. * Typically in interval [16, 64]
  69422. */
  69423. get motionBlurSamples(): number;
  69424. set motionBlurSamples(samples: number);
  69425. /**
  69426. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69427. */
  69428. get samples(): number;
  69429. set samples(sampleCount: number);
  69430. /**
  69431. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69432. * @constructor
  69433. * @param name The rendering pipeline name
  69434. * @param scene The scene linked to this pipeline
  69435. * @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)
  69436. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69437. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69438. */
  69439. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69440. private _buildPipeline;
  69441. private _createDownSampleX4PostProcess;
  69442. private _createBrightPassPostProcess;
  69443. private _createBlurPostProcesses;
  69444. private _createTextureAdderPostProcess;
  69445. private _createVolumetricLightPostProcess;
  69446. private _createLuminancePostProcesses;
  69447. private _createHdrPostProcess;
  69448. private _createLensFlarePostProcess;
  69449. private _createDepthOfFieldPostProcess;
  69450. private _createMotionBlurPostProcess;
  69451. private _getDepthTexture;
  69452. private _disposePostProcesses;
  69453. /**
  69454. * Dispose of the pipeline and stop all post processes
  69455. */
  69456. dispose(): void;
  69457. /**
  69458. * Serialize the rendering pipeline (Used when exporting)
  69459. * @returns the serialized object
  69460. */
  69461. serialize(): any;
  69462. /**
  69463. * Parse the serialized pipeline
  69464. * @param source Source pipeline.
  69465. * @param scene The scene to load the pipeline to.
  69466. * @param rootUrl The URL of the serialized pipeline.
  69467. * @returns An instantiated pipeline from the serialized object.
  69468. */
  69469. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69470. /**
  69471. * Luminance steps
  69472. */
  69473. static LuminanceSteps: number;
  69474. }
  69475. }
  69476. declare module BABYLON {
  69477. /** @hidden */
  69478. export var stereoscopicInterlacePixelShader: {
  69479. name: string;
  69480. shader: string;
  69481. };
  69482. }
  69483. declare module BABYLON {
  69484. /**
  69485. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  69486. */
  69487. export class StereoscopicInterlacePostProcessI extends PostProcess {
  69488. private _stepSize;
  69489. private _passedProcess;
  69490. /**
  69491. * Initializes a StereoscopicInterlacePostProcessI
  69492. * @param name The name of the effect.
  69493. * @param rigCameras The rig cameras to be appled to the post process
  69494. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  69495. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  69496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69497. * @param engine The engine which the post process will be applied. (default: current engine)
  69498. * @param reusable If the post process can be reused on the same frame. (default: false)
  69499. */
  69500. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69501. }
  69502. /**
  69503. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  69504. */
  69505. export class StereoscopicInterlacePostProcess extends PostProcess {
  69506. private _stepSize;
  69507. private _passedProcess;
  69508. /**
  69509. * Initializes a StereoscopicInterlacePostProcess
  69510. * @param name The name of the effect.
  69511. * @param rigCameras The rig cameras to be appled to the post process
  69512. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  69513. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69514. * @param engine The engine which the post process will be applied. (default: current engine)
  69515. * @param reusable If the post process can be reused on the same frame. (default: false)
  69516. */
  69517. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69518. }
  69519. }
  69520. declare module BABYLON {
  69521. /** @hidden */
  69522. export var tonemapPixelShader: {
  69523. name: string;
  69524. shader: string;
  69525. };
  69526. }
  69527. declare module BABYLON {
  69528. /** Defines operator used for tonemapping */
  69529. export enum TonemappingOperator {
  69530. /** Hable */
  69531. Hable = 0,
  69532. /** Reinhard */
  69533. Reinhard = 1,
  69534. /** HejiDawson */
  69535. HejiDawson = 2,
  69536. /** Photographic */
  69537. Photographic = 3
  69538. }
  69539. /**
  69540. * Defines a post process to apply tone mapping
  69541. */
  69542. export class TonemapPostProcess extends PostProcess {
  69543. private _operator;
  69544. /** Defines the required exposure adjustement */
  69545. exposureAdjustment: number;
  69546. /**
  69547. * Creates a new TonemapPostProcess
  69548. * @param name defines the name of the postprocess
  69549. * @param _operator defines the operator to use
  69550. * @param exposureAdjustment defines the required exposure adjustement
  69551. * @param camera defines the camera to use (can be null)
  69552. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69553. * @param engine defines the hosting engine (can be ignore if camera is set)
  69554. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69555. */
  69556. constructor(name: string, _operator: TonemappingOperator,
  69557. /** Defines the required exposure adjustement */
  69558. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69559. }
  69560. }
  69561. declare module BABYLON {
  69562. /** @hidden */
  69563. export var volumetricLightScatteringPixelShader: {
  69564. name: string;
  69565. shader: string;
  69566. };
  69567. }
  69568. declare module BABYLON {
  69569. /** @hidden */
  69570. export var volumetricLightScatteringPassVertexShader: {
  69571. name: string;
  69572. shader: string;
  69573. };
  69574. }
  69575. declare module BABYLON {
  69576. /** @hidden */
  69577. export var volumetricLightScatteringPassPixelShader: {
  69578. name: string;
  69579. shader: string;
  69580. };
  69581. }
  69582. declare module BABYLON {
  69583. /**
  69584. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69585. */
  69586. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69587. private _volumetricLightScatteringPass;
  69588. private _volumetricLightScatteringRTT;
  69589. private _viewPort;
  69590. private _screenCoordinates;
  69591. private _cachedDefines;
  69592. /**
  69593. * If not undefined, the mesh position is computed from the attached node position
  69594. */
  69595. attachedNode: {
  69596. position: Vector3;
  69597. };
  69598. /**
  69599. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69600. */
  69601. customMeshPosition: Vector3;
  69602. /**
  69603. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69604. */
  69605. useCustomMeshPosition: boolean;
  69606. /**
  69607. * If the post-process should inverse the light scattering direction
  69608. */
  69609. invert: boolean;
  69610. /**
  69611. * The internal mesh used by the post-process
  69612. */
  69613. mesh: Mesh;
  69614. /**
  69615. * @hidden
  69616. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69617. */
  69618. get useDiffuseColor(): boolean;
  69619. set useDiffuseColor(useDiffuseColor: boolean);
  69620. /**
  69621. * Array containing the excluded meshes not rendered in the internal pass
  69622. */
  69623. excludedMeshes: AbstractMesh[];
  69624. /**
  69625. * Controls the overall intensity of the post-process
  69626. */
  69627. exposure: number;
  69628. /**
  69629. * Dissipates each sample's contribution in range [0, 1]
  69630. */
  69631. decay: number;
  69632. /**
  69633. * Controls the overall intensity of each sample
  69634. */
  69635. weight: number;
  69636. /**
  69637. * Controls the density of each sample
  69638. */
  69639. density: number;
  69640. /**
  69641. * @constructor
  69642. * @param name The post-process name
  69643. * @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)
  69644. * @param camera The camera that the post-process will be attached to
  69645. * @param mesh The mesh used to create the light scattering
  69646. * @param samples The post-process quality, default 100
  69647. * @param samplingModeThe post-process filtering mode
  69648. * @param engine The babylon engine
  69649. * @param reusable If the post-process is reusable
  69650. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69651. */
  69652. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69653. /**
  69654. * Returns the string "VolumetricLightScatteringPostProcess"
  69655. * @returns "VolumetricLightScatteringPostProcess"
  69656. */
  69657. getClassName(): string;
  69658. private _isReady;
  69659. /**
  69660. * Sets the new light position for light scattering effect
  69661. * @param position The new custom light position
  69662. */
  69663. setCustomMeshPosition(position: Vector3): void;
  69664. /**
  69665. * Returns the light position for light scattering effect
  69666. * @return Vector3 The custom light position
  69667. */
  69668. getCustomMeshPosition(): Vector3;
  69669. /**
  69670. * Disposes the internal assets and detaches the post-process from the camera
  69671. */
  69672. dispose(camera: Camera): void;
  69673. /**
  69674. * Returns the render target texture used by the post-process
  69675. * @return the render target texture used by the post-process
  69676. */
  69677. getPass(): RenderTargetTexture;
  69678. private _meshExcluded;
  69679. private _createPass;
  69680. private _updateMeshScreenCoordinates;
  69681. /**
  69682. * Creates a default mesh for the Volumeric Light Scattering post-process
  69683. * @param name The mesh name
  69684. * @param scene The scene where to create the mesh
  69685. * @return the default mesh
  69686. */
  69687. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69688. }
  69689. }
  69690. declare module BABYLON {
  69691. interface Scene {
  69692. /** @hidden (Backing field) */
  69693. _boundingBoxRenderer: BoundingBoxRenderer;
  69694. /** @hidden (Backing field) */
  69695. _forceShowBoundingBoxes: boolean;
  69696. /**
  69697. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69698. */
  69699. forceShowBoundingBoxes: boolean;
  69700. /**
  69701. * Gets the bounding box renderer associated with the scene
  69702. * @returns a BoundingBoxRenderer
  69703. */
  69704. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69705. }
  69706. interface AbstractMesh {
  69707. /** @hidden (Backing field) */
  69708. _showBoundingBox: boolean;
  69709. /**
  69710. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69711. */
  69712. showBoundingBox: boolean;
  69713. }
  69714. /**
  69715. * Component responsible of rendering the bounding box of the meshes in a scene.
  69716. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69717. */
  69718. export class BoundingBoxRenderer implements ISceneComponent {
  69719. /**
  69720. * The component name helpfull to identify the component in the list of scene components.
  69721. */
  69722. readonly name: string;
  69723. /**
  69724. * The scene the component belongs to.
  69725. */
  69726. scene: Scene;
  69727. /**
  69728. * Color of the bounding box lines placed in front of an object
  69729. */
  69730. frontColor: Color3;
  69731. /**
  69732. * Color of the bounding box lines placed behind an object
  69733. */
  69734. backColor: Color3;
  69735. /**
  69736. * Defines if the renderer should show the back lines or not
  69737. */
  69738. showBackLines: boolean;
  69739. /**
  69740. * Observable raised before rendering a bounding box
  69741. */
  69742. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  69743. /**
  69744. * Observable raised after rendering a bounding box
  69745. */
  69746. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  69747. /**
  69748. * @hidden
  69749. */
  69750. renderList: SmartArray<BoundingBox>;
  69751. private _colorShader;
  69752. private _vertexBuffers;
  69753. private _indexBuffer;
  69754. private _fillIndexBuffer;
  69755. private _fillIndexData;
  69756. /**
  69757. * Instantiates a new bounding box renderer in a scene.
  69758. * @param scene the scene the renderer renders in
  69759. */
  69760. constructor(scene: Scene);
  69761. /**
  69762. * Registers the component in a given scene
  69763. */
  69764. register(): void;
  69765. private _evaluateSubMesh;
  69766. private _activeMesh;
  69767. private _prepareRessources;
  69768. private _createIndexBuffer;
  69769. /**
  69770. * Rebuilds the elements related to this component in case of
  69771. * context lost for instance.
  69772. */
  69773. rebuild(): void;
  69774. /**
  69775. * @hidden
  69776. */
  69777. reset(): void;
  69778. /**
  69779. * Render the bounding boxes of a specific rendering group
  69780. * @param renderingGroupId defines the rendering group to render
  69781. */
  69782. render(renderingGroupId: number): void;
  69783. /**
  69784. * In case of occlusion queries, we can render the occlusion bounding box through this method
  69785. * @param mesh Define the mesh to render the occlusion bounding box for
  69786. */
  69787. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  69788. /**
  69789. * Dispose and release the resources attached to this renderer.
  69790. */
  69791. dispose(): void;
  69792. }
  69793. }
  69794. declare module BABYLON {
  69795. interface Scene {
  69796. /** @hidden (Backing field) */
  69797. _depthRenderer: {
  69798. [id: string]: DepthRenderer;
  69799. };
  69800. /**
  69801. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  69802. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  69803. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  69804. * @returns the created depth renderer
  69805. */
  69806. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  69807. /**
  69808. * Disables a depth renderer for a given camera
  69809. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  69810. */
  69811. disableDepthRenderer(camera?: Nullable<Camera>): void;
  69812. }
  69813. /**
  69814. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  69815. * in several rendering techniques.
  69816. */
  69817. export class DepthRendererSceneComponent implements ISceneComponent {
  69818. /**
  69819. * The component name helpfull to identify the component in the list of scene components.
  69820. */
  69821. readonly name: string;
  69822. /**
  69823. * The scene the component belongs to.
  69824. */
  69825. scene: Scene;
  69826. /**
  69827. * Creates a new instance of the component for the given scene
  69828. * @param scene Defines the scene to register the component in
  69829. */
  69830. constructor(scene: Scene);
  69831. /**
  69832. * Registers the component in a given scene
  69833. */
  69834. register(): void;
  69835. /**
  69836. * Rebuilds the elements related to this component in case of
  69837. * context lost for instance.
  69838. */
  69839. rebuild(): void;
  69840. /**
  69841. * Disposes the component and the associated ressources
  69842. */
  69843. dispose(): void;
  69844. private _gatherRenderTargets;
  69845. private _gatherActiveCameraRenderTargets;
  69846. }
  69847. }
  69848. declare module BABYLON {
  69849. /** @hidden */
  69850. export var outlinePixelShader: {
  69851. name: string;
  69852. shader: string;
  69853. };
  69854. }
  69855. declare module BABYLON {
  69856. /** @hidden */
  69857. export var outlineVertexShader: {
  69858. name: string;
  69859. shader: string;
  69860. };
  69861. }
  69862. declare module BABYLON {
  69863. interface Scene {
  69864. /** @hidden */
  69865. _outlineRenderer: OutlineRenderer;
  69866. /**
  69867. * Gets the outline renderer associated with the scene
  69868. * @returns a OutlineRenderer
  69869. */
  69870. getOutlineRenderer(): OutlineRenderer;
  69871. }
  69872. interface AbstractMesh {
  69873. /** @hidden (Backing field) */
  69874. _renderOutline: boolean;
  69875. /**
  69876. * Gets or sets a boolean indicating if the outline must be rendered as well
  69877. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  69878. */
  69879. renderOutline: boolean;
  69880. /** @hidden (Backing field) */
  69881. _renderOverlay: boolean;
  69882. /**
  69883. * Gets or sets a boolean indicating if the overlay must be rendered as well
  69884. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  69885. */
  69886. renderOverlay: boolean;
  69887. }
  69888. /**
  69889. * This class is responsible to draw bothe outline/overlay of meshes.
  69890. * It should not be used directly but through the available method on mesh.
  69891. */
  69892. export class OutlineRenderer implements ISceneComponent {
  69893. /**
  69894. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  69895. */
  69896. private static _StencilReference;
  69897. /**
  69898. * The name of the component. Each component must have a unique name.
  69899. */
  69900. name: string;
  69901. /**
  69902. * The scene the component belongs to.
  69903. */
  69904. scene: Scene;
  69905. /**
  69906. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  69907. */
  69908. zOffset: number;
  69909. private _engine;
  69910. private _effect;
  69911. private _cachedDefines;
  69912. private _savedDepthWrite;
  69913. /**
  69914. * Instantiates a new outline renderer. (There could be only one per scene).
  69915. * @param scene Defines the scene it belongs to
  69916. */
  69917. constructor(scene: Scene);
  69918. /**
  69919. * Register the component to one instance of a scene.
  69920. */
  69921. register(): void;
  69922. /**
  69923. * Rebuilds the elements related to this component in case of
  69924. * context lost for instance.
  69925. */
  69926. rebuild(): void;
  69927. /**
  69928. * Disposes the component and the associated ressources.
  69929. */
  69930. dispose(): void;
  69931. /**
  69932. * Renders the outline in the canvas.
  69933. * @param subMesh Defines the sumesh to render
  69934. * @param batch Defines the batch of meshes in case of instances
  69935. * @param useOverlay Defines if the rendering is for the overlay or the outline
  69936. */
  69937. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  69938. /**
  69939. * Returns whether or not the outline renderer is ready for a given submesh.
  69940. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  69941. * @param subMesh Defines the submesh to check readyness for
  69942. * @param useInstances Defines wheter wee are trying to render instances or not
  69943. * @returns true if ready otherwise false
  69944. */
  69945. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69946. private _beforeRenderingMesh;
  69947. private _afterRenderingMesh;
  69948. }
  69949. }
  69950. declare module BABYLON {
  69951. /**
  69952. * Defines the basic options interface of a Sprite Frame Source Size.
  69953. */
  69954. export interface ISpriteJSONSpriteSourceSize {
  69955. /**
  69956. * number of the original width of the Frame
  69957. */
  69958. w: number;
  69959. /**
  69960. * number of the original height of the Frame
  69961. */
  69962. h: number;
  69963. }
  69964. /**
  69965. * Defines the basic options interface of a Sprite Frame Data.
  69966. */
  69967. export interface ISpriteJSONSpriteFrameData {
  69968. /**
  69969. * number of the x offset of the Frame
  69970. */
  69971. x: number;
  69972. /**
  69973. * number of the y offset of the Frame
  69974. */
  69975. y: number;
  69976. /**
  69977. * number of the width of the Frame
  69978. */
  69979. w: number;
  69980. /**
  69981. * number of the height of the Frame
  69982. */
  69983. h: number;
  69984. }
  69985. /**
  69986. * Defines the basic options interface of a JSON Sprite.
  69987. */
  69988. export interface ISpriteJSONSprite {
  69989. /**
  69990. * string name of the Frame
  69991. */
  69992. filename: string;
  69993. /**
  69994. * ISpriteJSONSpriteFrame basic object of the frame data
  69995. */
  69996. frame: ISpriteJSONSpriteFrameData;
  69997. /**
  69998. * boolean to flag is the frame was rotated.
  69999. */
  70000. rotated: boolean;
  70001. /**
  70002. * boolean to flag is the frame was trimmed.
  70003. */
  70004. trimmed: boolean;
  70005. /**
  70006. * ISpriteJSONSpriteFrame basic object of the source data
  70007. */
  70008. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70009. /**
  70010. * ISpriteJSONSpriteFrame basic object of the source data
  70011. */
  70012. sourceSize: ISpriteJSONSpriteSourceSize;
  70013. }
  70014. /**
  70015. * Defines the basic options interface of a JSON atlas.
  70016. */
  70017. export interface ISpriteJSONAtlas {
  70018. /**
  70019. * Array of objects that contain the frame data.
  70020. */
  70021. frames: Array<ISpriteJSONSprite>;
  70022. /**
  70023. * object basic object containing the sprite meta data.
  70024. */
  70025. meta?: object;
  70026. }
  70027. }
  70028. declare module BABYLON {
  70029. /** @hidden */
  70030. export var spriteMapPixelShader: {
  70031. name: string;
  70032. shader: string;
  70033. };
  70034. }
  70035. declare module BABYLON {
  70036. /** @hidden */
  70037. export var spriteMapVertexShader: {
  70038. name: string;
  70039. shader: string;
  70040. };
  70041. }
  70042. declare module BABYLON {
  70043. /**
  70044. * Defines the basic options interface of a SpriteMap
  70045. */
  70046. export interface ISpriteMapOptions {
  70047. /**
  70048. * Vector2 of the number of cells in the grid.
  70049. */
  70050. stageSize?: Vector2;
  70051. /**
  70052. * Vector2 of the size of the output plane in World Units.
  70053. */
  70054. outputSize?: Vector2;
  70055. /**
  70056. * Vector3 of the position of the output plane in World Units.
  70057. */
  70058. outputPosition?: Vector3;
  70059. /**
  70060. * Vector3 of the rotation of the output plane.
  70061. */
  70062. outputRotation?: Vector3;
  70063. /**
  70064. * number of layers that the system will reserve in resources.
  70065. */
  70066. layerCount?: number;
  70067. /**
  70068. * number of max animation frames a single cell will reserve in resources.
  70069. */
  70070. maxAnimationFrames?: number;
  70071. /**
  70072. * number cell index of the base tile when the system compiles.
  70073. */
  70074. baseTile?: number;
  70075. /**
  70076. * boolean flip the sprite after its been repositioned by the framing data.
  70077. */
  70078. flipU?: boolean;
  70079. /**
  70080. * Vector3 scalar of the global RGB values of the SpriteMap.
  70081. */
  70082. colorMultiply?: Vector3;
  70083. }
  70084. /**
  70085. * Defines the IDisposable interface in order to be cleanable from resources.
  70086. */
  70087. export interface ISpriteMap extends IDisposable {
  70088. /**
  70089. * String name of the SpriteMap.
  70090. */
  70091. name: string;
  70092. /**
  70093. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70094. */
  70095. atlasJSON: ISpriteJSONAtlas;
  70096. /**
  70097. * Texture of the SpriteMap.
  70098. */
  70099. spriteSheet: Texture;
  70100. /**
  70101. * The parameters to initialize the SpriteMap with.
  70102. */
  70103. options: ISpriteMapOptions;
  70104. }
  70105. /**
  70106. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70107. */
  70108. export class SpriteMap implements ISpriteMap {
  70109. /** The Name of the spriteMap */
  70110. name: string;
  70111. /** The JSON file with the frame and meta data */
  70112. atlasJSON: ISpriteJSONAtlas;
  70113. /** The systems Sprite Sheet Texture */
  70114. spriteSheet: Texture;
  70115. /** Arguments passed with the Constructor */
  70116. options: ISpriteMapOptions;
  70117. /** Public Sprite Storage array, parsed from atlasJSON */
  70118. sprites: Array<ISpriteJSONSprite>;
  70119. /** Returns the Number of Sprites in the System */
  70120. get spriteCount(): number;
  70121. /** Returns the Position of Output Plane*/
  70122. get position(): Vector3;
  70123. /** Returns the Position of Output Plane*/
  70124. set position(v: Vector3);
  70125. /** Returns the Rotation of Output Plane*/
  70126. get rotation(): Vector3;
  70127. /** Returns the Rotation of Output Plane*/
  70128. set rotation(v: Vector3);
  70129. /** Sets the AnimationMap*/
  70130. get animationMap(): RawTexture;
  70131. /** Sets the AnimationMap*/
  70132. set animationMap(v: RawTexture);
  70133. /** Scene that the SpriteMap was created in */
  70134. private _scene;
  70135. /** Texture Buffer of Float32 that holds tile frame data*/
  70136. private _frameMap;
  70137. /** Texture Buffers of Float32 that holds tileMap data*/
  70138. private _tileMaps;
  70139. /** Texture Buffer of Float32 that holds Animation Data*/
  70140. private _animationMap;
  70141. /** Custom ShaderMaterial Central to the System*/
  70142. private _material;
  70143. /** Custom ShaderMaterial Central to the System*/
  70144. private _output;
  70145. /** Systems Time Ticker*/
  70146. private _time;
  70147. /**
  70148. * Creates a new SpriteMap
  70149. * @param name defines the SpriteMaps Name
  70150. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70151. * @param spriteSheet is the Texture that the Sprites are on.
  70152. * @param options a basic deployment configuration
  70153. * @param scene The Scene that the map is deployed on
  70154. */
  70155. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70156. /**
  70157. * Returns tileID location
  70158. * @returns Vector2 the cell position ID
  70159. */
  70160. getTileID(): Vector2;
  70161. /**
  70162. * Gets the UV location of the mouse over the SpriteMap.
  70163. * @returns Vector2 the UV position of the mouse interaction
  70164. */
  70165. getMousePosition(): Vector2;
  70166. /**
  70167. * Creates the "frame" texture Buffer
  70168. * -------------------------------------
  70169. * Structure of frames
  70170. * "filename": "Falling-Water-2.png",
  70171. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70172. * "rotated": true,
  70173. * "trimmed": true,
  70174. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70175. * "sourceSize": {"w":32,"h":32}
  70176. * @returns RawTexture of the frameMap
  70177. */
  70178. private _createFrameBuffer;
  70179. /**
  70180. * Creates the tileMap texture Buffer
  70181. * @param buffer normally and array of numbers, or a false to generate from scratch
  70182. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70183. * @returns RawTexture of the tileMap
  70184. */
  70185. private _createTileBuffer;
  70186. /**
  70187. * Modifies the data of the tileMaps
  70188. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70189. * @param pos is the iVector2 Coordinates of the Tile
  70190. * @param tile The SpriteIndex of the new Tile
  70191. */
  70192. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70193. /**
  70194. * Creates the animationMap texture Buffer
  70195. * @param buffer normally and array of numbers, or a false to generate from scratch
  70196. * @returns RawTexture of the animationMap
  70197. */
  70198. private _createTileAnimationBuffer;
  70199. /**
  70200. * Modifies the data of the animationMap
  70201. * @param cellID is the Index of the Sprite
  70202. * @param _frame is the target Animation frame
  70203. * @param toCell is the Target Index of the next frame of the animation
  70204. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70205. * @param speed is a global scalar of the time variable on the map.
  70206. */
  70207. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70208. /**
  70209. * Exports the .tilemaps file
  70210. */
  70211. saveTileMaps(): void;
  70212. /**
  70213. * Imports the .tilemaps file
  70214. * @param url of the .tilemaps file
  70215. */
  70216. loadTileMaps(url: string): void;
  70217. /**
  70218. * Release associated resources
  70219. */
  70220. dispose(): void;
  70221. }
  70222. }
  70223. declare module BABYLON {
  70224. /**
  70225. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70226. * @see http://doc.babylonjs.com/babylon101/sprites
  70227. */
  70228. export class SpritePackedManager extends SpriteManager {
  70229. /** defines the packed manager's name */
  70230. name: string;
  70231. /**
  70232. * Creates a new sprite manager from a packed sprite sheet
  70233. * @param name defines the manager's name
  70234. * @param imgUrl defines the sprite sheet url
  70235. * @param capacity defines the maximum allowed number of sprites
  70236. * @param scene defines the hosting scene
  70237. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70238. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70239. * @param samplingMode defines the smapling mode to use with spritesheet
  70240. * @param fromPacked set to true; do not alter
  70241. */
  70242. constructor(
  70243. /** defines the packed manager's name */
  70244. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70245. }
  70246. }
  70247. declare module BABYLON {
  70248. /**
  70249. * Defines the list of states available for a task inside a AssetsManager
  70250. */
  70251. export enum AssetTaskState {
  70252. /**
  70253. * Initialization
  70254. */
  70255. INIT = 0,
  70256. /**
  70257. * Running
  70258. */
  70259. RUNNING = 1,
  70260. /**
  70261. * Done
  70262. */
  70263. DONE = 2,
  70264. /**
  70265. * Error
  70266. */
  70267. ERROR = 3
  70268. }
  70269. /**
  70270. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70271. */
  70272. export abstract class AbstractAssetTask {
  70273. /**
  70274. * Task name
  70275. */ name: string;
  70276. /**
  70277. * Callback called when the task is successful
  70278. */
  70279. onSuccess: (task: any) => void;
  70280. /**
  70281. * Callback called when the task is not successful
  70282. */
  70283. onError: (task: any, message?: string, exception?: any) => void;
  70284. /**
  70285. * Creates a new AssetsManager
  70286. * @param name defines the name of the task
  70287. */
  70288. constructor(
  70289. /**
  70290. * Task name
  70291. */ name: string);
  70292. private _isCompleted;
  70293. private _taskState;
  70294. private _errorObject;
  70295. /**
  70296. * Get if the task is completed
  70297. */
  70298. get isCompleted(): boolean;
  70299. /**
  70300. * Gets the current state of the task
  70301. */
  70302. get taskState(): AssetTaskState;
  70303. /**
  70304. * Gets the current error object (if task is in error)
  70305. */
  70306. get errorObject(): {
  70307. message?: string;
  70308. exception?: any;
  70309. };
  70310. /**
  70311. * Internal only
  70312. * @hidden
  70313. */
  70314. _setErrorObject(message?: string, exception?: any): void;
  70315. /**
  70316. * Execute the current task
  70317. * @param scene defines the scene where you want your assets to be loaded
  70318. * @param onSuccess is a callback called when the task is successfully executed
  70319. * @param onError is a callback called if an error occurs
  70320. */
  70321. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70322. /**
  70323. * Execute the current task
  70324. * @param scene defines the scene where you want your assets to be loaded
  70325. * @param onSuccess is a callback called when the task is successfully executed
  70326. * @param onError is a callback called if an error occurs
  70327. */
  70328. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70329. /**
  70330. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70331. * This can be used with failed tasks that have the reason for failure fixed.
  70332. */
  70333. reset(): void;
  70334. private onErrorCallback;
  70335. private onDoneCallback;
  70336. }
  70337. /**
  70338. * Define the interface used by progress events raised during assets loading
  70339. */
  70340. export interface IAssetsProgressEvent {
  70341. /**
  70342. * Defines the number of remaining tasks to process
  70343. */
  70344. remainingCount: number;
  70345. /**
  70346. * Defines the total number of tasks
  70347. */
  70348. totalCount: number;
  70349. /**
  70350. * Defines the task that was just processed
  70351. */
  70352. task: AbstractAssetTask;
  70353. }
  70354. /**
  70355. * Class used to share progress information about assets loading
  70356. */
  70357. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70358. /**
  70359. * Defines the number of remaining tasks to process
  70360. */
  70361. remainingCount: number;
  70362. /**
  70363. * Defines the total number of tasks
  70364. */
  70365. totalCount: number;
  70366. /**
  70367. * Defines the task that was just processed
  70368. */
  70369. task: AbstractAssetTask;
  70370. /**
  70371. * Creates a AssetsProgressEvent
  70372. * @param remainingCount defines the number of remaining tasks to process
  70373. * @param totalCount defines the total number of tasks
  70374. * @param task defines the task that was just processed
  70375. */
  70376. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70377. }
  70378. /**
  70379. * Define a task used by AssetsManager to load meshes
  70380. */
  70381. export class MeshAssetTask extends AbstractAssetTask {
  70382. /**
  70383. * Defines the name of the task
  70384. */
  70385. name: string;
  70386. /**
  70387. * Defines the list of mesh's names you want to load
  70388. */
  70389. meshesNames: any;
  70390. /**
  70391. * Defines the root url to use as a base to load your meshes and associated resources
  70392. */
  70393. rootUrl: string;
  70394. /**
  70395. * Defines the filename or File of the scene to load from
  70396. */
  70397. sceneFilename: string | File;
  70398. /**
  70399. * Gets the list of loaded meshes
  70400. */
  70401. loadedMeshes: Array<AbstractMesh>;
  70402. /**
  70403. * Gets the list of loaded particle systems
  70404. */
  70405. loadedParticleSystems: Array<IParticleSystem>;
  70406. /**
  70407. * Gets the list of loaded skeletons
  70408. */
  70409. loadedSkeletons: Array<Skeleton>;
  70410. /**
  70411. * Gets the list of loaded animation groups
  70412. */
  70413. loadedAnimationGroups: Array<AnimationGroup>;
  70414. /**
  70415. * Callback called when the task is successful
  70416. */
  70417. onSuccess: (task: MeshAssetTask) => void;
  70418. /**
  70419. * Callback called when the task is successful
  70420. */
  70421. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70422. /**
  70423. * Creates a new MeshAssetTask
  70424. * @param name defines the name of the task
  70425. * @param meshesNames defines the list of mesh's names you want to load
  70426. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70427. * @param sceneFilename defines the filename or File of the scene to load from
  70428. */
  70429. constructor(
  70430. /**
  70431. * Defines the name of the task
  70432. */
  70433. name: string,
  70434. /**
  70435. * Defines the list of mesh's names you want to load
  70436. */
  70437. meshesNames: any,
  70438. /**
  70439. * Defines the root url to use as a base to load your meshes and associated resources
  70440. */
  70441. rootUrl: string,
  70442. /**
  70443. * Defines the filename or File of the scene to load from
  70444. */
  70445. sceneFilename: string | File);
  70446. /**
  70447. * Execute the current task
  70448. * @param scene defines the scene where you want your assets to be loaded
  70449. * @param onSuccess is a callback called when the task is successfully executed
  70450. * @param onError is a callback called if an error occurs
  70451. */
  70452. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70453. }
  70454. /**
  70455. * Define a task used by AssetsManager to load text content
  70456. */
  70457. export class TextFileAssetTask extends AbstractAssetTask {
  70458. /**
  70459. * Defines the name of the task
  70460. */
  70461. name: string;
  70462. /**
  70463. * Defines the location of the file to load
  70464. */
  70465. url: string;
  70466. /**
  70467. * Gets the loaded text string
  70468. */
  70469. text: string;
  70470. /**
  70471. * Callback called when the task is successful
  70472. */
  70473. onSuccess: (task: TextFileAssetTask) => void;
  70474. /**
  70475. * Callback called when the task is successful
  70476. */
  70477. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70478. /**
  70479. * Creates a new TextFileAssetTask object
  70480. * @param name defines the name of the task
  70481. * @param url defines the location of the file to load
  70482. */
  70483. constructor(
  70484. /**
  70485. * Defines the name of the task
  70486. */
  70487. name: string,
  70488. /**
  70489. * Defines the location of the file to load
  70490. */
  70491. url: string);
  70492. /**
  70493. * Execute the current task
  70494. * @param scene defines the scene where you want your assets to be loaded
  70495. * @param onSuccess is a callback called when the task is successfully executed
  70496. * @param onError is a callback called if an error occurs
  70497. */
  70498. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70499. }
  70500. /**
  70501. * Define a task used by AssetsManager to load binary data
  70502. */
  70503. export class BinaryFileAssetTask extends AbstractAssetTask {
  70504. /**
  70505. * Defines the name of the task
  70506. */
  70507. name: string;
  70508. /**
  70509. * Defines the location of the file to load
  70510. */
  70511. url: string;
  70512. /**
  70513. * Gets the lodaded data (as an array buffer)
  70514. */
  70515. data: ArrayBuffer;
  70516. /**
  70517. * Callback called when the task is successful
  70518. */
  70519. onSuccess: (task: BinaryFileAssetTask) => void;
  70520. /**
  70521. * Callback called when the task is successful
  70522. */
  70523. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70524. /**
  70525. * Creates a new BinaryFileAssetTask object
  70526. * @param name defines the name of the new task
  70527. * @param url defines the location of the file to load
  70528. */
  70529. constructor(
  70530. /**
  70531. * Defines the name of the task
  70532. */
  70533. name: string,
  70534. /**
  70535. * Defines the location of the file to load
  70536. */
  70537. url: string);
  70538. /**
  70539. * Execute the current task
  70540. * @param scene defines the scene where you want your assets to be loaded
  70541. * @param onSuccess is a callback called when the task is successfully executed
  70542. * @param onError is a callback called if an error occurs
  70543. */
  70544. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70545. }
  70546. /**
  70547. * Define a task used by AssetsManager to load images
  70548. */
  70549. export class ImageAssetTask extends AbstractAssetTask {
  70550. /**
  70551. * Defines the name of the task
  70552. */
  70553. name: string;
  70554. /**
  70555. * Defines the location of the image to load
  70556. */
  70557. url: string;
  70558. /**
  70559. * Gets the loaded images
  70560. */
  70561. image: HTMLImageElement;
  70562. /**
  70563. * Callback called when the task is successful
  70564. */
  70565. onSuccess: (task: ImageAssetTask) => void;
  70566. /**
  70567. * Callback called when the task is successful
  70568. */
  70569. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70570. /**
  70571. * Creates a new ImageAssetTask
  70572. * @param name defines the name of the task
  70573. * @param url defines the location of the image to load
  70574. */
  70575. constructor(
  70576. /**
  70577. * Defines the name of the task
  70578. */
  70579. name: string,
  70580. /**
  70581. * Defines the location of the image to load
  70582. */
  70583. url: string);
  70584. /**
  70585. * Execute the current task
  70586. * @param scene defines the scene where you want your assets to be loaded
  70587. * @param onSuccess is a callback called when the task is successfully executed
  70588. * @param onError is a callback called if an error occurs
  70589. */
  70590. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70591. }
  70592. /**
  70593. * Defines the interface used by texture loading tasks
  70594. */
  70595. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70596. /**
  70597. * Gets the loaded texture
  70598. */
  70599. texture: TEX;
  70600. }
  70601. /**
  70602. * Define a task used by AssetsManager to load 2D textures
  70603. */
  70604. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70605. /**
  70606. * Defines the name of the task
  70607. */
  70608. name: string;
  70609. /**
  70610. * Defines the location of the file to load
  70611. */
  70612. url: string;
  70613. /**
  70614. * Defines if mipmap should not be generated (default is false)
  70615. */
  70616. noMipmap?: boolean | undefined;
  70617. /**
  70618. * Defines if texture must be inverted on Y axis (default is true)
  70619. */
  70620. invertY: boolean;
  70621. /**
  70622. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70623. */
  70624. samplingMode: number;
  70625. /**
  70626. * Gets the loaded texture
  70627. */
  70628. texture: Texture;
  70629. /**
  70630. * Callback called when the task is successful
  70631. */
  70632. onSuccess: (task: TextureAssetTask) => void;
  70633. /**
  70634. * Callback called when the task is successful
  70635. */
  70636. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70637. /**
  70638. * Creates a new TextureAssetTask object
  70639. * @param name defines the name of the task
  70640. * @param url defines the location of the file to load
  70641. * @param noMipmap defines if mipmap should not be generated (default is false)
  70642. * @param invertY defines if texture must be inverted on Y axis (default is true)
  70643. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70644. */
  70645. constructor(
  70646. /**
  70647. * Defines the name of the task
  70648. */
  70649. name: string,
  70650. /**
  70651. * Defines the location of the file to load
  70652. */
  70653. url: string,
  70654. /**
  70655. * Defines if mipmap should not be generated (default is false)
  70656. */
  70657. noMipmap?: boolean | undefined,
  70658. /**
  70659. * Defines if texture must be inverted on Y axis (default is true)
  70660. */
  70661. invertY?: boolean,
  70662. /**
  70663. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70664. */
  70665. samplingMode?: number);
  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 cube textures
  70676. */
  70677. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  70678. /**
  70679. * Defines the name of the task
  70680. */
  70681. name: string;
  70682. /**
  70683. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70684. */
  70685. url: string;
  70686. /**
  70687. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70688. */
  70689. extensions?: string[] | undefined;
  70690. /**
  70691. * Defines if mipmaps should not be generated (default is false)
  70692. */
  70693. noMipmap?: boolean | undefined;
  70694. /**
  70695. * Defines the explicit list of files (undefined by default)
  70696. */
  70697. files?: string[] | undefined;
  70698. /**
  70699. * Gets the loaded texture
  70700. */
  70701. texture: CubeTexture;
  70702. /**
  70703. * Callback called when the task is successful
  70704. */
  70705. onSuccess: (task: CubeTextureAssetTask) => void;
  70706. /**
  70707. * Callback called when the task is successful
  70708. */
  70709. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  70710. /**
  70711. * Creates a new CubeTextureAssetTask
  70712. * @param name defines the name of the task
  70713. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70714. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70715. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70716. * @param files defines the explicit list of files (undefined by default)
  70717. */
  70718. constructor(
  70719. /**
  70720. * Defines the name of the task
  70721. */
  70722. name: string,
  70723. /**
  70724. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70725. */
  70726. url: string,
  70727. /**
  70728. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70729. */
  70730. extensions?: string[] | undefined,
  70731. /**
  70732. * Defines if mipmaps should not be generated (default is false)
  70733. */
  70734. noMipmap?: boolean | undefined,
  70735. /**
  70736. * Defines the explicit list of files (undefined by default)
  70737. */
  70738. files?: string[] | undefined);
  70739. /**
  70740. * Execute the current task
  70741. * @param scene defines the scene where you want your assets to be loaded
  70742. * @param onSuccess is a callback called when the task is successfully executed
  70743. * @param onError is a callback called if an error occurs
  70744. */
  70745. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70746. }
  70747. /**
  70748. * Define a task used by AssetsManager to load HDR cube textures
  70749. */
  70750. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  70751. /**
  70752. * Defines the name of the task
  70753. */
  70754. name: string;
  70755. /**
  70756. * Defines the location of the file to load
  70757. */
  70758. url: string;
  70759. /**
  70760. * Defines the desired size (the more it increases the longer the generation will be)
  70761. */
  70762. size: number;
  70763. /**
  70764. * Defines if mipmaps should not be generated (default is false)
  70765. */
  70766. noMipmap: boolean;
  70767. /**
  70768. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70769. */
  70770. generateHarmonics: boolean;
  70771. /**
  70772. * 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)
  70773. */
  70774. gammaSpace: boolean;
  70775. /**
  70776. * Internal Use Only
  70777. */
  70778. reserved: boolean;
  70779. /**
  70780. * Gets the loaded texture
  70781. */
  70782. texture: HDRCubeTexture;
  70783. /**
  70784. * Callback called when the task is successful
  70785. */
  70786. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  70787. /**
  70788. * Callback called when the task is successful
  70789. */
  70790. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  70791. /**
  70792. * Creates a new HDRCubeTextureAssetTask object
  70793. * @param name defines the name of the task
  70794. * @param url defines the location of the file to load
  70795. * @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.
  70796. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70797. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70798. * @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)
  70799. * @param reserved Internal use only
  70800. */
  70801. constructor(
  70802. /**
  70803. * Defines the name of the task
  70804. */
  70805. name: string,
  70806. /**
  70807. * Defines the location of the file to load
  70808. */
  70809. url: string,
  70810. /**
  70811. * Defines the desired size (the more it increases the longer the generation will be)
  70812. */
  70813. size: number,
  70814. /**
  70815. * Defines if mipmaps should not be generated (default is false)
  70816. */
  70817. noMipmap?: boolean,
  70818. /**
  70819. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70820. */
  70821. generateHarmonics?: boolean,
  70822. /**
  70823. * 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)
  70824. */
  70825. gammaSpace?: boolean,
  70826. /**
  70827. * Internal Use Only
  70828. */
  70829. reserved?: boolean);
  70830. /**
  70831. * Execute the current task
  70832. * @param scene defines the scene where you want your assets to be loaded
  70833. * @param onSuccess is a callback called when the task is successfully executed
  70834. * @param onError is a callback called if an error occurs
  70835. */
  70836. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70837. }
  70838. /**
  70839. * Define a task used by AssetsManager to load Equirectangular cube textures
  70840. */
  70841. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  70842. /**
  70843. * Defines the name of the task
  70844. */
  70845. name: string;
  70846. /**
  70847. * Defines the location of the file to load
  70848. */
  70849. url: string;
  70850. /**
  70851. * Defines the desired size (the more it increases the longer the generation will be)
  70852. */
  70853. size: number;
  70854. /**
  70855. * Defines if mipmaps should not be generated (default is false)
  70856. */
  70857. noMipmap: boolean;
  70858. /**
  70859. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70860. * but the standard material would require them in Gamma space) (default is true)
  70861. */
  70862. gammaSpace: boolean;
  70863. /**
  70864. * Gets the loaded texture
  70865. */
  70866. texture: EquiRectangularCubeTexture;
  70867. /**
  70868. * Callback called when the task is successful
  70869. */
  70870. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  70871. /**
  70872. * Callback called when the task is successful
  70873. */
  70874. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  70875. /**
  70876. * Creates a new EquiRectangularCubeTextureAssetTask object
  70877. * @param name defines the name of the task
  70878. * @param url defines the location of the file to load
  70879. * @param size defines the desired size (the more it increases the longer the generation will be)
  70880. * If the size is omitted this implies you are using a preprocessed cubemap.
  70881. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70882. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  70883. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  70884. * (default is true)
  70885. */
  70886. constructor(
  70887. /**
  70888. * Defines the name of the task
  70889. */
  70890. name: string,
  70891. /**
  70892. * Defines the location of the file to load
  70893. */
  70894. url: string,
  70895. /**
  70896. * Defines the desired size (the more it increases the longer the generation will be)
  70897. */
  70898. size: number,
  70899. /**
  70900. * Defines if mipmaps should not be generated (default is false)
  70901. */
  70902. noMipmap?: boolean,
  70903. /**
  70904. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70905. * but the standard material would require them in Gamma space) (default is true)
  70906. */
  70907. gammaSpace?: boolean);
  70908. /**
  70909. * Execute the current task
  70910. * @param scene defines the scene where you want your assets to be loaded
  70911. * @param onSuccess is a callback called when the task is successfully executed
  70912. * @param onError is a callback called if an error occurs
  70913. */
  70914. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70915. }
  70916. /**
  70917. * This class can be used to easily import assets into a scene
  70918. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  70919. */
  70920. export class AssetsManager {
  70921. private _scene;
  70922. private _isLoading;
  70923. protected _tasks: AbstractAssetTask[];
  70924. protected _waitingTasksCount: number;
  70925. protected _totalTasksCount: number;
  70926. /**
  70927. * Callback called when all tasks are processed
  70928. */
  70929. onFinish: (tasks: AbstractAssetTask[]) => void;
  70930. /**
  70931. * Callback called when a task is successful
  70932. */
  70933. onTaskSuccess: (task: AbstractAssetTask) => void;
  70934. /**
  70935. * Callback called when a task had an error
  70936. */
  70937. onTaskError: (task: AbstractAssetTask) => void;
  70938. /**
  70939. * Callback called when a task is done (whatever the result is)
  70940. */
  70941. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  70942. /**
  70943. * Observable called when all tasks are processed
  70944. */
  70945. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  70946. /**
  70947. * Observable called when a task had an error
  70948. */
  70949. onTaskErrorObservable: Observable<AbstractAssetTask>;
  70950. /**
  70951. * Observable called when all tasks were executed
  70952. */
  70953. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  70954. /**
  70955. * Observable called when a task is done (whatever the result is)
  70956. */
  70957. onProgressObservable: Observable<IAssetsProgressEvent>;
  70958. /**
  70959. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  70960. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  70961. */
  70962. useDefaultLoadingScreen: boolean;
  70963. /**
  70964. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  70965. * when all assets have been downloaded.
  70966. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  70967. */
  70968. autoHideLoadingUI: boolean;
  70969. /**
  70970. * Creates a new AssetsManager
  70971. * @param scene defines the scene to work on
  70972. */
  70973. constructor(scene: Scene);
  70974. /**
  70975. * Add a MeshAssetTask to the list of active tasks
  70976. * @param taskName defines the name of the new task
  70977. * @param meshesNames defines the name of meshes to load
  70978. * @param rootUrl defines the root url to use to locate files
  70979. * @param sceneFilename defines the filename of the scene file
  70980. * @returns a new MeshAssetTask object
  70981. */
  70982. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  70983. /**
  70984. * Add a TextFileAssetTask to the list of active tasks
  70985. * @param taskName defines the name of the new task
  70986. * @param url defines the url of the file to load
  70987. * @returns a new TextFileAssetTask object
  70988. */
  70989. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  70990. /**
  70991. * Add a BinaryFileAssetTask to the list of active tasks
  70992. * @param taskName defines the name of the new task
  70993. * @param url defines the url of the file to load
  70994. * @returns a new BinaryFileAssetTask object
  70995. */
  70996. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  70997. /**
  70998. * Add a ImageAssetTask to the list of active tasks
  70999. * @param taskName defines the name of the new task
  71000. * @param url defines the url of the file to load
  71001. * @returns a new ImageAssetTask object
  71002. */
  71003. addImageTask(taskName: string, url: string): ImageAssetTask;
  71004. /**
  71005. * Add a TextureAssetTask to the list of active tasks
  71006. * @param taskName defines the name of the new task
  71007. * @param url defines the url of the file to load
  71008. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71009. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71010. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71011. * @returns a new TextureAssetTask object
  71012. */
  71013. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71014. /**
  71015. * Add a CubeTextureAssetTask to the list of active tasks
  71016. * @param taskName defines the name of the new task
  71017. * @param url defines the url of the file to load
  71018. * @param extensions defines the extension to use to load the cube map (can be null)
  71019. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71020. * @param files defines the list of files to load (can be null)
  71021. * @returns a new CubeTextureAssetTask object
  71022. */
  71023. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71024. /**
  71025. *
  71026. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71027. * @param taskName defines the name of the new task
  71028. * @param url defines the url of the file to load
  71029. * @param size defines the size you want for the cubemap (can be null)
  71030. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71031. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71032. * @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)
  71033. * @param reserved Internal use only
  71034. * @returns a new HDRCubeTextureAssetTask object
  71035. */
  71036. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71037. /**
  71038. *
  71039. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71040. * @param taskName defines the name of the new task
  71041. * @param url defines the url of the file to load
  71042. * @param size defines the size you want for the cubemap (can be null)
  71043. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71044. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71045. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71046. * @returns a new EquiRectangularCubeTextureAssetTask object
  71047. */
  71048. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71049. /**
  71050. * Remove a task from the assets manager.
  71051. * @param task the task to remove
  71052. */
  71053. removeTask(task: AbstractAssetTask): void;
  71054. private _decreaseWaitingTasksCount;
  71055. private _runTask;
  71056. /**
  71057. * Reset the AssetsManager and remove all tasks
  71058. * @return the current instance of the AssetsManager
  71059. */
  71060. reset(): AssetsManager;
  71061. /**
  71062. * Start the loading process
  71063. * @return the current instance of the AssetsManager
  71064. */
  71065. load(): AssetsManager;
  71066. /**
  71067. * Start the loading process as an async operation
  71068. * @return a promise returning the list of failed tasks
  71069. */
  71070. loadAsync(): Promise<void>;
  71071. }
  71072. }
  71073. declare module BABYLON {
  71074. /**
  71075. * Wrapper class for promise with external resolve and reject.
  71076. */
  71077. export class Deferred<T> {
  71078. /**
  71079. * The promise associated with this deferred object.
  71080. */
  71081. readonly promise: Promise<T>;
  71082. private _resolve;
  71083. private _reject;
  71084. /**
  71085. * The resolve method of the promise associated with this deferred object.
  71086. */
  71087. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71088. /**
  71089. * The reject method of the promise associated with this deferred object.
  71090. */
  71091. get reject(): (reason?: any) => void;
  71092. /**
  71093. * Constructor for this deferred object.
  71094. */
  71095. constructor();
  71096. }
  71097. }
  71098. declare module BABYLON {
  71099. /**
  71100. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71101. */
  71102. export class MeshExploder {
  71103. private _centerMesh;
  71104. private _meshes;
  71105. private _meshesOrigins;
  71106. private _toCenterVectors;
  71107. private _scaledDirection;
  71108. private _newPosition;
  71109. private _centerPosition;
  71110. /**
  71111. * Explodes meshes from a center mesh.
  71112. * @param meshes The meshes to explode.
  71113. * @param centerMesh The mesh to be center of explosion.
  71114. */
  71115. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71116. private _setCenterMesh;
  71117. /**
  71118. * Get class name
  71119. * @returns "MeshExploder"
  71120. */
  71121. getClassName(): string;
  71122. /**
  71123. * "Exploded meshes"
  71124. * @returns Array of meshes with the centerMesh at index 0.
  71125. */
  71126. getMeshes(): Array<Mesh>;
  71127. /**
  71128. * Explodes meshes giving a specific direction
  71129. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71130. */
  71131. explode(direction?: number): void;
  71132. }
  71133. }
  71134. declare module BABYLON {
  71135. /**
  71136. * Class used to help managing file picking and drag'n'drop
  71137. */
  71138. export class FilesInput {
  71139. /**
  71140. * List of files ready to be loaded
  71141. */
  71142. static get FilesToLoad(): {
  71143. [key: string]: File;
  71144. };
  71145. /**
  71146. * Callback called when a file is processed
  71147. */
  71148. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71149. private _engine;
  71150. private _currentScene;
  71151. private _sceneLoadedCallback;
  71152. private _progressCallback;
  71153. private _additionalRenderLoopLogicCallback;
  71154. private _textureLoadingCallback;
  71155. private _startingProcessingFilesCallback;
  71156. private _onReloadCallback;
  71157. private _errorCallback;
  71158. private _elementToMonitor;
  71159. private _sceneFileToLoad;
  71160. private _filesToLoad;
  71161. /**
  71162. * Creates a new FilesInput
  71163. * @param engine defines the rendering engine
  71164. * @param scene defines the hosting scene
  71165. * @param sceneLoadedCallback callback called when scene is loaded
  71166. * @param progressCallback callback called to track progress
  71167. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71168. * @param textureLoadingCallback callback called when a texture is loading
  71169. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71170. * @param onReloadCallback callback called when a reload is requested
  71171. * @param errorCallback callback call if an error occurs
  71172. */
  71173. 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);
  71174. private _dragEnterHandler;
  71175. private _dragOverHandler;
  71176. private _dropHandler;
  71177. /**
  71178. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71179. * @param elementToMonitor defines the DOM element to track
  71180. */
  71181. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71182. /**
  71183. * Release all associated resources
  71184. */
  71185. dispose(): void;
  71186. private renderFunction;
  71187. private drag;
  71188. private drop;
  71189. private _traverseFolder;
  71190. private _processFiles;
  71191. /**
  71192. * Load files from a drop event
  71193. * @param event defines the drop event to use as source
  71194. */
  71195. loadFiles(event: any): void;
  71196. private _processReload;
  71197. /**
  71198. * Reload the current scene from the loaded files
  71199. */
  71200. reload(): void;
  71201. }
  71202. }
  71203. declare module BABYLON {
  71204. /**
  71205. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71206. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71207. */
  71208. export class SceneOptimization {
  71209. /**
  71210. * Defines the priority of this optimization (0 by default which means first in the list)
  71211. */
  71212. priority: number;
  71213. /**
  71214. * Gets a string describing the action executed by the current optimization
  71215. * @returns description string
  71216. */
  71217. getDescription(): string;
  71218. /**
  71219. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71220. * @param scene defines the current scene where to apply this optimization
  71221. * @param optimizer defines the current optimizer
  71222. * @returns true if everything that can be done was applied
  71223. */
  71224. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71225. /**
  71226. * Creates the SceneOptimization object
  71227. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71228. * @param desc defines the description associated with the optimization
  71229. */
  71230. constructor(
  71231. /**
  71232. * Defines the priority of this optimization (0 by default which means first in the list)
  71233. */
  71234. priority?: number);
  71235. }
  71236. /**
  71237. * Defines an optimization used to reduce the size of render target textures
  71238. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71239. */
  71240. export class TextureOptimization extends SceneOptimization {
  71241. /**
  71242. * Defines the priority of this optimization (0 by default which means first in the list)
  71243. */
  71244. priority: number;
  71245. /**
  71246. * 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
  71247. */
  71248. maximumSize: number;
  71249. /**
  71250. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71251. */
  71252. step: number;
  71253. /**
  71254. * Gets a string describing the action executed by the current optimization
  71255. * @returns description string
  71256. */
  71257. getDescription(): string;
  71258. /**
  71259. * Creates the TextureOptimization object
  71260. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71261. * @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
  71262. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71263. */
  71264. constructor(
  71265. /**
  71266. * Defines the priority of this optimization (0 by default which means first in the list)
  71267. */
  71268. priority?: number,
  71269. /**
  71270. * 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
  71271. */
  71272. maximumSize?: number,
  71273. /**
  71274. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71275. */
  71276. step?: number);
  71277. /**
  71278. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71279. * @param scene defines the current scene where to apply this optimization
  71280. * @param optimizer defines the current optimizer
  71281. * @returns true if everything that can be done was applied
  71282. */
  71283. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71284. }
  71285. /**
  71286. * Defines an optimization used to increase or decrease the rendering resolution
  71287. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71288. */
  71289. export class HardwareScalingOptimization extends SceneOptimization {
  71290. /**
  71291. * Defines the priority of this optimization (0 by default which means first in the list)
  71292. */
  71293. priority: number;
  71294. /**
  71295. * Defines the maximum scale to use (2 by default)
  71296. */
  71297. maximumScale: number;
  71298. /**
  71299. * Defines the step to use between two passes (0.5 by default)
  71300. */
  71301. step: number;
  71302. private _currentScale;
  71303. private _directionOffset;
  71304. /**
  71305. * Gets a string describing the action executed by the current optimization
  71306. * @return description string
  71307. */
  71308. getDescription(): string;
  71309. /**
  71310. * Creates the HardwareScalingOptimization object
  71311. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71312. * @param maximumScale defines the maximum scale to use (2 by default)
  71313. * @param step defines the step to use between two passes (0.5 by default)
  71314. */
  71315. constructor(
  71316. /**
  71317. * Defines the priority of this optimization (0 by default which means first in the list)
  71318. */
  71319. priority?: number,
  71320. /**
  71321. * Defines the maximum scale to use (2 by default)
  71322. */
  71323. maximumScale?: number,
  71324. /**
  71325. * Defines the step to use between two passes (0.5 by default)
  71326. */
  71327. step?: number);
  71328. /**
  71329. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71330. * @param scene defines the current scene where to apply this optimization
  71331. * @param optimizer defines the current optimizer
  71332. * @returns true if everything that can be done was applied
  71333. */
  71334. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71335. }
  71336. /**
  71337. * Defines an optimization used to remove shadows
  71338. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71339. */
  71340. export class ShadowsOptimization extends SceneOptimization {
  71341. /**
  71342. * Gets a string describing the action executed by the current optimization
  71343. * @return description string
  71344. */
  71345. getDescription(): string;
  71346. /**
  71347. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71348. * @param scene defines the current scene where to apply this optimization
  71349. * @param optimizer defines the current optimizer
  71350. * @returns true if everything that can be done was applied
  71351. */
  71352. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71353. }
  71354. /**
  71355. * Defines an optimization used to turn post-processes off
  71356. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71357. */
  71358. export class PostProcessesOptimization extends SceneOptimization {
  71359. /**
  71360. * Gets a string describing the action executed by the current optimization
  71361. * @return description string
  71362. */
  71363. getDescription(): string;
  71364. /**
  71365. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71366. * @param scene defines the current scene where to apply this optimization
  71367. * @param optimizer defines the current optimizer
  71368. * @returns true if everything that can be done was applied
  71369. */
  71370. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71371. }
  71372. /**
  71373. * Defines an optimization used to turn lens flares off
  71374. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71375. */
  71376. export class LensFlaresOptimization extends SceneOptimization {
  71377. /**
  71378. * Gets a string describing the action executed by the current optimization
  71379. * @return description string
  71380. */
  71381. getDescription(): string;
  71382. /**
  71383. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71384. * @param scene defines the current scene where to apply this optimization
  71385. * @param optimizer defines the current optimizer
  71386. * @returns true if everything that can be done was applied
  71387. */
  71388. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71389. }
  71390. /**
  71391. * Defines an optimization based on user defined callback.
  71392. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71393. */
  71394. export class CustomOptimization extends SceneOptimization {
  71395. /**
  71396. * Callback called to apply the custom optimization.
  71397. */
  71398. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71399. /**
  71400. * Callback called to get custom description
  71401. */
  71402. onGetDescription: () => string;
  71403. /**
  71404. * Gets a string describing the action executed by the current optimization
  71405. * @returns description string
  71406. */
  71407. getDescription(): string;
  71408. /**
  71409. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71410. * @param scene defines the current scene where to apply this optimization
  71411. * @param optimizer defines the current optimizer
  71412. * @returns true if everything that can be done was applied
  71413. */
  71414. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71415. }
  71416. /**
  71417. * Defines an optimization used to turn particles off
  71418. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71419. */
  71420. export class ParticlesOptimization extends SceneOptimization {
  71421. /**
  71422. * Gets a string describing the action executed by the current optimization
  71423. * @return description string
  71424. */
  71425. getDescription(): string;
  71426. /**
  71427. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71428. * @param scene defines the current scene where to apply this optimization
  71429. * @param optimizer defines the current optimizer
  71430. * @returns true if everything that can be done was applied
  71431. */
  71432. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71433. }
  71434. /**
  71435. * Defines an optimization used to turn render targets off
  71436. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71437. */
  71438. export class RenderTargetsOptimization extends SceneOptimization {
  71439. /**
  71440. * Gets a string describing the action executed by the current optimization
  71441. * @return description string
  71442. */
  71443. getDescription(): string;
  71444. /**
  71445. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71446. * @param scene defines the current scene where to apply this optimization
  71447. * @param optimizer defines the current optimizer
  71448. * @returns true if everything that can be done was applied
  71449. */
  71450. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71451. }
  71452. /**
  71453. * Defines an optimization used to merge meshes with compatible materials
  71454. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71455. */
  71456. export class MergeMeshesOptimization extends SceneOptimization {
  71457. private static _UpdateSelectionTree;
  71458. /**
  71459. * Gets or sets a boolean which defines if optimization octree has to be updated
  71460. */
  71461. static get UpdateSelectionTree(): boolean;
  71462. /**
  71463. * Gets or sets a boolean which defines if optimization octree has to be updated
  71464. */
  71465. static set UpdateSelectionTree(value: boolean);
  71466. /**
  71467. * Gets a string describing the action executed by the current optimization
  71468. * @return description string
  71469. */
  71470. getDescription(): string;
  71471. private _canBeMerged;
  71472. /**
  71473. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71474. * @param scene defines the current scene where to apply this optimization
  71475. * @param optimizer defines the current optimizer
  71476. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71477. * @returns true if everything that can be done was applied
  71478. */
  71479. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71480. }
  71481. /**
  71482. * Defines a list of options used by SceneOptimizer
  71483. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71484. */
  71485. export class SceneOptimizerOptions {
  71486. /**
  71487. * Defines the target frame rate to reach (60 by default)
  71488. */
  71489. targetFrameRate: number;
  71490. /**
  71491. * Defines the interval between two checkes (2000ms by default)
  71492. */
  71493. trackerDuration: number;
  71494. /**
  71495. * Gets the list of optimizations to apply
  71496. */
  71497. optimizations: SceneOptimization[];
  71498. /**
  71499. * Creates a new list of options used by SceneOptimizer
  71500. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71501. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71502. */
  71503. constructor(
  71504. /**
  71505. * Defines the target frame rate to reach (60 by default)
  71506. */
  71507. targetFrameRate?: number,
  71508. /**
  71509. * Defines the interval between two checkes (2000ms by default)
  71510. */
  71511. trackerDuration?: number);
  71512. /**
  71513. * Add a new optimization
  71514. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71515. * @returns the current SceneOptimizerOptions
  71516. */
  71517. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71518. /**
  71519. * Add a new custom optimization
  71520. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71521. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71522. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71523. * @returns the current SceneOptimizerOptions
  71524. */
  71525. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71526. /**
  71527. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71528. * @param targetFrameRate defines the target frame rate (60 by default)
  71529. * @returns a SceneOptimizerOptions object
  71530. */
  71531. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71532. /**
  71533. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71534. * @param targetFrameRate defines the target frame rate (60 by default)
  71535. * @returns a SceneOptimizerOptions object
  71536. */
  71537. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71538. /**
  71539. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71540. * @param targetFrameRate defines the target frame rate (60 by default)
  71541. * @returns a SceneOptimizerOptions object
  71542. */
  71543. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71544. }
  71545. /**
  71546. * Class used to run optimizations in order to reach a target frame rate
  71547. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71548. */
  71549. export class SceneOptimizer implements IDisposable {
  71550. private _isRunning;
  71551. private _options;
  71552. private _scene;
  71553. private _currentPriorityLevel;
  71554. private _targetFrameRate;
  71555. private _trackerDuration;
  71556. private _currentFrameRate;
  71557. private _sceneDisposeObserver;
  71558. private _improvementMode;
  71559. /**
  71560. * Defines an observable called when the optimizer reaches the target frame rate
  71561. */
  71562. onSuccessObservable: Observable<SceneOptimizer>;
  71563. /**
  71564. * Defines an observable called when the optimizer enables an optimization
  71565. */
  71566. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71567. /**
  71568. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71569. */
  71570. onFailureObservable: Observable<SceneOptimizer>;
  71571. /**
  71572. * Gets a boolean indicating if the optimizer is in improvement mode
  71573. */
  71574. get isInImprovementMode(): boolean;
  71575. /**
  71576. * Gets the current priority level (0 at start)
  71577. */
  71578. get currentPriorityLevel(): number;
  71579. /**
  71580. * Gets the current frame rate checked by the SceneOptimizer
  71581. */
  71582. get currentFrameRate(): number;
  71583. /**
  71584. * Gets or sets the current target frame rate (60 by default)
  71585. */
  71586. get targetFrameRate(): number;
  71587. /**
  71588. * Gets or sets the current target frame rate (60 by default)
  71589. */
  71590. set targetFrameRate(value: number);
  71591. /**
  71592. * Gets or sets the current interval between two checks (every 2000ms by default)
  71593. */
  71594. get trackerDuration(): number;
  71595. /**
  71596. * Gets or sets the current interval between two checks (every 2000ms by default)
  71597. */
  71598. set trackerDuration(value: number);
  71599. /**
  71600. * Gets the list of active optimizations
  71601. */
  71602. get optimizations(): SceneOptimization[];
  71603. /**
  71604. * Creates a new SceneOptimizer
  71605. * @param scene defines the scene to work on
  71606. * @param options defines the options to use with the SceneOptimizer
  71607. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71608. * @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)
  71609. */
  71610. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71611. /**
  71612. * Stops the current optimizer
  71613. */
  71614. stop(): void;
  71615. /**
  71616. * Reset the optimizer to initial step (current priority level = 0)
  71617. */
  71618. reset(): void;
  71619. /**
  71620. * Start the optimizer. By default it will try to reach a specific framerate
  71621. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71622. */
  71623. start(): void;
  71624. private _checkCurrentState;
  71625. /**
  71626. * Release all resources
  71627. */
  71628. dispose(): void;
  71629. /**
  71630. * Helper function to create a SceneOptimizer with one single line of code
  71631. * @param scene defines the scene to work on
  71632. * @param options defines the options to use with the SceneOptimizer
  71633. * @param onSuccess defines a callback to call on success
  71634. * @param onFailure defines a callback to call on failure
  71635. * @returns the new SceneOptimizer object
  71636. */
  71637. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71638. }
  71639. }
  71640. declare module BABYLON {
  71641. /**
  71642. * Class used to serialize a scene into a string
  71643. */
  71644. export class SceneSerializer {
  71645. /**
  71646. * Clear cache used by a previous serialization
  71647. */
  71648. static ClearCache(): void;
  71649. /**
  71650. * Serialize a scene into a JSON compatible object
  71651. * @param scene defines the scene to serialize
  71652. * @returns a JSON compatible object
  71653. */
  71654. static Serialize(scene: Scene): any;
  71655. /**
  71656. * Serialize a mesh into a JSON compatible object
  71657. * @param toSerialize defines the mesh to serialize
  71658. * @param withParents defines if parents must be serialized as well
  71659. * @param withChildren defines if children must be serialized as well
  71660. * @returns a JSON compatible object
  71661. */
  71662. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  71663. }
  71664. }
  71665. declare module BABYLON {
  71666. /**
  71667. * Class used to host texture specific utilities
  71668. */
  71669. export class TextureTools {
  71670. /**
  71671. * Uses the GPU to create a copy texture rescaled at a given size
  71672. * @param texture Texture to copy from
  71673. * @param width defines the desired width
  71674. * @param height defines the desired height
  71675. * @param useBilinearMode defines if bilinear mode has to be used
  71676. * @return the generated texture
  71677. */
  71678. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  71679. }
  71680. }
  71681. declare module BABYLON {
  71682. /**
  71683. * This represents the different options available for the video capture.
  71684. */
  71685. export interface VideoRecorderOptions {
  71686. /** Defines the mime type of the video. */
  71687. mimeType: string;
  71688. /** Defines the FPS the video should be recorded at. */
  71689. fps: number;
  71690. /** Defines the chunk size for the recording data. */
  71691. recordChunckSize: number;
  71692. /** The audio tracks to attach to the recording. */
  71693. audioTracks?: MediaStreamTrack[];
  71694. }
  71695. /**
  71696. * This can help with recording videos from BabylonJS.
  71697. * This is based on the available WebRTC functionalities of the browser.
  71698. *
  71699. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  71700. */
  71701. export class VideoRecorder {
  71702. private static readonly _defaultOptions;
  71703. /**
  71704. * Returns whether or not the VideoRecorder is available in your browser.
  71705. * @param engine Defines the Babylon Engine.
  71706. * @returns true if supported otherwise false.
  71707. */
  71708. static IsSupported(engine: Engine): boolean;
  71709. private readonly _options;
  71710. private _canvas;
  71711. private _mediaRecorder;
  71712. private _recordedChunks;
  71713. private _fileName;
  71714. private _resolve;
  71715. private _reject;
  71716. /**
  71717. * True when a recording is already in progress.
  71718. */
  71719. get isRecording(): boolean;
  71720. /**
  71721. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  71722. * @param engine Defines the BabylonJS Engine you wish to record.
  71723. * @param options Defines options that can be used to customize the capture.
  71724. */
  71725. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  71726. /**
  71727. * Stops the current recording before the default capture timeout passed in the startRecording function.
  71728. */
  71729. stopRecording(): void;
  71730. /**
  71731. * Starts recording the canvas for a max duration specified in parameters.
  71732. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  71733. * If null no automatic download will start and you can rely on the promise to get the data back.
  71734. * @param maxDuration Defines the maximum recording time in seconds.
  71735. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  71736. * @return A promise callback at the end of the recording with the video data in Blob.
  71737. */
  71738. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  71739. /**
  71740. * Releases internal resources used during the recording.
  71741. */
  71742. dispose(): void;
  71743. private _handleDataAvailable;
  71744. private _handleError;
  71745. private _handleStop;
  71746. }
  71747. }
  71748. declare module BABYLON {
  71749. /**
  71750. * Class containing a set of static utilities functions for screenshots
  71751. */
  71752. export class ScreenshotTools {
  71753. /**
  71754. * Captures a screenshot of the current rendering
  71755. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71756. * @param engine defines the rendering engine
  71757. * @param camera defines the source camera
  71758. * @param size This parameter can be set to a single number or to an object with the
  71759. * following (optional) properties: precision, width, height. If a single number is passed,
  71760. * it will be used for both width and height. If an object is passed, the screenshot size
  71761. * will be derived from the parameters. The precision property is a multiplier allowing
  71762. * rendering at a higher or lower resolution
  71763. * @param successCallback defines the callback receives a single parameter which contains the
  71764. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71765. * src parameter of an <img> to display it
  71766. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71767. * Check your browser for supported MIME types
  71768. */
  71769. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  71770. /**
  71771. * Captures a screenshot of the current rendering
  71772. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71773. * @param engine defines the rendering engine
  71774. * @param camera defines the source camera
  71775. * @param size This parameter can be set to a single number or to an object with the
  71776. * following (optional) properties: precision, width, height. If a single number is passed,
  71777. * it will be used for both width and height. If an object is passed, the screenshot size
  71778. * will be derived from the parameters. The precision property is a multiplier allowing
  71779. * rendering at a higher or lower resolution
  71780. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71781. * Check your browser for supported MIME types
  71782. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71783. * to the src parameter of an <img> to display it
  71784. */
  71785. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  71786. /**
  71787. * Generates an image screenshot from the specified camera.
  71788. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71789. * @param engine The engine to use for rendering
  71790. * @param camera The camera to use for rendering
  71791. * @param size This parameter can be set to a single number or to an object with the
  71792. * following (optional) properties: precision, width, height. If a single number is passed,
  71793. * it will be used for both width and height. If an object is passed, the screenshot size
  71794. * will be derived from the parameters. The precision property is a multiplier allowing
  71795. * rendering at a higher or lower resolution
  71796. * @param successCallback The callback receives a single parameter which contains the
  71797. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71798. * src parameter of an <img> to display it
  71799. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71800. * Check your browser for supported MIME types
  71801. * @param samples Texture samples (default: 1)
  71802. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71803. * @param fileName A name for for the downloaded file.
  71804. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71805. */
  71806. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  71807. /**
  71808. * Generates an image screenshot from the specified camera.
  71809. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71810. * @param engine The engine to use for rendering
  71811. * @param camera The camera to use for rendering
  71812. * @param size This parameter can be set to a single number or to an object with the
  71813. * following (optional) properties: precision, width, height. If a single number is passed,
  71814. * it will be used for both width and height. If an object is passed, the screenshot size
  71815. * will be derived from the parameters. The precision property is a multiplier allowing
  71816. * rendering at a higher or lower resolution
  71817. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71818. * Check your browser for supported MIME types
  71819. * @param samples Texture samples (default: 1)
  71820. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71821. * @param fileName A name for for the downloaded file.
  71822. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71823. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71824. * to the src parameter of an <img> to display it
  71825. */
  71826. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  71827. /**
  71828. * Gets height and width for screenshot size
  71829. * @private
  71830. */
  71831. private static _getScreenshotSize;
  71832. }
  71833. }
  71834. declare module BABYLON {
  71835. /**
  71836. * Interface for a data buffer
  71837. */
  71838. export interface IDataBuffer {
  71839. /**
  71840. * Reads bytes from the data buffer.
  71841. * @param byteOffset The byte offset to read
  71842. * @param byteLength The byte length to read
  71843. * @returns A promise that resolves when the bytes are read
  71844. */
  71845. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  71846. /**
  71847. * The byte length of the buffer.
  71848. */
  71849. readonly byteLength: number;
  71850. }
  71851. /**
  71852. * Utility class for reading from a data buffer
  71853. */
  71854. export class DataReader {
  71855. /**
  71856. * The data buffer associated with this data reader.
  71857. */
  71858. readonly buffer: IDataBuffer;
  71859. /**
  71860. * The current byte offset from the beginning of the data buffer.
  71861. */
  71862. byteOffset: number;
  71863. private _dataView;
  71864. private _dataByteOffset;
  71865. /**
  71866. * Constructor
  71867. * @param buffer The buffer to read
  71868. */
  71869. constructor(buffer: IDataBuffer);
  71870. /**
  71871. * Loads the given byte length.
  71872. * @param byteLength The byte length to load
  71873. * @returns A promise that resolves when the load is complete
  71874. */
  71875. loadAsync(byteLength: number): Promise<void>;
  71876. /**
  71877. * Read a unsigned 32-bit integer from the currently loaded data range.
  71878. * @returns The 32-bit integer read
  71879. */
  71880. readUint32(): number;
  71881. /**
  71882. * Read a byte array from the currently loaded data range.
  71883. * @param byteLength The byte length to read
  71884. * @returns The byte array read
  71885. */
  71886. readUint8Array(byteLength: number): Uint8Array;
  71887. /**
  71888. * Read a string from the currently loaded data range.
  71889. * @param byteLength The byte length to read
  71890. * @returns The string read
  71891. */
  71892. readString(byteLength: number): string;
  71893. /**
  71894. * Skips the given byte length the currently loaded data range.
  71895. * @param byteLength The byte length to skip
  71896. */
  71897. skipBytes(byteLength: number): void;
  71898. }
  71899. }
  71900. declare module BABYLON {
  71901. /**
  71902. * Class for storing data to local storage if available or in-memory storage otherwise
  71903. */
  71904. export class DataStorage {
  71905. private static _Storage;
  71906. private static _GetStorage;
  71907. /**
  71908. * Reads a string from the data storage
  71909. * @param key The key to read
  71910. * @param defaultValue The value if the key doesn't exist
  71911. * @returns The string value
  71912. */
  71913. static ReadString(key: string, defaultValue: string): string;
  71914. /**
  71915. * Writes a string to the data storage
  71916. * @param key The key to write
  71917. * @param value The value to write
  71918. */
  71919. static WriteString(key: string, value: string): void;
  71920. /**
  71921. * Reads a boolean from the data storage
  71922. * @param key The key to read
  71923. * @param defaultValue The value if the key doesn't exist
  71924. * @returns The boolean value
  71925. */
  71926. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  71927. /**
  71928. * Writes a boolean to the data storage
  71929. * @param key The key to write
  71930. * @param value The value to write
  71931. */
  71932. static WriteBoolean(key: string, value: boolean): void;
  71933. /**
  71934. * Reads a number from the data storage
  71935. * @param key The key to read
  71936. * @param defaultValue The value if the key doesn't exist
  71937. * @returns The number value
  71938. */
  71939. static ReadNumber(key: string, defaultValue: number): number;
  71940. /**
  71941. * Writes a number to the data storage
  71942. * @param key The key to write
  71943. * @param value The value to write
  71944. */
  71945. static WriteNumber(key: string, value: number): void;
  71946. }
  71947. }
  71948. declare module BABYLON {
  71949. /**
  71950. * Options used for hit testing
  71951. */
  71952. export interface IWebXRLegacyHitTestOptions {
  71953. /**
  71954. * Only test when user interacted with the scene. Default - hit test every frame
  71955. */
  71956. testOnPointerDownOnly?: boolean;
  71957. /**
  71958. * The node to use to transform the local results to world coordinates
  71959. */
  71960. worldParentNode?: TransformNode;
  71961. }
  71962. /**
  71963. * Interface defining the babylon result of raycasting/hit-test
  71964. */
  71965. export interface IWebXRLegacyHitResult {
  71966. /**
  71967. * Transformation matrix that can be applied to a node that will put it in the hit point location
  71968. */
  71969. transformationMatrix: Matrix;
  71970. /**
  71971. * The native hit test result
  71972. */
  71973. xrHitResult: XRHitResult | XRHitTestResult;
  71974. }
  71975. /**
  71976. * The currently-working hit-test module.
  71977. * Hit test (or Ray-casting) is used to interact with the real world.
  71978. * For further information read here - https://github.com/immersive-web/hit-test
  71979. */
  71980. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  71981. /**
  71982. * options to use when constructing this feature
  71983. */
  71984. readonly options: IWebXRLegacyHitTestOptions;
  71985. private _direction;
  71986. private _mat;
  71987. private _onSelectEnabled;
  71988. private _origin;
  71989. /**
  71990. * The module's name
  71991. */
  71992. static readonly Name: string;
  71993. /**
  71994. * The (Babylon) version of this module.
  71995. * This is an integer representing the implementation version.
  71996. * This number does not correspond to the WebXR specs version
  71997. */
  71998. static readonly Version: number;
  71999. /**
  72000. * Populated with the last native XR Hit Results
  72001. */
  72002. lastNativeXRHitResults: XRHitResult[];
  72003. /**
  72004. * Triggered when new babylon (transformed) hit test results are available
  72005. */
  72006. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72007. /**
  72008. * Creates a new instance of the (legacy version) hit test feature
  72009. * @param _xrSessionManager an instance of WebXRSessionManager
  72010. * @param options options to use when constructing this feature
  72011. */
  72012. constructor(_xrSessionManager: WebXRSessionManager,
  72013. /**
  72014. * options to use when constructing this feature
  72015. */
  72016. options?: IWebXRLegacyHitTestOptions);
  72017. /**
  72018. * execute a hit test with an XR Ray
  72019. *
  72020. * @param xrSession a native xrSession that will execute this hit test
  72021. * @param xrRay the ray (position and direction) to use for ray-casting
  72022. * @param referenceSpace native XR reference space to use for the hit-test
  72023. * @param filter filter function that will filter the results
  72024. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72025. */
  72026. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72027. /**
  72028. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72029. * @param event the (select) event to use to select with
  72030. * @param referenceSpace the reference space to use for this hit test
  72031. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72032. */
  72033. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72034. /**
  72035. * attach this feature
  72036. * Will usually be called by the features manager
  72037. *
  72038. * @returns true if successful.
  72039. */
  72040. attach(): boolean;
  72041. /**
  72042. * detach this feature.
  72043. * Will usually be called by the features manager
  72044. *
  72045. * @returns true if successful.
  72046. */
  72047. detach(): boolean;
  72048. /**
  72049. * Dispose this feature and all of the resources attached
  72050. */
  72051. dispose(): void;
  72052. protected _onXRFrame(frame: XRFrame): void;
  72053. private _onHitTestResults;
  72054. private _onSelect;
  72055. }
  72056. }
  72057. declare module BABYLON {
  72058. /**
  72059. * Options used in the plane detector module
  72060. */
  72061. export interface IWebXRPlaneDetectorOptions {
  72062. /**
  72063. * The node to use to transform the local results to world coordinates
  72064. */
  72065. worldParentNode?: TransformNode;
  72066. }
  72067. /**
  72068. * A babylon interface for a WebXR plane.
  72069. * A Plane is actually a polygon, built from N points in space
  72070. *
  72071. * Supported in chrome 79, not supported in canary 81 ATM
  72072. */
  72073. export interface IWebXRPlane {
  72074. /**
  72075. * a babylon-assigned ID for this polygon
  72076. */
  72077. id: number;
  72078. /**
  72079. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72080. */
  72081. polygonDefinition: Array<Vector3>;
  72082. /**
  72083. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72084. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72085. */
  72086. transformationMatrix: Matrix;
  72087. /**
  72088. * the native xr-plane object
  72089. */
  72090. xrPlane: XRPlane;
  72091. }
  72092. /**
  72093. * The plane detector is used to detect planes in the real world when in AR
  72094. * For more information see https://github.com/immersive-web/real-world-geometry/
  72095. */
  72096. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72097. private _options;
  72098. private _detectedPlanes;
  72099. private _enabled;
  72100. private _lastFrameDetected;
  72101. /**
  72102. * The module's name
  72103. */
  72104. static readonly Name: string;
  72105. /**
  72106. * The (Babylon) version of this module.
  72107. * This is an integer representing the implementation version.
  72108. * This number does not correspond to the WebXR specs version
  72109. */
  72110. static readonly Version: number;
  72111. /**
  72112. * Observers registered here will be executed when a new plane was added to the session
  72113. */
  72114. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72115. /**
  72116. * Observers registered here will be executed when a plane is no longer detected in the session
  72117. */
  72118. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72119. /**
  72120. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72121. * This can execute N times every frame
  72122. */
  72123. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72124. /**
  72125. * construct a new Plane Detector
  72126. * @param _xrSessionManager an instance of xr Session manager
  72127. * @param _options configuration to use when constructing this feature
  72128. */
  72129. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72130. /**
  72131. * Dispose this feature and all of the resources attached
  72132. */
  72133. dispose(): void;
  72134. protected _onXRFrame(frame: XRFrame): void;
  72135. private _init;
  72136. private _updatePlaneWithXRPlane;
  72137. /**
  72138. * avoiding using Array.find for global support.
  72139. * @param xrPlane the plane to find in the array
  72140. */
  72141. private findIndexInPlaneArray;
  72142. }
  72143. }
  72144. declare module BABYLON {
  72145. /**
  72146. * Configuration options of the anchor system
  72147. */
  72148. export interface IWebXRAnchorSystemOptions {
  72149. /**
  72150. * Should a new anchor be added every time a select event is triggered
  72151. */
  72152. addAnchorOnSelect?: boolean;
  72153. /**
  72154. * should the anchor system use plane detection.
  72155. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72156. */
  72157. usePlaneDetection?: boolean;
  72158. /**
  72159. * a node that will be used to convert local to world coordinates
  72160. */
  72161. worldParentNode?: TransformNode;
  72162. }
  72163. /**
  72164. * A babylon container for an XR Anchor
  72165. */
  72166. export interface IWebXRAnchor {
  72167. /**
  72168. * A babylon-assigned ID for this anchor
  72169. */
  72170. id: number;
  72171. /**
  72172. * Transformation matrix to apply to an object attached to this anchor
  72173. */
  72174. transformationMatrix: Matrix;
  72175. /**
  72176. * The native anchor object
  72177. */
  72178. xrAnchor: XRAnchor;
  72179. }
  72180. /**
  72181. * An implementation of the anchor system of WebXR.
  72182. * Note that the current documented implementation is not available in any browser. Future implementations
  72183. * will use the frame to create an anchor and not the session or a detected plane
  72184. * For further information see https://github.com/immersive-web/anchors/
  72185. */
  72186. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72187. private _options;
  72188. private _enabled;
  72189. private _hitTestModule;
  72190. private _lastFrameDetected;
  72191. private _onSelect;
  72192. private _planeDetector;
  72193. private _trackedAnchors;
  72194. /**
  72195. * The module's name
  72196. */
  72197. static readonly Name: string;
  72198. /**
  72199. * The (Babylon) version of this module.
  72200. * This is an integer representing the implementation version.
  72201. * This number does not correspond to the WebXR specs version
  72202. */
  72203. static readonly Version: number;
  72204. /**
  72205. * Observers registered here will be executed when a new anchor was added to the session
  72206. */
  72207. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72208. /**
  72209. * Observers registered here will be executed when an anchor was removed from the session
  72210. */
  72211. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72212. /**
  72213. * Observers registered here will be executed when an existing anchor updates
  72214. * This can execute N times every frame
  72215. */
  72216. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72217. /**
  72218. * constructs a new anchor system
  72219. * @param _xrSessionManager an instance of WebXRSessionManager
  72220. * @param _options configuration object for this feature
  72221. */
  72222. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72223. /**
  72224. * Add anchor at a specific XR point.
  72225. *
  72226. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72227. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72228. * @returns a promise the fulfills when the anchor was created
  72229. */
  72230. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72231. /**
  72232. * attach this feature
  72233. * Will usually be called by the features manager
  72234. *
  72235. * @returns true if successful.
  72236. */
  72237. attach(): boolean;
  72238. /**
  72239. * detach this feature.
  72240. * Will usually be called by the features manager
  72241. *
  72242. * @returns true if successful.
  72243. */
  72244. detach(): boolean;
  72245. /**
  72246. * Dispose this feature and all of the resources attached
  72247. */
  72248. dispose(): void;
  72249. /**
  72250. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72251. * @param hitTestModule the hit-test module to use.
  72252. */
  72253. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72254. /**
  72255. * set the plane detector to use in order to create anchors from frames
  72256. * @param planeDetector the plane-detector module to use
  72257. * @param enable enable plane-anchors. default is true
  72258. */
  72259. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72260. protected _onXRFrame(frame: XRFrame): void;
  72261. /**
  72262. * avoiding using Array.find for global support.
  72263. * @param xrAnchor the plane to find in the array
  72264. */
  72265. private _findIndexInAnchorArray;
  72266. private _updateAnchorWithXRFrame;
  72267. }
  72268. }
  72269. declare module BABYLON {
  72270. /**
  72271. * Options interface for the background remover plugin
  72272. */
  72273. export interface IWebXRBackgroundRemoverOptions {
  72274. /**
  72275. * Further background meshes to disable when entering AR
  72276. */
  72277. backgroundMeshes?: AbstractMesh[];
  72278. /**
  72279. * flags to configure the removal of the environment helper.
  72280. * If not set, the entire background will be removed. If set, flags should be set as well.
  72281. */
  72282. environmentHelperRemovalFlags?: {
  72283. /**
  72284. * Should the skybox be removed (default false)
  72285. */
  72286. skyBox?: boolean;
  72287. /**
  72288. * Should the ground be removed (default false)
  72289. */
  72290. ground?: boolean;
  72291. };
  72292. /**
  72293. * don't disable the environment helper
  72294. */
  72295. ignoreEnvironmentHelper?: boolean;
  72296. }
  72297. /**
  72298. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72299. */
  72300. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72301. /**
  72302. * read-only options to be used in this module
  72303. */
  72304. readonly options: IWebXRBackgroundRemoverOptions;
  72305. /**
  72306. * The module's name
  72307. */
  72308. static readonly Name: string;
  72309. /**
  72310. * The (Babylon) version of this module.
  72311. * This is an integer representing the implementation version.
  72312. * This number does not correspond to the WebXR specs version
  72313. */
  72314. static readonly Version: number;
  72315. /**
  72316. * registered observers will be triggered when the background state changes
  72317. */
  72318. onBackgroundStateChangedObservable: Observable<boolean>;
  72319. /**
  72320. * constructs a new background remover module
  72321. * @param _xrSessionManager the session manager for this module
  72322. * @param options read-only options to be used in this module
  72323. */
  72324. constructor(_xrSessionManager: WebXRSessionManager,
  72325. /**
  72326. * read-only options to be used in this module
  72327. */
  72328. options?: IWebXRBackgroundRemoverOptions);
  72329. /**
  72330. * attach this feature
  72331. * Will usually be called by the features manager
  72332. *
  72333. * @returns true if successful.
  72334. */
  72335. attach(): boolean;
  72336. /**
  72337. * detach this feature.
  72338. * Will usually be called by the features manager
  72339. *
  72340. * @returns true if successful.
  72341. */
  72342. detach(): boolean;
  72343. /**
  72344. * Dispose this feature and all of the resources attached
  72345. */
  72346. dispose(): void;
  72347. protected _onXRFrame(_xrFrame: XRFrame): void;
  72348. private _setBackgroundState;
  72349. }
  72350. }
  72351. declare module BABYLON {
  72352. /**
  72353. * Options for the controller physics feature
  72354. */
  72355. export class IWebXRControllerPhysicsOptions {
  72356. /**
  72357. * Should the headset get its own impostor
  72358. */
  72359. enableHeadsetImpostor?: boolean;
  72360. /**
  72361. * Optional parameters for the headset impostor
  72362. */
  72363. headsetImpostorParams?: {
  72364. /**
  72365. * The type of impostor to create. Default is sphere
  72366. */
  72367. impostorType: number;
  72368. /**
  72369. * the size of the impostor. Defaults to 10cm
  72370. */
  72371. impostorSize?: number | {
  72372. width: number;
  72373. height: number;
  72374. depth: number;
  72375. };
  72376. /**
  72377. * Friction definitions
  72378. */
  72379. friction?: number;
  72380. /**
  72381. * Restitution
  72382. */
  72383. restitution?: number;
  72384. };
  72385. /**
  72386. * The physics properties of the future impostors
  72387. */
  72388. physicsProperties?: {
  72389. /**
  72390. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72391. * Note that this requires a physics engine that supports mesh impostors!
  72392. */
  72393. useControllerMesh?: boolean;
  72394. /**
  72395. * The type of impostor to create. Default is sphere
  72396. */
  72397. impostorType?: number;
  72398. /**
  72399. * the size of the impostor. Defaults to 10cm
  72400. */
  72401. impostorSize?: number | {
  72402. width: number;
  72403. height: number;
  72404. depth: number;
  72405. };
  72406. /**
  72407. * Friction definitions
  72408. */
  72409. friction?: number;
  72410. /**
  72411. * Restitution
  72412. */
  72413. restitution?: number;
  72414. };
  72415. /**
  72416. * the xr input to use with this pointer selection
  72417. */
  72418. xrInput: WebXRInput;
  72419. }
  72420. /**
  72421. * Add physics impostor to your webxr controllers,
  72422. * including naive calculation of their linear and angular velocity
  72423. */
  72424. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72425. private readonly _options;
  72426. private _attachController;
  72427. private _controllers;
  72428. private _debugMode;
  72429. private _delta;
  72430. private _headsetImpostor?;
  72431. private _headsetMesh?;
  72432. private _lastTimestamp;
  72433. private _tmpQuaternion;
  72434. private _tmpVector;
  72435. /**
  72436. * The module's name
  72437. */
  72438. static readonly Name: string;
  72439. /**
  72440. * The (Babylon) version of this module.
  72441. * This is an integer representing the implementation version.
  72442. * This number does not correspond to the webxr specs version
  72443. */
  72444. static readonly Version: number;
  72445. /**
  72446. * Construct a new Controller Physics Feature
  72447. * @param _xrSessionManager the corresponding xr session manager
  72448. * @param _options options to create this feature with
  72449. */
  72450. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72451. /**
  72452. * @hidden
  72453. * enable debugging - will show console outputs and the impostor mesh
  72454. */
  72455. _enablePhysicsDebug(): void;
  72456. /**
  72457. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72458. * @param xrController the controller to add
  72459. */
  72460. addController(xrController: WebXRInputSource): void;
  72461. /**
  72462. * attach this feature
  72463. * Will usually be called by the features manager
  72464. *
  72465. * @returns true if successful.
  72466. */
  72467. attach(): boolean;
  72468. /**
  72469. * detach this feature.
  72470. * Will usually be called by the features manager
  72471. *
  72472. * @returns true if successful.
  72473. */
  72474. detach(): boolean;
  72475. /**
  72476. * Get the headset impostor, if enabled
  72477. * @returns the impostor
  72478. */
  72479. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72480. /**
  72481. * Get the physics impostor of a specific controller.
  72482. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72483. * @param controller the controller or the controller id of which to get the impostor
  72484. * @returns the impostor or null
  72485. */
  72486. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72487. /**
  72488. * Update the physics properties provided in the constructor
  72489. * @param newProperties the new properties object
  72490. */
  72491. setPhysicsProperties(newProperties: {
  72492. impostorType?: number;
  72493. impostorSize?: number | {
  72494. width: number;
  72495. height: number;
  72496. depth: number;
  72497. };
  72498. friction?: number;
  72499. restitution?: number;
  72500. }): void;
  72501. protected _onXRFrame(_xrFrame: any): void;
  72502. private _detachController;
  72503. }
  72504. }
  72505. declare module BABYLON {
  72506. /**
  72507. * Options used for hit testing (version 2)
  72508. */
  72509. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72510. /**
  72511. * Do not create a permanent hit test. Will usually be used when only
  72512. * transient inputs are needed.
  72513. */
  72514. disablePermanentHitTest?: boolean;
  72515. /**
  72516. * Enable transient (for example touch-based) hit test inspections
  72517. */
  72518. enableTransientHitTest?: boolean;
  72519. /**
  72520. * Offset ray for the permanent hit test
  72521. */
  72522. offsetRay?: Vector3;
  72523. /**
  72524. * Offset ray for the transient hit test
  72525. */
  72526. transientOffsetRay?: Vector3;
  72527. /**
  72528. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72529. */
  72530. useReferenceSpace?: boolean;
  72531. }
  72532. /**
  72533. * Interface defining the babylon result of hit-test
  72534. */
  72535. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72536. /**
  72537. * The input source that generated this hit test (if transient)
  72538. */
  72539. inputSource?: XRInputSource;
  72540. /**
  72541. * Is this a transient hit test
  72542. */
  72543. isTransient?: boolean;
  72544. /**
  72545. * Position of the hit test result
  72546. */
  72547. position: Vector3;
  72548. /**
  72549. * Rotation of the hit test result
  72550. */
  72551. rotationQuaternion: Quaternion;
  72552. }
  72553. /**
  72554. * The currently-working hit-test module.
  72555. * Hit test (or Ray-casting) is used to interact with the real world.
  72556. * For further information read here - https://github.com/immersive-web/hit-test
  72557. *
  72558. * Tested on chrome (mobile) 80.
  72559. */
  72560. export class WebXRHitTest extends WebXRAbstractFeature {
  72561. /**
  72562. * options to use when constructing this feature
  72563. */
  72564. readonly options: IWebXRHitTestOptions;
  72565. private _tmpMat;
  72566. private _tmpPos;
  72567. private _tmpQuat;
  72568. private _transientXrHitTestSource;
  72569. private _xrHitTestSource;
  72570. private initHitTestSource;
  72571. /**
  72572. * The module's name
  72573. */
  72574. static readonly Name: string;
  72575. /**
  72576. * The (Babylon) version of this module.
  72577. * This is an integer representing the implementation version.
  72578. * This number does not correspond to the WebXR specs version
  72579. */
  72580. static readonly Version: number;
  72581. /**
  72582. * When set to true, each hit test will have its own position/rotation objects
  72583. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72584. * the developers will clone them or copy them as they see fit.
  72585. */
  72586. autoCloneTransformation: boolean;
  72587. /**
  72588. * Populated with the last native XR Hit Results
  72589. */
  72590. lastNativeXRHitResults: XRHitResult[];
  72591. /**
  72592. * Triggered when new babylon (transformed) hit test results are available
  72593. */
  72594. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72595. /**
  72596. * Use this to temporarily pause hit test checks.
  72597. */
  72598. paused: boolean;
  72599. /**
  72600. * Creates a new instance of the hit test feature
  72601. * @param _xrSessionManager an instance of WebXRSessionManager
  72602. * @param options options to use when constructing this feature
  72603. */
  72604. constructor(_xrSessionManager: WebXRSessionManager,
  72605. /**
  72606. * options to use when constructing this feature
  72607. */
  72608. options?: IWebXRHitTestOptions);
  72609. /**
  72610. * attach this feature
  72611. * Will usually be called by the features manager
  72612. *
  72613. * @returns true if successful.
  72614. */
  72615. attach(): boolean;
  72616. /**
  72617. * detach this feature.
  72618. * Will usually be called by the features manager
  72619. *
  72620. * @returns true if successful.
  72621. */
  72622. detach(): boolean;
  72623. /**
  72624. * Dispose this feature and all of the resources attached
  72625. */
  72626. dispose(): void;
  72627. protected _onXRFrame(frame: XRFrame): void;
  72628. private _processWebXRHitTestResult;
  72629. }
  72630. }
  72631. declare module BABYLON {
  72632. /**
  72633. * The motion controller class for all microsoft mixed reality controllers
  72634. */
  72635. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72636. protected readonly _mapping: {
  72637. defaultButton: {
  72638. valueNodeName: string;
  72639. unpressedNodeName: string;
  72640. pressedNodeName: string;
  72641. };
  72642. defaultAxis: {
  72643. valueNodeName: string;
  72644. minNodeName: string;
  72645. maxNodeName: string;
  72646. };
  72647. buttons: {
  72648. "xr-standard-trigger": {
  72649. rootNodeName: string;
  72650. componentProperty: string;
  72651. states: string[];
  72652. };
  72653. "xr-standard-squeeze": {
  72654. rootNodeName: string;
  72655. componentProperty: string;
  72656. states: string[];
  72657. };
  72658. "xr-standard-touchpad": {
  72659. rootNodeName: string;
  72660. labelAnchorNodeName: string;
  72661. touchPointNodeName: string;
  72662. };
  72663. "xr-standard-thumbstick": {
  72664. rootNodeName: string;
  72665. componentProperty: string;
  72666. states: string[];
  72667. };
  72668. };
  72669. axes: {
  72670. "xr-standard-touchpad": {
  72671. "x-axis": {
  72672. rootNodeName: string;
  72673. };
  72674. "y-axis": {
  72675. rootNodeName: string;
  72676. };
  72677. };
  72678. "xr-standard-thumbstick": {
  72679. "x-axis": {
  72680. rootNodeName: string;
  72681. };
  72682. "y-axis": {
  72683. rootNodeName: string;
  72684. };
  72685. };
  72686. };
  72687. };
  72688. /**
  72689. * The base url used to load the left and right controller models
  72690. */
  72691. static MODEL_BASE_URL: string;
  72692. /**
  72693. * The name of the left controller model file
  72694. */
  72695. static MODEL_LEFT_FILENAME: string;
  72696. /**
  72697. * The name of the right controller model file
  72698. */
  72699. static MODEL_RIGHT_FILENAME: string;
  72700. profileId: string;
  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. * The motion controller class for oculus touch (quest, rift).
  72715. * This class supports legacy mapping as well the standard xr mapping
  72716. */
  72717. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72718. private _forceLegacyControllers;
  72719. private _modelRootNode;
  72720. /**
  72721. * The base url used to load the left and right controller models
  72722. */
  72723. static MODEL_BASE_URL: string;
  72724. /**
  72725. * The name of the left controller model file
  72726. */
  72727. static MODEL_LEFT_FILENAME: string;
  72728. /**
  72729. * The name of the right controller model file
  72730. */
  72731. static MODEL_RIGHT_FILENAME: string;
  72732. /**
  72733. * Base Url for the Quest controller model.
  72734. */
  72735. static QUEST_MODEL_BASE_URL: string;
  72736. profileId: string;
  72737. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  72738. protected _getFilenameAndPath(): {
  72739. filename: string;
  72740. path: string;
  72741. };
  72742. protected _getModelLoadingConstraints(): boolean;
  72743. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72744. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72745. protected _updateModel(): void;
  72746. /**
  72747. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  72748. * between the touch and touch 2.
  72749. */
  72750. private _isQuest;
  72751. }
  72752. }
  72753. declare module BABYLON {
  72754. /**
  72755. * The motion controller class for the standard HTC-Vive controllers
  72756. */
  72757. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  72758. private _modelRootNode;
  72759. /**
  72760. * The base url used to load the left and right controller models
  72761. */
  72762. static MODEL_BASE_URL: string;
  72763. /**
  72764. * File name for the controller model.
  72765. */
  72766. static MODEL_FILENAME: string;
  72767. profileId: string;
  72768. /**
  72769. * Create a new Vive motion controller object
  72770. * @param scene the scene to use to create this controller
  72771. * @param gamepadObject the corresponding gamepad object
  72772. * @param handedness the handedness of the controller
  72773. */
  72774. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72775. protected _getFilenameAndPath(): {
  72776. filename: string;
  72777. path: string;
  72778. };
  72779. protected _getModelLoadingConstraints(): boolean;
  72780. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72781. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72782. protected _updateModel(): void;
  72783. }
  72784. }
  72785. declare module BABYLON {
  72786. /**
  72787. * A cursor which tracks a point on a path
  72788. */
  72789. export class PathCursor {
  72790. private path;
  72791. /**
  72792. * Stores path cursor callbacks for when an onchange event is triggered
  72793. */
  72794. private _onchange;
  72795. /**
  72796. * The value of the path cursor
  72797. */
  72798. value: number;
  72799. /**
  72800. * The animation array of the path cursor
  72801. */
  72802. animations: Animation[];
  72803. /**
  72804. * Initializes the path cursor
  72805. * @param path The path to track
  72806. */
  72807. constructor(path: Path2);
  72808. /**
  72809. * Gets the cursor point on the path
  72810. * @returns A point on the path cursor at the cursor location
  72811. */
  72812. getPoint(): Vector3;
  72813. /**
  72814. * Moves the cursor ahead by the step amount
  72815. * @param step The amount to move the cursor forward
  72816. * @returns This path cursor
  72817. */
  72818. moveAhead(step?: number): PathCursor;
  72819. /**
  72820. * Moves the cursor behind by the step amount
  72821. * @param step The amount to move the cursor back
  72822. * @returns This path cursor
  72823. */
  72824. moveBack(step?: number): PathCursor;
  72825. /**
  72826. * Moves the cursor by the step amount
  72827. * If the step amount is greater than one, an exception is thrown
  72828. * @param step The amount to move the cursor
  72829. * @returns This path cursor
  72830. */
  72831. move(step: number): PathCursor;
  72832. /**
  72833. * Ensures that the value is limited between zero and one
  72834. * @returns This path cursor
  72835. */
  72836. private ensureLimits;
  72837. /**
  72838. * Runs onchange callbacks on change (used by the animation engine)
  72839. * @returns This path cursor
  72840. */
  72841. private raiseOnChange;
  72842. /**
  72843. * Executes a function on change
  72844. * @param f A path cursor onchange callback
  72845. * @returns This path cursor
  72846. */
  72847. onchange(f: (cursor: PathCursor) => void): PathCursor;
  72848. }
  72849. }
  72850. declare module BABYLON {
  72851. /** @hidden */
  72852. export var blurPixelShader: {
  72853. name: string;
  72854. shader: string;
  72855. };
  72856. }
  72857. declare module BABYLON {
  72858. /** @hidden */
  72859. export var pointCloudVertexDeclaration: {
  72860. name: string;
  72861. shader: string;
  72862. };
  72863. }
  72864. // Mixins
  72865. interface Window {
  72866. mozIndexedDB: IDBFactory;
  72867. webkitIndexedDB: IDBFactory;
  72868. msIndexedDB: IDBFactory;
  72869. webkitURL: typeof URL;
  72870. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  72871. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  72872. WebGLRenderingContext: WebGLRenderingContext;
  72873. MSGesture: MSGesture;
  72874. CANNON: any;
  72875. AudioContext: AudioContext;
  72876. webkitAudioContext: AudioContext;
  72877. PointerEvent: any;
  72878. Math: Math;
  72879. Uint8Array: Uint8ArrayConstructor;
  72880. Float32Array: Float32ArrayConstructor;
  72881. mozURL: typeof URL;
  72882. msURL: typeof URL;
  72883. VRFrameData: any; // WebVR, from specs 1.1
  72884. DracoDecoderModule: any;
  72885. setImmediate(handler: (...args: any[]) => void): number;
  72886. }
  72887. interface HTMLCanvasElement {
  72888. requestPointerLock(): void;
  72889. msRequestPointerLock?(): void;
  72890. mozRequestPointerLock?(): void;
  72891. webkitRequestPointerLock?(): void;
  72892. /** Track wether a record is in progress */
  72893. isRecording: boolean;
  72894. /** Capture Stream method defined by some browsers */
  72895. captureStream(fps?: number): MediaStream;
  72896. }
  72897. interface CanvasRenderingContext2D {
  72898. msImageSmoothingEnabled: boolean;
  72899. }
  72900. interface MouseEvent {
  72901. mozMovementX: number;
  72902. mozMovementY: number;
  72903. webkitMovementX: number;
  72904. webkitMovementY: number;
  72905. msMovementX: number;
  72906. msMovementY: number;
  72907. }
  72908. interface Navigator {
  72909. mozGetVRDevices: (any: any) => any;
  72910. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72911. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72912. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72913. webkitGetGamepads(): Gamepad[];
  72914. msGetGamepads(): Gamepad[];
  72915. webkitGamepads(): Gamepad[];
  72916. }
  72917. interface HTMLVideoElement {
  72918. mozSrcObject: any;
  72919. }
  72920. interface Math {
  72921. fround(x: number): number;
  72922. imul(a: number, b: number): number;
  72923. }
  72924. interface WebGLRenderingContext {
  72925. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  72926. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  72927. vertexAttribDivisor(index: number, divisor: number): void;
  72928. createVertexArray(): any;
  72929. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  72930. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  72931. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  72932. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  72933. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  72934. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  72935. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  72936. // Queries
  72937. createQuery(): WebGLQuery;
  72938. deleteQuery(query: WebGLQuery): void;
  72939. beginQuery(target: number, query: WebGLQuery): void;
  72940. endQuery(target: number): void;
  72941. getQueryParameter(query: WebGLQuery, pname: number): any;
  72942. getQuery(target: number, pname: number): any;
  72943. MAX_SAMPLES: number;
  72944. RGBA8: number;
  72945. READ_FRAMEBUFFER: number;
  72946. DRAW_FRAMEBUFFER: number;
  72947. UNIFORM_BUFFER: number;
  72948. HALF_FLOAT_OES: number;
  72949. RGBA16F: number;
  72950. RGBA32F: number;
  72951. R32F: number;
  72952. RG32F: number;
  72953. RGB32F: number;
  72954. R16F: number;
  72955. RG16F: number;
  72956. RGB16F: number;
  72957. RED: number;
  72958. RG: number;
  72959. R8: number;
  72960. RG8: number;
  72961. UNSIGNED_INT_24_8: number;
  72962. DEPTH24_STENCIL8: number;
  72963. MIN: number;
  72964. MAX: number;
  72965. /* Multiple Render Targets */
  72966. drawBuffers(buffers: number[]): void;
  72967. readBuffer(src: number): void;
  72968. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  72969. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  72970. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  72971. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  72972. // Occlusion Query
  72973. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  72974. ANY_SAMPLES_PASSED: number;
  72975. QUERY_RESULT_AVAILABLE: number;
  72976. QUERY_RESULT: number;
  72977. }
  72978. interface WebGLProgram {
  72979. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  72980. }
  72981. interface EXT_disjoint_timer_query {
  72982. QUERY_COUNTER_BITS_EXT: number;
  72983. TIME_ELAPSED_EXT: number;
  72984. TIMESTAMP_EXT: number;
  72985. GPU_DISJOINT_EXT: number;
  72986. QUERY_RESULT_EXT: number;
  72987. QUERY_RESULT_AVAILABLE_EXT: number;
  72988. queryCounterEXT(query: WebGLQuery, target: number): void;
  72989. createQueryEXT(): WebGLQuery;
  72990. beginQueryEXT(target: number, query: WebGLQuery): void;
  72991. endQueryEXT(target: number): void;
  72992. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  72993. deleteQueryEXT(query: WebGLQuery): void;
  72994. }
  72995. interface WebGLUniformLocation {
  72996. _currentState: any;
  72997. }
  72998. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  72999. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73000. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73001. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73002. interface WebGLRenderingContext {
  73003. readonly RASTERIZER_DISCARD: number;
  73004. readonly DEPTH_COMPONENT24: number;
  73005. readonly TEXTURE_3D: number;
  73006. readonly TEXTURE_2D_ARRAY: number;
  73007. readonly TEXTURE_COMPARE_FUNC: number;
  73008. readonly TEXTURE_COMPARE_MODE: number;
  73009. readonly COMPARE_REF_TO_TEXTURE: number;
  73010. readonly TEXTURE_WRAP_R: number;
  73011. readonly HALF_FLOAT: number;
  73012. readonly RGB8: number;
  73013. readonly RED_INTEGER: number;
  73014. readonly RG_INTEGER: number;
  73015. readonly RGB_INTEGER: number;
  73016. readonly RGBA_INTEGER: number;
  73017. readonly R8_SNORM: number;
  73018. readonly RG8_SNORM: number;
  73019. readonly RGB8_SNORM: number;
  73020. readonly RGBA8_SNORM: number;
  73021. readonly R8I: number;
  73022. readonly RG8I: number;
  73023. readonly RGB8I: number;
  73024. readonly RGBA8I: number;
  73025. readonly R8UI: number;
  73026. readonly RG8UI: number;
  73027. readonly RGB8UI: number;
  73028. readonly RGBA8UI: number;
  73029. readonly R16I: number;
  73030. readonly RG16I: number;
  73031. readonly RGB16I: number;
  73032. readonly RGBA16I: number;
  73033. readonly R16UI: number;
  73034. readonly RG16UI: number;
  73035. readonly RGB16UI: number;
  73036. readonly RGBA16UI: number;
  73037. readonly R32I: number;
  73038. readonly RG32I: number;
  73039. readonly RGB32I: number;
  73040. readonly RGBA32I: number;
  73041. readonly R32UI: number;
  73042. readonly RG32UI: number;
  73043. readonly RGB32UI: number;
  73044. readonly RGBA32UI: number;
  73045. readonly RGB10_A2UI: number;
  73046. readonly R11F_G11F_B10F: number;
  73047. readonly RGB9_E5: number;
  73048. readonly RGB10_A2: number;
  73049. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73050. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73051. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73052. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73053. readonly DEPTH_COMPONENT32F: number;
  73054. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73055. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73056. 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;
  73057. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73058. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73059. readonly TRANSFORM_FEEDBACK: number;
  73060. readonly INTERLEAVED_ATTRIBS: number;
  73061. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73062. createTransformFeedback(): WebGLTransformFeedback;
  73063. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73064. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73065. beginTransformFeedback(primitiveMode: number): void;
  73066. endTransformFeedback(): void;
  73067. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73068. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73069. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73070. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73071. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73072. }
  73073. interface ImageBitmap {
  73074. readonly width: number;
  73075. readonly height: number;
  73076. close(): void;
  73077. }
  73078. interface WebGLQuery extends WebGLObject {
  73079. }
  73080. declare var WebGLQuery: {
  73081. prototype: WebGLQuery;
  73082. new(): WebGLQuery;
  73083. };
  73084. interface WebGLSampler extends WebGLObject {
  73085. }
  73086. declare var WebGLSampler: {
  73087. prototype: WebGLSampler;
  73088. new(): WebGLSampler;
  73089. };
  73090. interface WebGLSync extends WebGLObject {
  73091. }
  73092. declare var WebGLSync: {
  73093. prototype: WebGLSync;
  73094. new(): WebGLSync;
  73095. };
  73096. interface WebGLTransformFeedback extends WebGLObject {
  73097. }
  73098. declare var WebGLTransformFeedback: {
  73099. prototype: WebGLTransformFeedback;
  73100. new(): WebGLTransformFeedback;
  73101. };
  73102. interface WebGLVertexArrayObject extends WebGLObject {
  73103. }
  73104. declare var WebGLVertexArrayObject: {
  73105. prototype: WebGLVertexArrayObject;
  73106. new(): WebGLVertexArrayObject;
  73107. };
  73108. // Type definitions for WebVR API
  73109. // Project: https://w3c.github.io/webvr/
  73110. // Definitions by: six a <https://github.com/lostfictions>
  73111. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73112. interface VRDisplay extends EventTarget {
  73113. /**
  73114. * Dictionary of capabilities describing the VRDisplay.
  73115. */
  73116. readonly capabilities: VRDisplayCapabilities;
  73117. /**
  73118. * z-depth defining the far plane of the eye view frustum
  73119. * enables mapping of values in the render target depth
  73120. * attachment to scene coordinates. Initially set to 10000.0.
  73121. */
  73122. depthFar: number;
  73123. /**
  73124. * z-depth defining the near plane of the eye view frustum
  73125. * enables mapping of values in the render target depth
  73126. * attachment to scene coordinates. Initially set to 0.01.
  73127. */
  73128. depthNear: number;
  73129. /**
  73130. * An identifier for this distinct VRDisplay. Used as an
  73131. * association point in the Gamepad API.
  73132. */
  73133. readonly displayId: number;
  73134. /**
  73135. * A display name, a user-readable name identifying it.
  73136. */
  73137. readonly displayName: string;
  73138. readonly isConnected: boolean;
  73139. readonly isPresenting: boolean;
  73140. /**
  73141. * If this VRDisplay supports room-scale experiences, the optional
  73142. * stage attribute contains details on the room-scale parameters.
  73143. */
  73144. readonly stageParameters: VRStageParameters | null;
  73145. /**
  73146. * Passing the value returned by `requestAnimationFrame` to
  73147. * `cancelAnimationFrame` will unregister the callback.
  73148. * @param handle Define the hanle of the request to cancel
  73149. */
  73150. cancelAnimationFrame(handle: number): void;
  73151. /**
  73152. * Stops presenting to the VRDisplay.
  73153. * @returns a promise to know when it stopped
  73154. */
  73155. exitPresent(): Promise<void>;
  73156. /**
  73157. * Return the current VREyeParameters for the given eye.
  73158. * @param whichEye Define the eye we want the parameter for
  73159. * @returns the eye parameters
  73160. */
  73161. getEyeParameters(whichEye: string): VREyeParameters;
  73162. /**
  73163. * Populates the passed VRFrameData with the information required to render
  73164. * the current frame.
  73165. * @param frameData Define the data structure to populate
  73166. * @returns true if ok otherwise false
  73167. */
  73168. getFrameData(frameData: VRFrameData): boolean;
  73169. /**
  73170. * Get the layers currently being presented.
  73171. * @returns the list of VR layers
  73172. */
  73173. getLayers(): VRLayer[];
  73174. /**
  73175. * Return a VRPose containing the future predicted pose of the VRDisplay
  73176. * when the current frame will be presented. The value returned will not
  73177. * change until JavaScript has returned control to the browser.
  73178. *
  73179. * The VRPose will contain the position, orientation, velocity,
  73180. * and acceleration of each of these properties.
  73181. * @returns the pose object
  73182. */
  73183. getPose(): VRPose;
  73184. /**
  73185. * Return the current instantaneous pose of the VRDisplay, with no
  73186. * prediction applied.
  73187. * @returns the current instantaneous pose
  73188. */
  73189. getImmediatePose(): VRPose;
  73190. /**
  73191. * The callback passed to `requestAnimationFrame` will be called
  73192. * any time a new frame should be rendered. When the VRDisplay is
  73193. * presenting the callback will be called at the native refresh
  73194. * rate of the HMD. When not presenting this function acts
  73195. * identically to how window.requestAnimationFrame acts. Content should
  73196. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73197. * asynchronously from other displays and at differing refresh rates.
  73198. * @param callback Define the eaction to run next frame
  73199. * @returns the request handle it
  73200. */
  73201. requestAnimationFrame(callback: FrameRequestCallback): number;
  73202. /**
  73203. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73204. * Repeat calls while already presenting will update the VRLayers being displayed.
  73205. * @param layers Define the list of layer to present
  73206. * @returns a promise to know when the request has been fulfilled
  73207. */
  73208. requestPresent(layers: VRLayer[]): Promise<void>;
  73209. /**
  73210. * Reset the pose for this display, treating its current position and
  73211. * orientation as the "origin/zero" values. VRPose.position,
  73212. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73213. * updated when calling resetPose(). This should be called in only
  73214. * sitting-space experiences.
  73215. */
  73216. resetPose(): void;
  73217. /**
  73218. * The VRLayer provided to the VRDisplay will be captured and presented
  73219. * in the HMD. Calling this function has the same effect on the source
  73220. * canvas as any other operation that uses its source image, and canvases
  73221. * created without preserveDrawingBuffer set to true will be cleared.
  73222. * @param pose Define the pose to submit
  73223. */
  73224. submitFrame(pose?: VRPose): void;
  73225. }
  73226. declare var VRDisplay: {
  73227. prototype: VRDisplay;
  73228. new(): VRDisplay;
  73229. };
  73230. interface VRLayer {
  73231. leftBounds?: number[] | Float32Array | null;
  73232. rightBounds?: number[] | Float32Array | null;
  73233. source?: HTMLCanvasElement | null;
  73234. }
  73235. interface VRDisplayCapabilities {
  73236. readonly canPresent: boolean;
  73237. readonly hasExternalDisplay: boolean;
  73238. readonly hasOrientation: boolean;
  73239. readonly hasPosition: boolean;
  73240. readonly maxLayers: number;
  73241. }
  73242. interface VREyeParameters {
  73243. /** @deprecated */
  73244. readonly fieldOfView: VRFieldOfView;
  73245. readonly offset: Float32Array;
  73246. readonly renderHeight: number;
  73247. readonly renderWidth: number;
  73248. }
  73249. interface VRFieldOfView {
  73250. readonly downDegrees: number;
  73251. readonly leftDegrees: number;
  73252. readonly rightDegrees: number;
  73253. readonly upDegrees: number;
  73254. }
  73255. interface VRFrameData {
  73256. readonly leftProjectionMatrix: Float32Array;
  73257. readonly leftViewMatrix: Float32Array;
  73258. readonly pose: VRPose;
  73259. readonly rightProjectionMatrix: Float32Array;
  73260. readonly rightViewMatrix: Float32Array;
  73261. readonly timestamp: number;
  73262. }
  73263. interface VRPose {
  73264. readonly angularAcceleration: Float32Array | null;
  73265. readonly angularVelocity: Float32Array | null;
  73266. readonly linearAcceleration: Float32Array | null;
  73267. readonly linearVelocity: Float32Array | null;
  73268. readonly orientation: Float32Array | null;
  73269. readonly position: Float32Array | null;
  73270. readonly timestamp: number;
  73271. }
  73272. interface VRStageParameters {
  73273. sittingToStandingTransform?: Float32Array;
  73274. sizeX?: number;
  73275. sizeY?: number;
  73276. }
  73277. interface Navigator {
  73278. getVRDisplays(): Promise<VRDisplay[]>;
  73279. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73280. }
  73281. interface Window {
  73282. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73283. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73284. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73285. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73286. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73287. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73288. }
  73289. interface Gamepad {
  73290. readonly displayId: number;
  73291. }
  73292. type XRSessionMode =
  73293. | "inline"
  73294. | "immersive-vr"
  73295. | "immersive-ar";
  73296. type XRReferenceSpaceType =
  73297. | "viewer"
  73298. | "local"
  73299. | "local-floor"
  73300. | "bounded-floor"
  73301. | "unbounded";
  73302. type XREnvironmentBlendMode =
  73303. | "opaque"
  73304. | "additive"
  73305. | "alpha-blend";
  73306. type XRVisibilityState =
  73307. | "visible"
  73308. | "visible-blurred"
  73309. | "hidden";
  73310. type XRHandedness =
  73311. | "none"
  73312. | "left"
  73313. | "right";
  73314. type XRTargetRayMode =
  73315. | "gaze"
  73316. | "tracked-pointer"
  73317. | "screen";
  73318. type XREye =
  73319. | "none"
  73320. | "left"
  73321. | "right";
  73322. type XREventType =
  73323. | "devicechange"
  73324. | "visibilitychange"
  73325. | "end"
  73326. | "inputsourceschange"
  73327. | "select"
  73328. | "selectstart"
  73329. | "selectend"
  73330. | "squeeze"
  73331. | "squeezestart"
  73332. | "squeezeend"
  73333. | "reset";
  73334. interface XRSpace extends EventTarget {
  73335. }
  73336. interface XRRenderState {
  73337. depthNear?: number;
  73338. depthFar?: number;
  73339. inlineVerticalFieldOfView?: number;
  73340. baseLayer?: XRWebGLLayer;
  73341. }
  73342. interface XRInputSource {
  73343. handedness: XRHandedness;
  73344. targetRayMode: XRTargetRayMode;
  73345. targetRaySpace: XRSpace;
  73346. gripSpace: XRSpace | undefined;
  73347. gamepad: Gamepad | undefined;
  73348. profiles: Array<string>;
  73349. }
  73350. interface XRSessionInit {
  73351. optionalFeatures?: string[];
  73352. requiredFeatures?: string[];
  73353. }
  73354. interface XRSession extends XRAnchorCreator {
  73355. addEventListener: Function;
  73356. removeEventListener: Function;
  73357. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  73358. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  73359. requestAnimationFrame: Function;
  73360. end(): Promise<void>;
  73361. renderState: XRRenderState;
  73362. inputSources: Array<XRInputSource>;
  73363. // hit test
  73364. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  73365. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  73366. // legacy AR hit test
  73367. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73368. // legacy plane detection
  73369. updateWorldTrackingState(options: {
  73370. planeDetectionState?: { enabled: boolean; }
  73371. }): void;
  73372. }
  73373. interface XRReferenceSpace extends XRSpace {
  73374. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  73375. onreset: any;
  73376. }
  73377. type XRPlaneSet = Set<XRPlane>;
  73378. type XRAnchorSet = Set<XRAnchor>;
  73379. interface XRFrame {
  73380. session: XRSession;
  73381. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  73382. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  73383. // AR
  73384. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  73385. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  73386. // Anchors
  73387. trackedAnchors?: XRAnchorSet;
  73388. // Planes
  73389. worldInformation: {
  73390. detectedPlanes?: XRPlaneSet;
  73391. };
  73392. }
  73393. interface XRViewerPose extends XRPose {
  73394. views: Array<XRView>;
  73395. }
  73396. interface XRPose {
  73397. transform: XRRigidTransform;
  73398. emulatedPosition: boolean;
  73399. }
  73400. interface XRWebGLLayerOptions {
  73401. antialias?: boolean;
  73402. depth?: boolean;
  73403. stencil?: boolean;
  73404. alpha?: boolean;
  73405. multiview?: boolean;
  73406. framebufferScaleFactor?: number;
  73407. }
  73408. declare var XRWebGLLayer: {
  73409. prototype: XRWebGLLayer;
  73410. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  73411. };
  73412. interface XRWebGLLayer {
  73413. framebuffer: WebGLFramebuffer;
  73414. framebufferWidth: number;
  73415. framebufferHeight: number;
  73416. getViewport: Function;
  73417. }
  73418. declare class XRRigidTransform {
  73419. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  73420. position: DOMPointReadOnly;
  73421. orientation: DOMPointReadOnly;
  73422. matrix: Float32Array;
  73423. inverse: XRRigidTransform;
  73424. }
  73425. interface XRView {
  73426. eye: XREye;
  73427. projectionMatrix: Float32Array;
  73428. transform: XRRigidTransform;
  73429. }
  73430. interface XRInputSourceChangeEvent {
  73431. session: XRSession;
  73432. removed: Array<XRInputSource>;
  73433. added: Array<XRInputSource>;
  73434. }
  73435. interface XRInputSourceEvent extends Event {
  73436. readonly frame: XRFrame;
  73437. readonly inputSource: XRInputSource;
  73438. }
  73439. // Experimental(er) features
  73440. declare class XRRay {
  73441. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  73442. origin: DOMPointReadOnly;
  73443. direction: DOMPointReadOnly;
  73444. matrix: Float32Array;
  73445. }
  73446. declare enum XRHitTestTrackableType {
  73447. "point",
  73448. "plane"
  73449. }
  73450. interface XRHitResult {
  73451. hitMatrix: Float32Array;
  73452. }
  73453. interface XRTransientInputHitTestResult {
  73454. readonly inputSource: XRInputSource;
  73455. readonly results: Array<XRHitTestResult>;
  73456. }
  73457. interface XRHitTestResult {
  73458. getPose(baseSpace: XRSpace): XRPose | undefined;
  73459. }
  73460. interface XRHitTestSource {
  73461. cancel(): void;
  73462. }
  73463. interface XRTransientInputHitTestSource {
  73464. cancel(): void;
  73465. }
  73466. interface XRHitTestOptionsInit {
  73467. space: XRSpace;
  73468. entityTypes?: Array<XRHitTestTrackableType>;
  73469. offsetRay?: XRRay;
  73470. }
  73471. interface XRTransientInputHitTestOptionsInit {
  73472. profile: string;
  73473. entityTypes?: Array<XRHitTestTrackableType>;
  73474. offsetRay?: XRRay;
  73475. }
  73476. interface XRAnchor {
  73477. // remove?
  73478. id?: string;
  73479. anchorSpace: XRSpace;
  73480. lastChangedTime: number;
  73481. detach(): void;
  73482. }
  73483. interface XRPlane extends XRAnchorCreator {
  73484. orientation: "Horizontal" | "Vertical";
  73485. planeSpace: XRSpace;
  73486. polygon: Array<DOMPointReadOnly>;
  73487. lastChangedTime: number;
  73488. }
  73489. interface XRAnchorCreator {
  73490. // AR Anchors
  73491. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  73492. }
  73493. /**
  73494. * @ignore
  73495. */
  73496. declare module BABYLON.GLTF2.Exporter {
  73497. }
  73498. /**
  73499. * @ignore
  73500. */
  73501. declare module BABYLON.GLTF1 {
  73502. }
  73503. declare module BABYLON.GUI {
  73504. /**
  73505. * Class used to specific a value and its associated unit
  73506. */
  73507. export class ValueAndUnit {
  73508. /** defines the unit to store */
  73509. unit: number;
  73510. /** defines a boolean indicating if the value can be negative */
  73511. negativeValueAllowed: boolean;
  73512. private _value;
  73513. private _originalUnit;
  73514. /**
  73515. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  73516. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73517. */
  73518. ignoreAdaptiveScaling: boolean;
  73519. /**
  73520. * Creates a new ValueAndUnit
  73521. * @param value defines the value to store
  73522. * @param unit defines the unit to store
  73523. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  73524. */
  73525. constructor(value: number,
  73526. /** defines the unit to store */
  73527. unit?: number,
  73528. /** defines a boolean indicating if the value can be negative */
  73529. negativeValueAllowed?: boolean);
  73530. /** Gets a boolean indicating if the value is a percentage */
  73531. get isPercentage(): boolean;
  73532. /** Gets a boolean indicating if the value is store as pixel */
  73533. get isPixel(): boolean;
  73534. /** Gets direct internal value */
  73535. get internalValue(): number;
  73536. /**
  73537. * Gets value as pixel
  73538. * @param host defines the root host
  73539. * @param refValue defines the reference value for percentages
  73540. * @returns the value as pixel
  73541. */
  73542. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  73543. /**
  73544. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  73545. * @param value defines the value to store
  73546. * @param unit defines the unit to store
  73547. * @returns the current ValueAndUnit
  73548. */
  73549. updateInPlace(value: number, unit?: number): ValueAndUnit;
  73550. /**
  73551. * Gets the value accordingly to its unit
  73552. * @param host defines the root host
  73553. * @returns the value
  73554. */
  73555. getValue(host: AdvancedDynamicTexture): number;
  73556. /**
  73557. * Gets a string representation of the value
  73558. * @param host defines the root host
  73559. * @param decimals defines an optional number of decimals to display
  73560. * @returns a string
  73561. */
  73562. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  73563. /**
  73564. * Store a value parsed from a string
  73565. * @param source defines the source string
  73566. * @returns true if the value was successfully parsed
  73567. */
  73568. fromString(source: string | number): boolean;
  73569. private static _Regex;
  73570. private static _UNITMODE_PERCENTAGE;
  73571. private static _UNITMODE_PIXEL;
  73572. /** UNITMODE_PERCENTAGE */
  73573. static get UNITMODE_PERCENTAGE(): number;
  73574. /** UNITMODE_PIXEL */
  73575. static get UNITMODE_PIXEL(): number;
  73576. }
  73577. }
  73578. declare module BABYLON.GUI {
  73579. /**
  73580. * Define a style used by control to automatically setup properties based on a template.
  73581. * Only support font related properties so far
  73582. */
  73583. export class Style implements BABYLON.IDisposable {
  73584. private _fontFamily;
  73585. private _fontStyle;
  73586. private _fontWeight;
  73587. /** @hidden */
  73588. _host: AdvancedDynamicTexture;
  73589. /** @hidden */
  73590. _fontSize: ValueAndUnit;
  73591. /**
  73592. * BABYLON.Observable raised when the style values are changed
  73593. */
  73594. onChangedObservable: BABYLON.Observable<Style>;
  73595. /**
  73596. * Creates a new style object
  73597. * @param host defines the AdvancedDynamicTexture which hosts this style
  73598. */
  73599. constructor(host: AdvancedDynamicTexture);
  73600. /**
  73601. * Gets or sets the font size
  73602. */
  73603. get fontSize(): string | number;
  73604. set fontSize(value: string | number);
  73605. /**
  73606. * Gets or sets the font family
  73607. */
  73608. get fontFamily(): string;
  73609. set fontFamily(value: string);
  73610. /**
  73611. * Gets or sets the font style
  73612. */
  73613. get fontStyle(): string;
  73614. set fontStyle(value: string);
  73615. /** Gets or sets font weight */
  73616. get fontWeight(): string;
  73617. set fontWeight(value: string);
  73618. /** Dispose all associated resources */
  73619. dispose(): void;
  73620. }
  73621. }
  73622. declare module BABYLON.GUI {
  73623. /**
  73624. * Class used to transport BABYLON.Vector2 information for pointer events
  73625. */
  73626. export class Vector2WithInfo extends BABYLON.Vector2 {
  73627. /** defines the current mouse button index */
  73628. buttonIndex: number;
  73629. /**
  73630. * Creates a new Vector2WithInfo
  73631. * @param source defines the vector2 data to transport
  73632. * @param buttonIndex defines the current mouse button index
  73633. */
  73634. constructor(source: BABYLON.Vector2,
  73635. /** defines the current mouse button index */
  73636. buttonIndex?: number);
  73637. }
  73638. /** Class used to provide 2D matrix features */
  73639. export class Matrix2D {
  73640. /** Gets the internal array of 6 floats used to store matrix data */
  73641. m: Float32Array;
  73642. /**
  73643. * Creates a new matrix
  73644. * @param m00 defines value for (0, 0)
  73645. * @param m01 defines value for (0, 1)
  73646. * @param m10 defines value for (1, 0)
  73647. * @param m11 defines value for (1, 1)
  73648. * @param m20 defines value for (2, 0)
  73649. * @param m21 defines value for (2, 1)
  73650. */
  73651. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  73652. /**
  73653. * Fills the matrix from direct values
  73654. * @param m00 defines value for (0, 0)
  73655. * @param m01 defines value for (0, 1)
  73656. * @param m10 defines value for (1, 0)
  73657. * @param m11 defines value for (1, 1)
  73658. * @param m20 defines value for (2, 0)
  73659. * @param m21 defines value for (2, 1)
  73660. * @returns the current modified matrix
  73661. */
  73662. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  73663. /**
  73664. * Gets matrix determinant
  73665. * @returns the determinant
  73666. */
  73667. determinant(): number;
  73668. /**
  73669. * Inverses the matrix and stores it in a target matrix
  73670. * @param result defines the target matrix
  73671. * @returns the current matrix
  73672. */
  73673. invertToRef(result: Matrix2D): Matrix2D;
  73674. /**
  73675. * Multiplies the current matrix with another one
  73676. * @param other defines the second operand
  73677. * @param result defines the target matrix
  73678. * @returns the current matrix
  73679. */
  73680. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  73681. /**
  73682. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  73683. * @param x defines the x coordinate to transform
  73684. * @param y defines the x coordinate to transform
  73685. * @param result defines the target vector2
  73686. * @returns the current matrix
  73687. */
  73688. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  73689. /**
  73690. * Creates an identity matrix
  73691. * @returns a new matrix
  73692. */
  73693. static Identity(): Matrix2D;
  73694. /**
  73695. * Creates a translation matrix and stores it in a target matrix
  73696. * @param x defines the x coordinate of the translation
  73697. * @param y defines the y coordinate of the translation
  73698. * @param result defines the target matrix
  73699. */
  73700. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  73701. /**
  73702. * Creates a scaling matrix and stores it in a target matrix
  73703. * @param x defines the x coordinate of the scaling
  73704. * @param y defines the y coordinate of the scaling
  73705. * @param result defines the target matrix
  73706. */
  73707. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  73708. /**
  73709. * Creates a rotation matrix and stores it in a target matrix
  73710. * @param angle defines the rotation angle
  73711. * @param result defines the target matrix
  73712. */
  73713. static RotationToRef(angle: number, result: Matrix2D): void;
  73714. private static _TempPreTranslationMatrix;
  73715. private static _TempPostTranslationMatrix;
  73716. private static _TempRotationMatrix;
  73717. private static _TempScalingMatrix;
  73718. private static _TempCompose0;
  73719. private static _TempCompose1;
  73720. private static _TempCompose2;
  73721. /**
  73722. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  73723. * @param tx defines the x coordinate of the translation
  73724. * @param ty defines the y coordinate of the translation
  73725. * @param angle defines the rotation angle
  73726. * @param scaleX defines the x coordinate of the scaling
  73727. * @param scaleY defines the y coordinate of the scaling
  73728. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  73729. * @param result defines the target matrix
  73730. */
  73731. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  73732. }
  73733. }
  73734. declare module BABYLON.GUI {
  73735. /**
  73736. * Class used to store 2D control sizes
  73737. */
  73738. export class Measure {
  73739. /** defines left coordinate */
  73740. left: number;
  73741. /** defines top coordinate */
  73742. top: number;
  73743. /** defines width dimension */
  73744. width: number;
  73745. /** defines height dimension */
  73746. height: number;
  73747. /**
  73748. * Creates a new measure
  73749. * @param left defines left coordinate
  73750. * @param top defines top coordinate
  73751. * @param width defines width dimension
  73752. * @param height defines height dimension
  73753. */
  73754. constructor(
  73755. /** defines left coordinate */
  73756. left: number,
  73757. /** defines top coordinate */
  73758. top: number,
  73759. /** defines width dimension */
  73760. width: number,
  73761. /** defines height dimension */
  73762. height: number);
  73763. /**
  73764. * Copy from another measure
  73765. * @param other defines the other measure to copy from
  73766. */
  73767. copyFrom(other: Measure): void;
  73768. /**
  73769. * Copy from a group of 4 floats
  73770. * @param left defines left coordinate
  73771. * @param top defines top coordinate
  73772. * @param width defines width dimension
  73773. * @param height defines height dimension
  73774. */
  73775. copyFromFloats(left: number, top: number, width: number, height: number): void;
  73776. /**
  73777. * Computes the axis aligned bounding box measure for two given measures
  73778. * @param a Input measure
  73779. * @param b Input measure
  73780. * @param result the resulting bounding measure
  73781. */
  73782. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  73783. /**
  73784. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  73785. * @param transform the matrix to transform the measure before computing the AABB
  73786. * @param result the resulting AABB
  73787. */
  73788. transformToRef(transform: Matrix2D, result: Measure): void;
  73789. /**
  73790. * Check equality between this measure and another one
  73791. * @param other defines the other measures
  73792. * @returns true if both measures are equals
  73793. */
  73794. isEqualsTo(other: Measure): boolean;
  73795. /**
  73796. * Creates an empty measure
  73797. * @returns a new measure
  73798. */
  73799. static Empty(): Measure;
  73800. }
  73801. }
  73802. declare module BABYLON.GUI {
  73803. /**
  73804. * Interface used to define a control that can receive focus
  73805. */
  73806. export interface IFocusableControl {
  73807. /**
  73808. * Function called when the control receives the focus
  73809. */
  73810. onFocus(): void;
  73811. /**
  73812. * Function called when the control loses the focus
  73813. */
  73814. onBlur(): void;
  73815. /**
  73816. * Function called to let the control handle keyboard events
  73817. * @param evt defines the current keyboard event
  73818. */
  73819. processKeyboard(evt: KeyboardEvent): void;
  73820. /**
  73821. * Function called to get the list of controls that should not steal the focus from this control
  73822. * @returns an array of controls
  73823. */
  73824. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73825. }
  73826. /**
  73827. * Class used to create texture to support 2D GUI elements
  73828. * @see http://doc.babylonjs.com/how_to/gui
  73829. */
  73830. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  73831. private _isDirty;
  73832. private _renderObserver;
  73833. private _resizeObserver;
  73834. private _preKeyboardObserver;
  73835. private _pointerMoveObserver;
  73836. private _pointerObserver;
  73837. private _canvasPointerOutObserver;
  73838. private _background;
  73839. /** @hidden */
  73840. _rootContainer: Container;
  73841. /** @hidden */
  73842. _lastPickedControl: Control;
  73843. /** @hidden */
  73844. _lastControlOver: {
  73845. [pointerId: number]: Control;
  73846. };
  73847. /** @hidden */
  73848. _lastControlDown: {
  73849. [pointerId: number]: Control;
  73850. };
  73851. /** @hidden */
  73852. _capturingControl: {
  73853. [pointerId: number]: Control;
  73854. };
  73855. /** @hidden */
  73856. _shouldBlockPointer: boolean;
  73857. /** @hidden */
  73858. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  73859. /** @hidden */
  73860. _linkedControls: Control[];
  73861. private _isFullscreen;
  73862. private _fullscreenViewport;
  73863. private _idealWidth;
  73864. private _idealHeight;
  73865. private _useSmallestIdeal;
  73866. private _renderAtIdealSize;
  73867. private _focusedControl;
  73868. private _blockNextFocusCheck;
  73869. private _renderScale;
  73870. private _rootElement;
  73871. private _cursorChanged;
  73872. private _defaultMousePointerId;
  73873. /** @hidden */
  73874. _numLayoutCalls: number;
  73875. /** Gets the number of layout calls made the last time the ADT has been rendered */
  73876. get numLayoutCalls(): number;
  73877. /** @hidden */
  73878. _numRenderCalls: number;
  73879. /** Gets the number of render calls made the last time the ADT has been rendered */
  73880. get numRenderCalls(): number;
  73881. /**
  73882. * Define type to string to ensure compatibility across browsers
  73883. * Safari doesn't support DataTransfer constructor
  73884. */
  73885. private _clipboardData;
  73886. /**
  73887. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  73888. */
  73889. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  73890. /**
  73891. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  73892. */
  73893. onControlPickedObservable: BABYLON.Observable<Control>;
  73894. /**
  73895. * BABYLON.Observable event triggered before layout is evaluated
  73896. */
  73897. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73898. /**
  73899. * BABYLON.Observable event triggered after the layout was evaluated
  73900. */
  73901. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73902. /**
  73903. * BABYLON.Observable event triggered before the texture is rendered
  73904. */
  73905. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73906. /**
  73907. * BABYLON.Observable event triggered after the texture was rendered
  73908. */
  73909. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73910. /**
  73911. * Gets or sets a boolean defining if alpha is stored as premultiplied
  73912. */
  73913. premulAlpha: boolean;
  73914. /**
  73915. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  73916. * Useful when you want more antialiasing
  73917. */
  73918. get renderScale(): number;
  73919. set renderScale(value: number);
  73920. /** Gets or sets the background color */
  73921. get background(): string;
  73922. set background(value: string);
  73923. /**
  73924. * Gets or sets the ideal width used to design controls.
  73925. * The GUI will then rescale everything accordingly
  73926. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73927. */
  73928. get idealWidth(): number;
  73929. set idealWidth(value: number);
  73930. /**
  73931. * Gets or sets the ideal height used to design controls.
  73932. * The GUI will then rescale everything accordingly
  73933. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73934. */
  73935. get idealHeight(): number;
  73936. set idealHeight(value: number);
  73937. /**
  73938. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  73939. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73940. */
  73941. get useSmallestIdeal(): boolean;
  73942. set useSmallestIdeal(value: boolean);
  73943. /**
  73944. * Gets or sets a boolean indicating if adaptive scaling must be used
  73945. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73946. */
  73947. get renderAtIdealSize(): boolean;
  73948. set renderAtIdealSize(value: boolean);
  73949. /**
  73950. * Gets the ratio used when in "ideal mode"
  73951. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73952. * */
  73953. get idealRatio(): number;
  73954. /**
  73955. * Gets the underlying layer used to render the texture when in fullscreen mode
  73956. */
  73957. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  73958. /**
  73959. * Gets the root container control
  73960. */
  73961. get rootContainer(): Container;
  73962. /**
  73963. * Returns an array containing the root container.
  73964. * This is mostly used to let the Inspector introspects the ADT
  73965. * @returns an array containing the rootContainer
  73966. */
  73967. getChildren(): Array<Container>;
  73968. /**
  73969. * Will return all controls that are inside this texture
  73970. * @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
  73971. * @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
  73972. * @return all child controls
  73973. */
  73974. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  73975. /**
  73976. * Gets or sets the current focused control
  73977. */
  73978. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  73979. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  73980. /**
  73981. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  73982. */
  73983. get isForeground(): boolean;
  73984. set isForeground(value: boolean);
  73985. /**
  73986. * Gets or set information about clipboardData
  73987. */
  73988. get clipboardData(): string;
  73989. set clipboardData(value: string);
  73990. /**
  73991. * Creates a new AdvancedDynamicTexture
  73992. * @param name defines the name of the texture
  73993. * @param width defines the width of the texture
  73994. * @param height defines the height of the texture
  73995. * @param scene defines the hosting scene
  73996. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  73997. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  73998. */
  73999. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74000. /**
  74001. * Get the current class name of the texture useful for serialization or dynamic coding.
  74002. * @returns "AdvancedDynamicTexture"
  74003. */
  74004. getClassName(): string;
  74005. /**
  74006. * Function used to execute a function on all controls
  74007. * @param func defines the function to execute
  74008. * @param container defines the container where controls belong. If null the root container will be used
  74009. */
  74010. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74011. private _useInvalidateRectOptimization;
  74012. /**
  74013. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74014. */
  74015. get useInvalidateRectOptimization(): boolean;
  74016. set useInvalidateRectOptimization(value: boolean);
  74017. private _invalidatedRectangle;
  74018. /**
  74019. * Invalidates a rectangle area on the gui texture
  74020. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74021. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74022. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74023. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74024. */
  74025. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74026. /**
  74027. * Marks the texture as dirty forcing a complete update
  74028. */
  74029. markAsDirty(): void;
  74030. /**
  74031. * Helper function used to create a new style
  74032. * @returns a new style
  74033. * @see http://doc.babylonjs.com/how_to/gui#styles
  74034. */
  74035. createStyle(): Style;
  74036. /**
  74037. * Adds a new control to the root container
  74038. * @param control defines the control to add
  74039. * @returns the current texture
  74040. */
  74041. addControl(control: Control): AdvancedDynamicTexture;
  74042. /**
  74043. * Removes a control from the root container
  74044. * @param control defines the control to remove
  74045. * @returns the current texture
  74046. */
  74047. removeControl(control: Control): AdvancedDynamicTexture;
  74048. /**
  74049. * Release all resources
  74050. */
  74051. dispose(): void;
  74052. private _onResize;
  74053. /** @hidden */
  74054. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74055. /**
  74056. * Get screen coordinates for a vector3
  74057. * @param position defines the position to project
  74058. * @param worldMatrix defines the world matrix to use
  74059. * @returns the projected position
  74060. */
  74061. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74062. private _checkUpdate;
  74063. private _clearMeasure;
  74064. private _render;
  74065. /** @hidden */
  74066. _changeCursor(cursor: string): void;
  74067. /** @hidden */
  74068. _registerLastControlDown(control: Control, pointerId: number): void;
  74069. private _doPicking;
  74070. /** @hidden */
  74071. _cleanControlAfterRemovalFromList(list: {
  74072. [pointerId: number]: Control;
  74073. }, control: Control): void;
  74074. /** @hidden */
  74075. _cleanControlAfterRemoval(control: Control): void;
  74076. /** Attach to all scene events required to support pointer events */
  74077. attach(): void;
  74078. /** @hidden */
  74079. private onClipboardCopy;
  74080. /** @hidden */
  74081. private onClipboardCut;
  74082. /** @hidden */
  74083. private onClipboardPaste;
  74084. /**
  74085. * Register the clipboard Events onto the canvas
  74086. */
  74087. registerClipboardEvents(): void;
  74088. /**
  74089. * Unregister the clipboard Events from the canvas
  74090. */
  74091. unRegisterClipboardEvents(): void;
  74092. /**
  74093. * Connect the texture to a hosting mesh to enable interactions
  74094. * @param mesh defines the mesh to attach to
  74095. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74096. */
  74097. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74098. /**
  74099. * Move the focus to a specific control
  74100. * @param control defines the control which will receive the focus
  74101. */
  74102. moveFocusToControl(control: IFocusableControl): void;
  74103. private _manageFocus;
  74104. private _attachToOnPointerOut;
  74105. /**
  74106. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74107. * @param mesh defines the mesh which will receive the texture
  74108. * @param width defines the texture width (1024 by default)
  74109. * @param height defines the texture height (1024 by default)
  74110. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74111. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74112. * @returns a new AdvancedDynamicTexture
  74113. */
  74114. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74115. /**
  74116. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74117. * In this mode the texture will rely on a layer for its rendering.
  74118. * This allows it to be treated like any other layer.
  74119. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74120. * LayerMask is set through advancedTexture.layer.layerMask
  74121. * @param name defines name for the texture
  74122. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74123. * @param scene defines the hsoting scene
  74124. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74125. * @returns a new AdvancedDynamicTexture
  74126. */
  74127. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74128. }
  74129. }
  74130. declare module BABYLON.GUI {
  74131. /**
  74132. * Root class used for all 2D controls
  74133. * @see http://doc.babylonjs.com/how_to/gui#controls
  74134. */
  74135. export class Control {
  74136. /** defines the name of the control */
  74137. name?: string | undefined;
  74138. /**
  74139. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74140. */
  74141. static AllowAlphaInheritance: boolean;
  74142. private _alpha;
  74143. private _alphaSet;
  74144. private _zIndex;
  74145. /** @hidden */
  74146. _host: AdvancedDynamicTexture;
  74147. /** Gets or sets the control parent */
  74148. parent: BABYLON.Nullable<Container>;
  74149. /** @hidden */
  74150. _currentMeasure: Measure;
  74151. private _fontFamily;
  74152. private _fontStyle;
  74153. private _fontWeight;
  74154. private _fontSize;
  74155. private _font;
  74156. /** @hidden */
  74157. _width: ValueAndUnit;
  74158. /** @hidden */
  74159. _height: ValueAndUnit;
  74160. /** @hidden */
  74161. protected _fontOffset: {
  74162. ascent: number;
  74163. height: number;
  74164. descent: number;
  74165. };
  74166. private _color;
  74167. private _style;
  74168. private _styleObserver;
  74169. /** @hidden */
  74170. protected _horizontalAlignment: number;
  74171. /** @hidden */
  74172. protected _verticalAlignment: number;
  74173. /** @hidden */
  74174. protected _isDirty: boolean;
  74175. /** @hidden */
  74176. protected _wasDirty: boolean;
  74177. /** @hidden */
  74178. _tempParentMeasure: Measure;
  74179. /** @hidden */
  74180. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74181. /** @hidden */
  74182. protected _cachedParentMeasure: Measure;
  74183. private _paddingLeft;
  74184. private _paddingRight;
  74185. private _paddingTop;
  74186. private _paddingBottom;
  74187. /** @hidden */
  74188. _left: ValueAndUnit;
  74189. /** @hidden */
  74190. _top: ValueAndUnit;
  74191. private _scaleX;
  74192. private _scaleY;
  74193. private _rotation;
  74194. private _transformCenterX;
  74195. private _transformCenterY;
  74196. /** @hidden */
  74197. _transformMatrix: Matrix2D;
  74198. /** @hidden */
  74199. protected _invertTransformMatrix: Matrix2D;
  74200. /** @hidden */
  74201. protected _transformedPosition: BABYLON.Vector2;
  74202. private _isMatrixDirty;
  74203. private _cachedOffsetX;
  74204. private _cachedOffsetY;
  74205. private _isVisible;
  74206. private _isHighlighted;
  74207. /** @hidden */
  74208. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74209. private _fontSet;
  74210. private _dummyVector2;
  74211. private _downCount;
  74212. private _enterCount;
  74213. private _doNotRender;
  74214. private _downPointerIds;
  74215. protected _isEnabled: boolean;
  74216. protected _disabledColor: string;
  74217. protected _disabledColorItem: string;
  74218. /** @hidden */
  74219. protected _rebuildLayout: boolean;
  74220. /** @hidden */
  74221. _customData: any;
  74222. /** @hidden */
  74223. _isClipped: boolean;
  74224. /** @hidden */
  74225. _automaticSize: boolean;
  74226. /** @hidden */
  74227. _tag: any;
  74228. /**
  74229. * 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
  74230. */
  74231. uniqueId: number;
  74232. /**
  74233. * Gets or sets an object used to store user defined information for the node
  74234. */
  74235. metadata: any;
  74236. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74237. isHitTestVisible: boolean;
  74238. /** Gets or sets a boolean indicating if the control can block pointer events */
  74239. isPointerBlocker: boolean;
  74240. /** Gets or sets a boolean indicating if the control can be focusable */
  74241. isFocusInvisible: boolean;
  74242. /**
  74243. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74244. * 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
  74245. */
  74246. clipChildren: boolean;
  74247. /**
  74248. * Gets or sets a boolean indicating that control content must be clipped
  74249. * 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
  74250. */
  74251. clipContent: boolean;
  74252. /**
  74253. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74254. */
  74255. useBitmapCache: boolean;
  74256. private _cacheData;
  74257. private _shadowOffsetX;
  74258. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74259. get shadowOffsetX(): number;
  74260. set shadowOffsetX(value: number);
  74261. private _shadowOffsetY;
  74262. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74263. get shadowOffsetY(): number;
  74264. set shadowOffsetY(value: number);
  74265. private _shadowBlur;
  74266. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74267. get shadowBlur(): number;
  74268. set shadowBlur(value: number);
  74269. private _shadowColor;
  74270. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74271. get shadowColor(): string;
  74272. set shadowColor(value: string);
  74273. /** Gets or sets the cursor to use when the control is hovered */
  74274. hoverCursor: string;
  74275. /** @hidden */
  74276. protected _linkOffsetX: ValueAndUnit;
  74277. /** @hidden */
  74278. protected _linkOffsetY: ValueAndUnit;
  74279. /** Gets the control type name */
  74280. get typeName(): string;
  74281. /**
  74282. * Get the current class name of the control.
  74283. * @returns current class name
  74284. */
  74285. getClassName(): string;
  74286. /**
  74287. * An event triggered when pointer wheel is scrolled
  74288. */
  74289. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74290. /**
  74291. * An event triggered when the pointer move over the control.
  74292. */
  74293. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74294. /**
  74295. * An event triggered when the pointer move out of the control.
  74296. */
  74297. onPointerOutObservable: BABYLON.Observable<Control>;
  74298. /**
  74299. * An event triggered when the pointer taps the control
  74300. */
  74301. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74302. /**
  74303. * An event triggered when pointer up
  74304. */
  74305. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74306. /**
  74307. * An event triggered when a control is clicked on
  74308. */
  74309. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74310. /**
  74311. * An event triggered when pointer enters the control
  74312. */
  74313. onPointerEnterObservable: BABYLON.Observable<Control>;
  74314. /**
  74315. * An event triggered when the control is marked as dirty
  74316. */
  74317. onDirtyObservable: BABYLON.Observable<Control>;
  74318. /**
  74319. * An event triggered before drawing the control
  74320. */
  74321. onBeforeDrawObservable: BABYLON.Observable<Control>;
  74322. /**
  74323. * An event triggered after the control was drawn
  74324. */
  74325. onAfterDrawObservable: BABYLON.Observable<Control>;
  74326. /**
  74327. * An event triggered when the control has been disposed
  74328. */
  74329. onDisposeObservable: BABYLON.Observable<Control>;
  74330. /**
  74331. * Get the hosting AdvancedDynamicTexture
  74332. */
  74333. get host(): AdvancedDynamicTexture;
  74334. /** Gets or set information about font offsets (used to render and align text) */
  74335. get fontOffset(): {
  74336. ascent: number;
  74337. height: number;
  74338. descent: number;
  74339. };
  74340. set fontOffset(offset: {
  74341. ascent: number;
  74342. height: number;
  74343. descent: number;
  74344. });
  74345. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  74346. get alpha(): number;
  74347. set alpha(value: number);
  74348. /**
  74349. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  74350. */
  74351. get isHighlighted(): boolean;
  74352. set isHighlighted(value: boolean);
  74353. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  74354. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74355. */
  74356. get scaleX(): number;
  74357. set scaleX(value: number);
  74358. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  74359. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74360. */
  74361. get scaleY(): number;
  74362. set scaleY(value: number);
  74363. /** Gets or sets the rotation angle (0 by default)
  74364. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74365. */
  74366. get rotation(): number;
  74367. set rotation(value: number);
  74368. /** Gets or sets the transformation center on Y axis (0 by default)
  74369. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74370. */
  74371. get transformCenterY(): number;
  74372. set transformCenterY(value: number);
  74373. /** Gets or sets the transformation center on X axis (0 by default)
  74374. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74375. */
  74376. get transformCenterX(): number;
  74377. set transformCenterX(value: number);
  74378. /**
  74379. * Gets or sets the horizontal alignment
  74380. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74381. */
  74382. get horizontalAlignment(): number;
  74383. set horizontalAlignment(value: number);
  74384. /**
  74385. * Gets or sets the vertical alignment
  74386. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74387. */
  74388. get verticalAlignment(): number;
  74389. set verticalAlignment(value: number);
  74390. /**
  74391. * Gets or sets control width
  74392. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74393. */
  74394. get width(): string | number;
  74395. set width(value: string | number);
  74396. /**
  74397. * Gets or sets the control width in pixel
  74398. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74399. */
  74400. get widthInPixels(): number;
  74401. set widthInPixels(value: number);
  74402. /**
  74403. * Gets or sets control height
  74404. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74405. */
  74406. get height(): string | number;
  74407. set height(value: string | number);
  74408. /**
  74409. * Gets or sets control height in pixel
  74410. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74411. */
  74412. get heightInPixels(): number;
  74413. set heightInPixels(value: number);
  74414. /** Gets or set font family */
  74415. get fontFamily(): string;
  74416. set fontFamily(value: string);
  74417. /** Gets or sets font style */
  74418. get fontStyle(): string;
  74419. set fontStyle(value: string);
  74420. /** Gets or sets font weight */
  74421. get fontWeight(): string;
  74422. set fontWeight(value: string);
  74423. /**
  74424. * Gets or sets style
  74425. * @see http://doc.babylonjs.com/how_to/gui#styles
  74426. */
  74427. get style(): BABYLON.Nullable<Style>;
  74428. set style(value: BABYLON.Nullable<Style>);
  74429. /** @hidden */
  74430. get _isFontSizeInPercentage(): boolean;
  74431. /** Gets or sets font size in pixels */
  74432. get fontSizeInPixels(): number;
  74433. set fontSizeInPixels(value: number);
  74434. /** Gets or sets font size */
  74435. get fontSize(): string | number;
  74436. set fontSize(value: string | number);
  74437. /** Gets or sets foreground color */
  74438. get color(): string;
  74439. set color(value: string);
  74440. /** Gets or sets z index which is used to reorder controls on the z axis */
  74441. get zIndex(): number;
  74442. set zIndex(value: number);
  74443. /** Gets or sets a boolean indicating if the control can be rendered */
  74444. get notRenderable(): boolean;
  74445. set notRenderable(value: boolean);
  74446. /** Gets or sets a boolean indicating if the control is visible */
  74447. get isVisible(): boolean;
  74448. set isVisible(value: boolean);
  74449. /** Gets a boolean indicating that the control needs to update its rendering */
  74450. get isDirty(): boolean;
  74451. /**
  74452. * Gets the current linked mesh (or null if none)
  74453. */
  74454. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74455. /**
  74456. * Gets or sets a value indicating the padding to use on the left of the control
  74457. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74458. */
  74459. get paddingLeft(): string | number;
  74460. set paddingLeft(value: string | number);
  74461. /**
  74462. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  74463. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74464. */
  74465. get paddingLeftInPixels(): number;
  74466. set paddingLeftInPixels(value: number);
  74467. /**
  74468. * Gets or sets a value indicating the padding to use on the right of the control
  74469. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74470. */
  74471. get paddingRight(): string | number;
  74472. set paddingRight(value: string | number);
  74473. /**
  74474. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  74475. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74476. */
  74477. get paddingRightInPixels(): number;
  74478. set paddingRightInPixels(value: number);
  74479. /**
  74480. * Gets or sets a value indicating the padding to use on the top of the control
  74481. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74482. */
  74483. get paddingTop(): string | number;
  74484. set paddingTop(value: string | number);
  74485. /**
  74486. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  74487. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74488. */
  74489. get paddingTopInPixels(): number;
  74490. set paddingTopInPixels(value: number);
  74491. /**
  74492. * Gets or sets a value indicating the padding to use on the bottom of the control
  74493. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74494. */
  74495. get paddingBottom(): string | number;
  74496. set paddingBottom(value: string | number);
  74497. /**
  74498. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  74499. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74500. */
  74501. get paddingBottomInPixels(): number;
  74502. set paddingBottomInPixels(value: number);
  74503. /**
  74504. * Gets or sets a value indicating the left coordinate of the control
  74505. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74506. */
  74507. get left(): string | number;
  74508. set left(value: string | number);
  74509. /**
  74510. * Gets or sets a value indicating the left coordinate in pixels of the control
  74511. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74512. */
  74513. get leftInPixels(): number;
  74514. set leftInPixels(value: number);
  74515. /**
  74516. * Gets or sets a value indicating the top coordinate of the control
  74517. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74518. */
  74519. get top(): string | number;
  74520. set top(value: string | number);
  74521. /**
  74522. * Gets or sets a value indicating the top coordinate in pixels of the control
  74523. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74524. */
  74525. get topInPixels(): number;
  74526. set topInPixels(value: number);
  74527. /**
  74528. * Gets or sets a value indicating the offset on X axis to the linked mesh
  74529. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74530. */
  74531. get linkOffsetX(): string | number;
  74532. set linkOffsetX(value: string | number);
  74533. /**
  74534. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  74535. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74536. */
  74537. get linkOffsetXInPixels(): number;
  74538. set linkOffsetXInPixels(value: number);
  74539. /**
  74540. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  74541. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74542. */
  74543. get linkOffsetY(): string | number;
  74544. set linkOffsetY(value: string | number);
  74545. /**
  74546. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  74547. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74548. */
  74549. get linkOffsetYInPixels(): number;
  74550. set linkOffsetYInPixels(value: number);
  74551. /** Gets the center coordinate on X axis */
  74552. get centerX(): number;
  74553. /** Gets the center coordinate on Y axis */
  74554. get centerY(): number;
  74555. /** Gets or sets if control is Enabled*/
  74556. get isEnabled(): boolean;
  74557. set isEnabled(value: boolean);
  74558. /** Gets or sets background color of control if it's disabled*/
  74559. get disabledColor(): string;
  74560. set disabledColor(value: string);
  74561. /** Gets or sets front color of control if it's disabled*/
  74562. get disabledColorItem(): string;
  74563. set disabledColorItem(value: string);
  74564. /**
  74565. * Creates a new control
  74566. * @param name defines the name of the control
  74567. */
  74568. constructor(
  74569. /** defines the name of the control */
  74570. name?: string | undefined);
  74571. /** @hidden */
  74572. protected _getTypeName(): string;
  74573. /**
  74574. * Gets the first ascendant in the hierarchy of the given type
  74575. * @param className defines the required type
  74576. * @returns the ascendant or null if not found
  74577. */
  74578. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  74579. /** @hidden */
  74580. _resetFontCache(): void;
  74581. /**
  74582. * Determines if a container is an ascendant of the current control
  74583. * @param container defines the container to look for
  74584. * @returns true if the container is one of the ascendant of the control
  74585. */
  74586. isAscendant(container: Control): boolean;
  74587. /**
  74588. * Gets coordinates in local control space
  74589. * @param globalCoordinates defines the coordinates to transform
  74590. * @returns the new coordinates in local space
  74591. */
  74592. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74593. /**
  74594. * Gets coordinates in local control space
  74595. * @param globalCoordinates defines the coordinates to transform
  74596. * @param result defines the target vector2 where to store the result
  74597. * @returns the current control
  74598. */
  74599. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  74600. /**
  74601. * Gets coordinates in parent local control space
  74602. * @param globalCoordinates defines the coordinates to transform
  74603. * @returns the new coordinates in parent local space
  74604. */
  74605. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74606. /**
  74607. * Move the current control to a vector3 position projected onto the screen.
  74608. * @param position defines the target position
  74609. * @param scene defines the hosting scene
  74610. */
  74611. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  74612. /**
  74613. * Will store all controls that have this control as ascendant in a given array
  74614. * @param results defines the array where to store the descendants
  74615. * @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
  74616. * @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
  74617. */
  74618. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  74619. /**
  74620. * Will return all controls that have this control as ascendant
  74621. * @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
  74622. * @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
  74623. * @return all child controls
  74624. */
  74625. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74626. /**
  74627. * Link current control with a target mesh
  74628. * @param mesh defines the mesh to link with
  74629. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74630. */
  74631. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  74632. /** @hidden */
  74633. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  74634. /** @hidden */
  74635. _offsetLeft(offset: number): void;
  74636. /** @hidden */
  74637. _offsetTop(offset: number): void;
  74638. /** @hidden */
  74639. _markMatrixAsDirty(): void;
  74640. /** @hidden */
  74641. _flagDescendantsAsMatrixDirty(): void;
  74642. /** @hidden */
  74643. _intersectsRect(rect: Measure): boolean;
  74644. /** @hidden */
  74645. protected invalidateRect(): void;
  74646. /** @hidden */
  74647. _markAsDirty(force?: boolean): void;
  74648. /** @hidden */
  74649. _markAllAsDirty(): void;
  74650. /** @hidden */
  74651. _link(host: AdvancedDynamicTexture): void;
  74652. /** @hidden */
  74653. protected _transform(context?: CanvasRenderingContext2D): void;
  74654. /** @hidden */
  74655. _renderHighlight(context: CanvasRenderingContext2D): void;
  74656. /** @hidden */
  74657. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74658. /** @hidden */
  74659. protected _applyStates(context: CanvasRenderingContext2D): void;
  74660. /** @hidden */
  74661. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74662. /** @hidden */
  74663. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74664. protected _evaluateClippingState(parentMeasure: Measure): void;
  74665. /** @hidden */
  74666. _measure(): void;
  74667. /** @hidden */
  74668. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74669. /** @hidden */
  74670. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74671. /** @hidden */
  74672. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74673. /** @hidden */
  74674. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74675. private static _ClipMeasure;
  74676. private _tmpMeasureA;
  74677. private _clip;
  74678. /** @hidden */
  74679. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  74680. /** @hidden */
  74681. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74682. /**
  74683. * Tests if a given coordinates belong to the current control
  74684. * @param x defines x coordinate to test
  74685. * @param y defines y coordinate to test
  74686. * @returns true if the coordinates are inside the control
  74687. */
  74688. contains(x: number, y: number): boolean;
  74689. /** @hidden */
  74690. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74691. /** @hidden */
  74692. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74693. /** @hidden */
  74694. _onPointerEnter(target: Control): boolean;
  74695. /** @hidden */
  74696. _onPointerOut(target: Control, force?: boolean): void;
  74697. /** @hidden */
  74698. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74699. /** @hidden */
  74700. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74701. /** @hidden */
  74702. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74703. /** @hidden */
  74704. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  74705. /** @hidden */
  74706. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74707. private _prepareFont;
  74708. /** Releases associated resources */
  74709. dispose(): void;
  74710. private static _HORIZONTAL_ALIGNMENT_LEFT;
  74711. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  74712. private static _HORIZONTAL_ALIGNMENT_CENTER;
  74713. private static _VERTICAL_ALIGNMENT_TOP;
  74714. private static _VERTICAL_ALIGNMENT_BOTTOM;
  74715. private static _VERTICAL_ALIGNMENT_CENTER;
  74716. /** HORIZONTAL_ALIGNMENT_LEFT */
  74717. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  74718. /** HORIZONTAL_ALIGNMENT_RIGHT */
  74719. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  74720. /** HORIZONTAL_ALIGNMENT_CENTER */
  74721. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  74722. /** VERTICAL_ALIGNMENT_TOP */
  74723. static get VERTICAL_ALIGNMENT_TOP(): number;
  74724. /** VERTICAL_ALIGNMENT_BOTTOM */
  74725. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  74726. /** VERTICAL_ALIGNMENT_CENTER */
  74727. static get VERTICAL_ALIGNMENT_CENTER(): number;
  74728. private static _FontHeightSizes;
  74729. /** @hidden */
  74730. static _GetFontOffset(font: string): {
  74731. ascent: number;
  74732. height: number;
  74733. descent: number;
  74734. };
  74735. /**
  74736. * Creates a stack panel that can be used to render headers
  74737. * @param control defines the control to associate with the header
  74738. * @param text defines the text of the header
  74739. * @param size defines the size of the header
  74740. * @param options defines options used to configure the header
  74741. * @returns a new StackPanel
  74742. * @ignore
  74743. * @hidden
  74744. */
  74745. static AddHeader: (control: Control, text: string, size: string | number, options: {
  74746. isHorizontal: boolean;
  74747. controlFirst: boolean;
  74748. }) => any;
  74749. /** @hidden */
  74750. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  74751. }
  74752. }
  74753. declare module BABYLON.GUI {
  74754. /**
  74755. * Root class for 2D containers
  74756. * @see http://doc.babylonjs.com/how_to/gui#containers
  74757. */
  74758. export class Container extends Control {
  74759. name?: string | undefined;
  74760. /** @hidden */
  74761. _children: Control[];
  74762. /** @hidden */
  74763. protected _measureForChildren: Measure;
  74764. /** @hidden */
  74765. protected _background: string;
  74766. /** @hidden */
  74767. protected _adaptWidthToChildren: boolean;
  74768. /** @hidden */
  74769. protected _adaptHeightToChildren: boolean;
  74770. /**
  74771. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  74772. */
  74773. logLayoutCycleErrors: boolean;
  74774. /**
  74775. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  74776. */
  74777. maxLayoutCycle: number;
  74778. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  74779. get adaptHeightToChildren(): boolean;
  74780. set adaptHeightToChildren(value: boolean);
  74781. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  74782. get adaptWidthToChildren(): boolean;
  74783. set adaptWidthToChildren(value: boolean);
  74784. /** Gets or sets background color */
  74785. get background(): string;
  74786. set background(value: string);
  74787. /** Gets the list of children */
  74788. get children(): Control[];
  74789. /**
  74790. * Creates a new Container
  74791. * @param name defines the name of the container
  74792. */
  74793. constructor(name?: string | undefined);
  74794. protected _getTypeName(): string;
  74795. _flagDescendantsAsMatrixDirty(): void;
  74796. /**
  74797. * Gets a child using its name
  74798. * @param name defines the child name to look for
  74799. * @returns the child control if found
  74800. */
  74801. getChildByName(name: string): BABYLON.Nullable<Control>;
  74802. /**
  74803. * Gets a child using its type and its name
  74804. * @param name defines the child name to look for
  74805. * @param type defines the child type to look for
  74806. * @returns the child control if found
  74807. */
  74808. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  74809. /**
  74810. * Search for a specific control in children
  74811. * @param control defines the control to look for
  74812. * @returns true if the control is in child list
  74813. */
  74814. containsControl(control: Control): boolean;
  74815. /**
  74816. * Adds a new control to the current container
  74817. * @param control defines the control to add
  74818. * @returns the current container
  74819. */
  74820. addControl(control: BABYLON.Nullable<Control>): Container;
  74821. /**
  74822. * Removes all controls from the current container
  74823. * @returns the current container
  74824. */
  74825. clearControls(): Container;
  74826. /**
  74827. * Removes a control from the current container
  74828. * @param control defines the control to remove
  74829. * @returns the current container
  74830. */
  74831. removeControl(control: Control): Container;
  74832. /** @hidden */
  74833. _reOrderControl(control: Control): void;
  74834. /** @hidden */
  74835. _offsetLeft(offset: number): void;
  74836. /** @hidden */
  74837. _offsetTop(offset: number): void;
  74838. /** @hidden */
  74839. _markAllAsDirty(): void;
  74840. /** @hidden */
  74841. protected _localDraw(context: CanvasRenderingContext2D): void;
  74842. /** @hidden */
  74843. _link(host: AdvancedDynamicTexture): void;
  74844. /** @hidden */
  74845. protected _beforeLayout(): void;
  74846. /** @hidden */
  74847. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74848. /** @hidden */
  74849. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74850. protected _postMeasure(): void;
  74851. /** @hidden */
  74852. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  74853. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  74854. /** @hidden */
  74855. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74856. /** @hidden */
  74857. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74858. /** Releases associated resources */
  74859. dispose(): void;
  74860. }
  74861. }
  74862. declare module BABYLON.GUI {
  74863. /** Class used to create rectangle container */
  74864. export class Rectangle extends Container {
  74865. name?: string | undefined;
  74866. private _thickness;
  74867. private _cornerRadius;
  74868. /** Gets or sets border thickness */
  74869. get thickness(): number;
  74870. set thickness(value: number);
  74871. /** Gets or sets the corner radius angle */
  74872. get cornerRadius(): number;
  74873. set cornerRadius(value: number);
  74874. /**
  74875. * Creates a new Rectangle
  74876. * @param name defines the control name
  74877. */
  74878. constructor(name?: string | undefined);
  74879. protected _getTypeName(): string;
  74880. protected _localDraw(context: CanvasRenderingContext2D): void;
  74881. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74882. private _drawRoundedRect;
  74883. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74884. }
  74885. }
  74886. declare module BABYLON.GUI {
  74887. /**
  74888. * Enum that determines the text-wrapping mode to use.
  74889. */
  74890. export enum TextWrapping {
  74891. /**
  74892. * Clip the text when it's larger than Control.width; this is the default mode.
  74893. */
  74894. Clip = 0,
  74895. /**
  74896. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  74897. */
  74898. WordWrap = 1,
  74899. /**
  74900. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  74901. */
  74902. Ellipsis = 2
  74903. }
  74904. /**
  74905. * Class used to create text block control
  74906. */
  74907. export class TextBlock extends Control {
  74908. /**
  74909. * Defines the name of the control
  74910. */
  74911. name?: string | undefined;
  74912. private _text;
  74913. private _textWrapping;
  74914. private _textHorizontalAlignment;
  74915. private _textVerticalAlignment;
  74916. private _lines;
  74917. private _resizeToFit;
  74918. private _lineSpacing;
  74919. private _outlineWidth;
  74920. private _outlineColor;
  74921. /**
  74922. * An event triggered after the text is changed
  74923. */
  74924. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  74925. /**
  74926. * An event triggered after the text was broken up into lines
  74927. */
  74928. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  74929. /**
  74930. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  74931. */
  74932. get lines(): any[];
  74933. /**
  74934. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  74935. */
  74936. get resizeToFit(): boolean;
  74937. /**
  74938. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  74939. */
  74940. set resizeToFit(value: boolean);
  74941. /**
  74942. * Gets or sets a boolean indicating if text must be wrapped
  74943. */
  74944. get textWrapping(): TextWrapping | boolean;
  74945. /**
  74946. * Gets or sets a boolean indicating if text must be wrapped
  74947. */
  74948. set textWrapping(value: TextWrapping | boolean);
  74949. /**
  74950. * Gets or sets text to display
  74951. */
  74952. get text(): string;
  74953. /**
  74954. * Gets or sets text to display
  74955. */
  74956. set text(value: string);
  74957. /**
  74958. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74959. */
  74960. get textHorizontalAlignment(): number;
  74961. /**
  74962. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74963. */
  74964. set textHorizontalAlignment(value: number);
  74965. /**
  74966. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  74967. */
  74968. get textVerticalAlignment(): number;
  74969. /**
  74970. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  74971. */
  74972. set textVerticalAlignment(value: number);
  74973. /**
  74974. * Gets or sets line spacing value
  74975. */
  74976. set lineSpacing(value: string | number);
  74977. /**
  74978. * Gets or sets line spacing value
  74979. */
  74980. get lineSpacing(): string | number;
  74981. /**
  74982. * Gets or sets outlineWidth of the text to display
  74983. */
  74984. get outlineWidth(): number;
  74985. /**
  74986. * Gets or sets outlineWidth of the text to display
  74987. */
  74988. set outlineWidth(value: number);
  74989. /**
  74990. * Gets or sets outlineColor of the text to display
  74991. */
  74992. get outlineColor(): string;
  74993. /**
  74994. * Gets or sets outlineColor of the text to display
  74995. */
  74996. set outlineColor(value: string);
  74997. /**
  74998. * Creates a new TextBlock object
  74999. * @param name defines the name of the control
  75000. * @param text defines the text to display (emptry string by default)
  75001. */
  75002. constructor(
  75003. /**
  75004. * Defines the name of the control
  75005. */
  75006. name?: string | undefined, text?: string);
  75007. protected _getTypeName(): string;
  75008. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75009. private _drawText;
  75010. /** @hidden */
  75011. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75012. protected _applyStates(context: CanvasRenderingContext2D): void;
  75013. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75014. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75015. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75016. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75017. protected _renderLines(context: CanvasRenderingContext2D): void;
  75018. /**
  75019. * Given a width constraint applied on the text block, find the expected height
  75020. * @returns expected height
  75021. */
  75022. computeExpectedHeight(): number;
  75023. dispose(): void;
  75024. }
  75025. }
  75026. declare module BABYLON.GUI {
  75027. /**
  75028. * Class used to create 2D images
  75029. */
  75030. export class Image extends Control {
  75031. name?: string | undefined;
  75032. private _workingCanvas;
  75033. private _domImage;
  75034. private _imageWidth;
  75035. private _imageHeight;
  75036. private _loaded;
  75037. private _stretch;
  75038. private _source;
  75039. private _autoScale;
  75040. private _sourceLeft;
  75041. private _sourceTop;
  75042. private _sourceWidth;
  75043. private _sourceHeight;
  75044. private _svgAttributesComputationCompleted;
  75045. private _isSVG;
  75046. private _cellWidth;
  75047. private _cellHeight;
  75048. private _cellId;
  75049. private _populateNinePatchSlicesFromImage;
  75050. private _sliceLeft;
  75051. private _sliceRight;
  75052. private _sliceTop;
  75053. private _sliceBottom;
  75054. private _detectPointerOnOpaqueOnly;
  75055. /**
  75056. * BABYLON.Observable notified when the content is loaded
  75057. */
  75058. onImageLoadedObservable: BABYLON.Observable<Image>;
  75059. /**
  75060. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75061. */
  75062. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75063. /**
  75064. * Gets a boolean indicating that the content is loaded
  75065. */
  75066. get isLoaded(): boolean;
  75067. /**
  75068. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75069. */
  75070. get populateNinePatchSlicesFromImage(): boolean;
  75071. set populateNinePatchSlicesFromImage(value: boolean);
  75072. /**
  75073. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75074. * Beware using this as this will comsume more memory as the image has to be stored twice
  75075. */
  75076. get detectPointerOnOpaqueOnly(): boolean;
  75077. set detectPointerOnOpaqueOnly(value: boolean);
  75078. /**
  75079. * Gets or sets the left value for slicing (9-patch)
  75080. */
  75081. get sliceLeft(): number;
  75082. set sliceLeft(value: number);
  75083. /**
  75084. * Gets or sets the right value for slicing (9-patch)
  75085. */
  75086. get sliceRight(): number;
  75087. set sliceRight(value: number);
  75088. /**
  75089. * Gets or sets the top value for slicing (9-patch)
  75090. */
  75091. get sliceTop(): number;
  75092. set sliceTop(value: number);
  75093. /**
  75094. * Gets or sets the bottom value for slicing (9-patch)
  75095. */
  75096. get sliceBottom(): number;
  75097. set sliceBottom(value: number);
  75098. /**
  75099. * Gets or sets the left coordinate in the source image
  75100. */
  75101. get sourceLeft(): number;
  75102. set sourceLeft(value: number);
  75103. /**
  75104. * Gets or sets the top coordinate in the source image
  75105. */
  75106. get sourceTop(): number;
  75107. set sourceTop(value: number);
  75108. /**
  75109. * Gets or sets the width to capture in the source image
  75110. */
  75111. get sourceWidth(): number;
  75112. set sourceWidth(value: number);
  75113. /**
  75114. * Gets or sets the height to capture in the source image
  75115. */
  75116. get sourceHeight(): number;
  75117. set sourceHeight(value: number);
  75118. /** Indicates if the format of the image is SVG */
  75119. get isSVG(): boolean;
  75120. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75121. get svgAttributesComputationCompleted(): boolean;
  75122. /**
  75123. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75124. * @see http://doc.babylonjs.com/how_to/gui#image
  75125. */
  75126. get autoScale(): boolean;
  75127. set autoScale(value: boolean);
  75128. /** Gets or sets the streching mode used by the image */
  75129. get stretch(): number;
  75130. set stretch(value: number);
  75131. /** @hidden */
  75132. _rotate90(n: number, preserveProperties?: boolean): Image;
  75133. private _handleRotationForSVGImage;
  75134. private _rotate90SourceProperties;
  75135. /**
  75136. * Gets or sets the internal DOM image used to render the control
  75137. */
  75138. set domImage(value: HTMLImageElement);
  75139. get domImage(): HTMLImageElement;
  75140. private _onImageLoaded;
  75141. private _extractNinePatchSliceDataFromImage;
  75142. /**
  75143. * Gets or sets image source url
  75144. */
  75145. set source(value: BABYLON.Nullable<string>);
  75146. /**
  75147. * Checks for svg document with icon id present
  75148. */
  75149. private _svgCheck;
  75150. /**
  75151. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75152. * given external svg file and icon id
  75153. */
  75154. private _getSVGAttribs;
  75155. /**
  75156. * Gets or sets the cell width to use when animation sheet is enabled
  75157. * @see http://doc.babylonjs.com/how_to/gui#image
  75158. */
  75159. get cellWidth(): number;
  75160. set cellWidth(value: number);
  75161. /**
  75162. * Gets or sets the cell height to use when animation sheet is enabled
  75163. * @see http://doc.babylonjs.com/how_to/gui#image
  75164. */
  75165. get cellHeight(): number;
  75166. set cellHeight(value: number);
  75167. /**
  75168. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75169. * @see http://doc.babylonjs.com/how_to/gui#image
  75170. */
  75171. get cellId(): number;
  75172. set cellId(value: number);
  75173. /**
  75174. * Creates a new Image
  75175. * @param name defines the control name
  75176. * @param url defines the image url
  75177. */
  75178. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75179. /**
  75180. * Tests if a given coordinates belong to the current control
  75181. * @param x defines x coordinate to test
  75182. * @param y defines y coordinate to test
  75183. * @returns true if the coordinates are inside the control
  75184. */
  75185. contains(x: number, y: number): boolean;
  75186. protected _getTypeName(): string;
  75187. /** Force the control to synchronize with its content */
  75188. synchronizeSizeWithContent(): void;
  75189. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75190. private _prepareWorkingCanvasForOpaqueDetection;
  75191. private _drawImage;
  75192. _draw(context: CanvasRenderingContext2D): void;
  75193. private _renderCornerPatch;
  75194. private _renderNinePatch;
  75195. dispose(): void;
  75196. /** STRETCH_NONE */
  75197. static readonly STRETCH_NONE: number;
  75198. /** STRETCH_FILL */
  75199. static readonly STRETCH_FILL: number;
  75200. /** STRETCH_UNIFORM */
  75201. static readonly STRETCH_UNIFORM: number;
  75202. /** STRETCH_EXTEND */
  75203. static readonly STRETCH_EXTEND: number;
  75204. /** NINE_PATCH */
  75205. static readonly STRETCH_NINE_PATCH: number;
  75206. }
  75207. }
  75208. declare module BABYLON.GUI {
  75209. /**
  75210. * Class used to create 2D buttons
  75211. */
  75212. export class Button extends Rectangle {
  75213. name?: string | undefined;
  75214. /**
  75215. * Function called to generate a pointer enter animation
  75216. */
  75217. pointerEnterAnimation: () => void;
  75218. /**
  75219. * Function called to generate a pointer out animation
  75220. */
  75221. pointerOutAnimation: () => void;
  75222. /**
  75223. * Function called to generate a pointer down animation
  75224. */
  75225. pointerDownAnimation: () => void;
  75226. /**
  75227. * Function called to generate a pointer up animation
  75228. */
  75229. pointerUpAnimation: () => void;
  75230. /**
  75231. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75232. */
  75233. delegatePickingToChildren: boolean;
  75234. private _image;
  75235. /**
  75236. * Returns the image part of the button (if any)
  75237. */
  75238. get image(): BABYLON.Nullable<Image>;
  75239. private _textBlock;
  75240. /**
  75241. * Returns the image part of the button (if any)
  75242. */
  75243. get textBlock(): BABYLON.Nullable<TextBlock>;
  75244. /**
  75245. * Creates a new Button
  75246. * @param name defines the name of the button
  75247. */
  75248. constructor(name?: string | undefined);
  75249. protected _getTypeName(): string;
  75250. /** @hidden */
  75251. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75252. /** @hidden */
  75253. _onPointerEnter(target: Control): boolean;
  75254. /** @hidden */
  75255. _onPointerOut(target: Control, force?: boolean): void;
  75256. /** @hidden */
  75257. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75258. /** @hidden */
  75259. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75260. /**
  75261. * Creates a new button made with an image and a text
  75262. * @param name defines the name of the button
  75263. * @param text defines the text of the button
  75264. * @param imageUrl defines the url of the image
  75265. * @returns a new Button
  75266. */
  75267. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75268. /**
  75269. * Creates a new button made with an image
  75270. * @param name defines the name of the button
  75271. * @param imageUrl defines the url of the image
  75272. * @returns a new Button
  75273. */
  75274. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75275. /**
  75276. * Creates a new button made with a text
  75277. * @param name defines the name of the button
  75278. * @param text defines the text of the button
  75279. * @returns a new Button
  75280. */
  75281. static CreateSimpleButton(name: string, text: string): Button;
  75282. /**
  75283. * Creates a new button made with an image and a centered text
  75284. * @param name defines the name of the button
  75285. * @param text defines the text of the button
  75286. * @param imageUrl defines the url of the image
  75287. * @returns a new Button
  75288. */
  75289. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75290. }
  75291. }
  75292. declare module BABYLON.GUI {
  75293. /**
  75294. * Class used to create a 2D stack panel container
  75295. */
  75296. export class StackPanel extends Container {
  75297. name?: string | undefined;
  75298. private _isVertical;
  75299. private _manualWidth;
  75300. private _manualHeight;
  75301. private _doNotTrackManualChanges;
  75302. /**
  75303. * Gets or sets a boolean indicating that layou warnings should be ignored
  75304. */
  75305. ignoreLayoutWarnings: boolean;
  75306. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75307. get isVertical(): boolean;
  75308. set isVertical(value: boolean);
  75309. /**
  75310. * Gets or sets panel width.
  75311. * This value should not be set when in horizontal mode as it will be computed automatically
  75312. */
  75313. set width(value: string | number);
  75314. get width(): string | number;
  75315. /**
  75316. * Gets or sets panel height.
  75317. * This value should not be set when in vertical mode as it will be computed automatically
  75318. */
  75319. set height(value: string | number);
  75320. get height(): string | number;
  75321. /**
  75322. * Creates a new StackPanel
  75323. * @param name defines control name
  75324. */
  75325. constructor(name?: string | undefined);
  75326. protected _getTypeName(): string;
  75327. /** @hidden */
  75328. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75329. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75330. protected _postMeasure(): void;
  75331. }
  75332. }
  75333. declare module BABYLON.GUI {
  75334. /**
  75335. * Class used to represent a 2D checkbox
  75336. */
  75337. export class Checkbox extends Control {
  75338. name?: string | undefined;
  75339. private _isChecked;
  75340. private _background;
  75341. private _checkSizeRatio;
  75342. private _thickness;
  75343. /** Gets or sets border thickness */
  75344. get thickness(): number;
  75345. set thickness(value: number);
  75346. /**
  75347. * BABYLON.Observable raised when isChecked property changes
  75348. */
  75349. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75350. /** Gets or sets a value indicating the ratio between overall size and check size */
  75351. get checkSizeRatio(): number;
  75352. set checkSizeRatio(value: number);
  75353. /** Gets or sets background color */
  75354. get background(): string;
  75355. set background(value: string);
  75356. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75357. get isChecked(): boolean;
  75358. set isChecked(value: boolean);
  75359. /**
  75360. * Creates a new CheckBox
  75361. * @param name defines the control name
  75362. */
  75363. constructor(name?: string | undefined);
  75364. protected _getTypeName(): string;
  75365. /** @hidden */
  75366. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75367. /** @hidden */
  75368. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75369. /**
  75370. * Utility function to easily create a checkbox with a header
  75371. * @param title defines the label to use for the header
  75372. * @param onValueChanged defines the callback to call when value changes
  75373. * @returns a StackPanel containing the checkbox and a textBlock
  75374. */
  75375. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  75376. }
  75377. }
  75378. declare module BABYLON.GUI {
  75379. /**
  75380. * Class used to store key control properties
  75381. */
  75382. export class KeyPropertySet {
  75383. /** Width */
  75384. width?: string;
  75385. /** Height */
  75386. height?: string;
  75387. /** Left padding */
  75388. paddingLeft?: string;
  75389. /** Right padding */
  75390. paddingRight?: string;
  75391. /** Top padding */
  75392. paddingTop?: string;
  75393. /** Bottom padding */
  75394. paddingBottom?: string;
  75395. /** Foreground color */
  75396. color?: string;
  75397. /** Background color */
  75398. background?: string;
  75399. }
  75400. /**
  75401. * Class used to create virtual keyboard
  75402. */
  75403. export class VirtualKeyboard extends StackPanel {
  75404. /** BABYLON.Observable raised when a key is pressed */
  75405. onKeyPressObservable: BABYLON.Observable<string>;
  75406. /** Gets or sets default key button width */
  75407. defaultButtonWidth: string;
  75408. /** Gets or sets default key button height */
  75409. defaultButtonHeight: string;
  75410. /** Gets or sets default key button left padding */
  75411. defaultButtonPaddingLeft: string;
  75412. /** Gets or sets default key button right padding */
  75413. defaultButtonPaddingRight: string;
  75414. /** Gets or sets default key button top padding */
  75415. defaultButtonPaddingTop: string;
  75416. /** Gets or sets default key button bottom padding */
  75417. defaultButtonPaddingBottom: string;
  75418. /** Gets or sets default key button foreground color */
  75419. defaultButtonColor: string;
  75420. /** Gets or sets default key button background color */
  75421. defaultButtonBackground: string;
  75422. /** Gets or sets shift button foreground color */
  75423. shiftButtonColor: string;
  75424. /** Gets or sets shift button thickness*/
  75425. selectedShiftThickness: number;
  75426. /** Gets shift key state */
  75427. shiftState: number;
  75428. protected _getTypeName(): string;
  75429. private _createKey;
  75430. /**
  75431. * Adds a new row of keys
  75432. * @param keys defines the list of keys to add
  75433. * @param propertySets defines the associated property sets
  75434. */
  75435. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  75436. /**
  75437. * Set the shift key to a specific state
  75438. * @param shiftState defines the new shift state
  75439. */
  75440. applyShiftState(shiftState: number): void;
  75441. private _currentlyConnectedInputText;
  75442. private _connectedInputTexts;
  75443. private _onKeyPressObserver;
  75444. /** Gets the input text control currently attached to the keyboard */
  75445. get connectedInputText(): BABYLON.Nullable<InputText>;
  75446. /**
  75447. * Connects the keyboard with an input text control
  75448. *
  75449. * @param input defines the target control
  75450. */
  75451. connect(input: InputText): void;
  75452. /**
  75453. * Disconnects the keyboard from connected InputText controls
  75454. *
  75455. * @param input optionally defines a target control, otherwise all are disconnected
  75456. */
  75457. disconnect(input?: InputText): void;
  75458. private _removeConnectedInputObservables;
  75459. /**
  75460. * Release all resources
  75461. */
  75462. dispose(): void;
  75463. /**
  75464. * Creates a new keyboard using a default layout
  75465. *
  75466. * @param name defines control name
  75467. * @returns a new VirtualKeyboard
  75468. */
  75469. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  75470. }
  75471. }
  75472. declare module BABYLON.GUI {
  75473. /**
  75474. * Class used to create input text control
  75475. */
  75476. export class InputText extends Control implements IFocusableControl {
  75477. name?: string | undefined;
  75478. private _text;
  75479. private _placeholderText;
  75480. private _background;
  75481. private _focusedBackground;
  75482. private _focusedColor;
  75483. private _placeholderColor;
  75484. private _thickness;
  75485. private _margin;
  75486. private _autoStretchWidth;
  75487. private _maxWidth;
  75488. private _isFocused;
  75489. private _blinkTimeout;
  75490. private _blinkIsEven;
  75491. private _cursorOffset;
  75492. private _scrollLeft;
  75493. private _textWidth;
  75494. private _clickedCoordinate;
  75495. private _deadKey;
  75496. private _addKey;
  75497. private _currentKey;
  75498. private _isTextHighlightOn;
  75499. private _textHighlightColor;
  75500. private _highligherOpacity;
  75501. private _highlightedText;
  75502. private _startHighlightIndex;
  75503. private _endHighlightIndex;
  75504. private _cursorIndex;
  75505. private _onFocusSelectAll;
  75506. private _isPointerDown;
  75507. private _onClipboardObserver;
  75508. private _onPointerDblTapObserver;
  75509. /** @hidden */
  75510. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  75511. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  75512. promptMessage: string;
  75513. /** Force disable prompt on mobile device */
  75514. disableMobilePrompt: boolean;
  75515. /** BABYLON.Observable raised when the text changes */
  75516. onTextChangedObservable: BABYLON.Observable<InputText>;
  75517. /** BABYLON.Observable raised just before an entered character is to be added */
  75518. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  75519. /** BABYLON.Observable raised when the control gets the focus */
  75520. onFocusObservable: BABYLON.Observable<InputText>;
  75521. /** BABYLON.Observable raised when the control loses the focus */
  75522. onBlurObservable: BABYLON.Observable<InputText>;
  75523. /**Observable raised when the text is highlighted */
  75524. onTextHighlightObservable: BABYLON.Observable<InputText>;
  75525. /**Observable raised when copy event is triggered */
  75526. onTextCopyObservable: BABYLON.Observable<InputText>;
  75527. /** BABYLON.Observable raised when cut event is triggered */
  75528. onTextCutObservable: BABYLON.Observable<InputText>;
  75529. /** BABYLON.Observable raised when paste event is triggered */
  75530. onTextPasteObservable: BABYLON.Observable<InputText>;
  75531. /** BABYLON.Observable raised when a key event was processed */
  75532. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  75533. /** Gets or sets the maximum width allowed by the control */
  75534. get maxWidth(): string | number;
  75535. /** Gets the maximum width allowed by the control in pixels */
  75536. get maxWidthInPixels(): number;
  75537. set maxWidth(value: string | number);
  75538. /** Gets or sets the text highlighter transparency; default: 0.4 */
  75539. get highligherOpacity(): number;
  75540. set highligherOpacity(value: number);
  75541. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  75542. get onFocusSelectAll(): boolean;
  75543. set onFocusSelectAll(value: boolean);
  75544. /** Gets or sets the text hightlight color */
  75545. get textHighlightColor(): string;
  75546. set textHighlightColor(value: string);
  75547. /** Gets or sets control margin */
  75548. get margin(): string;
  75549. /** Gets control margin in pixels */
  75550. get marginInPixels(): number;
  75551. set margin(value: string);
  75552. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  75553. get autoStretchWidth(): boolean;
  75554. set autoStretchWidth(value: boolean);
  75555. /** Gets or sets border thickness */
  75556. get thickness(): number;
  75557. set thickness(value: number);
  75558. /** Gets or sets the background color when focused */
  75559. get focusedBackground(): string;
  75560. set focusedBackground(value: string);
  75561. /** Gets or sets the background color when focused */
  75562. get focusedColor(): string;
  75563. set focusedColor(value: string);
  75564. /** Gets or sets the background color */
  75565. get background(): string;
  75566. set background(value: string);
  75567. /** Gets or sets the placeholder color */
  75568. get placeholderColor(): string;
  75569. set placeholderColor(value: string);
  75570. /** Gets or sets the text displayed when the control is empty */
  75571. get placeholderText(): string;
  75572. set placeholderText(value: string);
  75573. /** Gets or sets the dead key flag */
  75574. get deadKey(): boolean;
  75575. set deadKey(flag: boolean);
  75576. /** Gets or sets the highlight text */
  75577. get highlightedText(): string;
  75578. set highlightedText(text: string);
  75579. /** Gets or sets if the current key should be added */
  75580. get addKey(): boolean;
  75581. set addKey(flag: boolean);
  75582. /** Gets or sets the value of the current key being entered */
  75583. get currentKey(): string;
  75584. set currentKey(key: string);
  75585. /** Gets or sets the text displayed in the control */
  75586. get text(): string;
  75587. set text(value: string);
  75588. /** Gets or sets control width */
  75589. get width(): string | number;
  75590. set width(value: string | number);
  75591. /**
  75592. * Creates a new InputText
  75593. * @param name defines the control name
  75594. * @param text defines the text of the control
  75595. */
  75596. constructor(name?: string | undefined, text?: string);
  75597. /** @hidden */
  75598. onBlur(): void;
  75599. /** @hidden */
  75600. onFocus(): void;
  75601. protected _getTypeName(): string;
  75602. /**
  75603. * Function called to get the list of controls that should not steal the focus from this control
  75604. * @returns an array of controls
  75605. */
  75606. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75607. /** @hidden */
  75608. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  75609. /** @hidden */
  75610. private _updateValueFromCursorIndex;
  75611. /** @hidden */
  75612. private _processDblClick;
  75613. /** @hidden */
  75614. private _selectAllText;
  75615. /**
  75616. * Handles the keyboard event
  75617. * @param evt Defines the KeyboardEvent
  75618. */
  75619. processKeyboard(evt: KeyboardEvent): void;
  75620. /** @hidden */
  75621. private _onCopyText;
  75622. /** @hidden */
  75623. private _onCutText;
  75624. /** @hidden */
  75625. private _onPasteText;
  75626. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75627. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75628. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75629. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75630. protected _beforeRenderText(text: string): string;
  75631. dispose(): void;
  75632. }
  75633. }
  75634. declare module BABYLON.GUI {
  75635. /**
  75636. * Class used to create a 2D grid container
  75637. */
  75638. export class Grid extends Container {
  75639. name?: string | undefined;
  75640. private _rowDefinitions;
  75641. private _columnDefinitions;
  75642. private _cells;
  75643. private _childControls;
  75644. /**
  75645. * Gets the number of columns
  75646. */
  75647. get columnCount(): number;
  75648. /**
  75649. * Gets the number of rows
  75650. */
  75651. get rowCount(): number;
  75652. /** Gets the list of children */
  75653. get children(): Control[];
  75654. /** Gets the list of cells (e.g. the containers) */
  75655. get cells(): {
  75656. [key: string]: Container;
  75657. };
  75658. /**
  75659. * Gets the definition of a specific row
  75660. * @param index defines the index of the row
  75661. * @returns the row definition
  75662. */
  75663. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75664. /**
  75665. * Gets the definition of a specific column
  75666. * @param index defines the index of the column
  75667. * @returns the column definition
  75668. */
  75669. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75670. /**
  75671. * Adds a new row to the grid
  75672. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75673. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  75674. * @returns the current grid
  75675. */
  75676. addRowDefinition(height: number, isPixel?: boolean): Grid;
  75677. /**
  75678. * Adds a new column to the grid
  75679. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75680. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75681. * @returns the current grid
  75682. */
  75683. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  75684. /**
  75685. * Update a row definition
  75686. * @param index defines the index of the row to update
  75687. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75688. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  75689. * @returns the current grid
  75690. */
  75691. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  75692. /**
  75693. * Update a column definition
  75694. * @param index defines the index of the column to update
  75695. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75696. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75697. * @returns the current grid
  75698. */
  75699. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  75700. /**
  75701. * Gets the list of children stored in a specific cell
  75702. * @param row defines the row to check
  75703. * @param column defines the column to check
  75704. * @returns the list of controls
  75705. */
  75706. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  75707. /**
  75708. * Gets a string representing the child cell info (row x column)
  75709. * @param child defines the control to get info from
  75710. * @returns a string containing the child cell info (row x column)
  75711. */
  75712. getChildCellInfo(child: Control): string;
  75713. private _removeCell;
  75714. private _offsetCell;
  75715. /**
  75716. * Remove a column definition at specified index
  75717. * @param index defines the index of the column to remove
  75718. * @returns the current grid
  75719. */
  75720. removeColumnDefinition(index: number): Grid;
  75721. /**
  75722. * Remove a row definition at specified index
  75723. * @param index defines the index of the row to remove
  75724. * @returns the current grid
  75725. */
  75726. removeRowDefinition(index: number): Grid;
  75727. /**
  75728. * Adds a new control to the current grid
  75729. * @param control defines the control to add
  75730. * @param row defines the row where to add the control (0 by default)
  75731. * @param column defines the column where to add the control (0 by default)
  75732. * @returns the current grid
  75733. */
  75734. addControl(control: Control, row?: number, column?: number): Grid;
  75735. /**
  75736. * Removes a control from the current container
  75737. * @param control defines the control to remove
  75738. * @returns the current container
  75739. */
  75740. removeControl(control: Control): Container;
  75741. /**
  75742. * Creates a new Grid
  75743. * @param name defines control name
  75744. */
  75745. constructor(name?: string | undefined);
  75746. protected _getTypeName(): string;
  75747. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  75748. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75749. _flagDescendantsAsMatrixDirty(): void;
  75750. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75751. /** Releases associated resources */
  75752. dispose(): void;
  75753. }
  75754. }
  75755. declare module BABYLON.GUI {
  75756. /** Class used to create color pickers */
  75757. export class ColorPicker extends Control {
  75758. name?: string | undefined;
  75759. private static _Epsilon;
  75760. private _colorWheelCanvas;
  75761. private _value;
  75762. private _tmpColor;
  75763. private _pointerStartedOnSquare;
  75764. private _pointerStartedOnWheel;
  75765. private _squareLeft;
  75766. private _squareTop;
  75767. private _squareSize;
  75768. private _h;
  75769. private _s;
  75770. private _v;
  75771. private _lastPointerDownID;
  75772. /**
  75773. * BABYLON.Observable raised when the value changes
  75774. */
  75775. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  75776. /** Gets or sets the color of the color picker */
  75777. get value(): BABYLON.Color3;
  75778. set value(value: BABYLON.Color3);
  75779. /**
  75780. * Gets or sets control width
  75781. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75782. */
  75783. get width(): string | number;
  75784. set width(value: string | number);
  75785. /**
  75786. * Gets or sets control height
  75787. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75788. */
  75789. get height(): string | number;
  75790. /** Gets or sets control height */
  75791. set height(value: string | number);
  75792. /** Gets or sets control size */
  75793. get size(): string | number;
  75794. set size(value: string | number);
  75795. /**
  75796. * Creates a new ColorPicker
  75797. * @param name defines the control name
  75798. */
  75799. constructor(name?: string | undefined);
  75800. protected _getTypeName(): string;
  75801. /** @hidden */
  75802. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75803. private _updateSquareProps;
  75804. private _drawGradientSquare;
  75805. private _drawCircle;
  75806. private _createColorWheelCanvas;
  75807. /** @hidden */
  75808. _draw(context: CanvasRenderingContext2D): void;
  75809. private _pointerIsDown;
  75810. private _updateValueFromPointer;
  75811. private _isPointOnSquare;
  75812. private _isPointOnWheel;
  75813. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75814. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75815. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75816. /**
  75817. * This function expands the color picker by creating a color picker dialog with manual
  75818. * color value input and the ability to save colors into an array to be used later in
  75819. * subsequent launches of the dialogue.
  75820. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  75821. * @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.
  75822. * @returns picked color as a hex string and the saved colors array as hex strings.
  75823. */
  75824. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  75825. pickerWidth?: string;
  75826. pickerHeight?: string;
  75827. headerHeight?: string;
  75828. lastColor?: string;
  75829. swatchLimit?: number;
  75830. numSwatchesPerLine?: number;
  75831. savedColors?: Array<string>;
  75832. }): Promise<{
  75833. savedColors?: string[];
  75834. pickedColor: string;
  75835. }>;
  75836. }
  75837. }
  75838. declare module BABYLON.GUI {
  75839. /** Class used to create 2D ellipse containers */
  75840. export class Ellipse extends Container {
  75841. name?: string | undefined;
  75842. private _thickness;
  75843. /** Gets or sets border thickness */
  75844. get thickness(): number;
  75845. set thickness(value: number);
  75846. /**
  75847. * Creates a new Ellipse
  75848. * @param name defines the control name
  75849. */
  75850. constructor(name?: string | undefined);
  75851. protected _getTypeName(): string;
  75852. protected _localDraw(context: CanvasRenderingContext2D): void;
  75853. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75854. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75855. }
  75856. }
  75857. declare module BABYLON.GUI {
  75858. /**
  75859. * Class used to create a password control
  75860. */
  75861. export class InputPassword extends InputText {
  75862. protected _beforeRenderText(text: string): string;
  75863. }
  75864. }
  75865. declare module BABYLON.GUI {
  75866. /** Class used to render 2D lines */
  75867. export class Line extends Control {
  75868. name?: string | undefined;
  75869. private _lineWidth;
  75870. private _x1;
  75871. private _y1;
  75872. private _x2;
  75873. private _y2;
  75874. private _dash;
  75875. private _connectedControl;
  75876. private _connectedControlDirtyObserver;
  75877. /** Gets or sets the dash pattern */
  75878. get dash(): Array<number>;
  75879. set dash(value: Array<number>);
  75880. /** Gets or sets the control connected with the line end */
  75881. get connectedControl(): Control;
  75882. set connectedControl(value: Control);
  75883. /** Gets or sets start coordinates on X axis */
  75884. get x1(): string | number;
  75885. set x1(value: string | number);
  75886. /** Gets or sets start coordinates on Y axis */
  75887. get y1(): string | number;
  75888. set y1(value: string | number);
  75889. /** Gets or sets end coordinates on X axis */
  75890. get x2(): string | number;
  75891. set x2(value: string | number);
  75892. /** Gets or sets end coordinates on Y axis */
  75893. get y2(): string | number;
  75894. set y2(value: string | number);
  75895. /** Gets or sets line width */
  75896. get lineWidth(): number;
  75897. set lineWidth(value: number);
  75898. /** Gets or sets horizontal alignment */
  75899. set horizontalAlignment(value: number);
  75900. /** Gets or sets vertical alignment */
  75901. set verticalAlignment(value: number);
  75902. private get _effectiveX2();
  75903. private get _effectiveY2();
  75904. /**
  75905. * Creates a new Line
  75906. * @param name defines the control name
  75907. */
  75908. constructor(name?: string | undefined);
  75909. protected _getTypeName(): string;
  75910. _draw(context: CanvasRenderingContext2D): void;
  75911. _measure(): void;
  75912. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75913. /**
  75914. * Move one end of the line given 3D cartesian coordinates.
  75915. * @param position Targeted world position
  75916. * @param scene BABYLON.Scene
  75917. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  75918. */
  75919. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  75920. /**
  75921. * Move one end of the line to a position in screen absolute space.
  75922. * @param projectedPosition Position in screen absolute space (X, Y)
  75923. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  75924. */
  75925. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  75926. }
  75927. }
  75928. declare module BABYLON.GUI {
  75929. /**
  75930. * Class used to store a point for a MultiLine object.
  75931. * The point can be pure 2D coordinates, a mesh or a control
  75932. */
  75933. export class MultiLinePoint {
  75934. private _multiLine;
  75935. private _x;
  75936. private _y;
  75937. private _control;
  75938. private _mesh;
  75939. private _controlObserver;
  75940. private _meshObserver;
  75941. /** @hidden */
  75942. _point: BABYLON.Vector2;
  75943. /**
  75944. * Creates a new MultiLinePoint
  75945. * @param multiLine defines the source MultiLine object
  75946. */
  75947. constructor(multiLine: MultiLine);
  75948. /** Gets or sets x coordinate */
  75949. get x(): string | number;
  75950. set x(value: string | number);
  75951. /** Gets or sets y coordinate */
  75952. get y(): string | number;
  75953. set y(value: string | number);
  75954. /** Gets or sets the control associated with this point */
  75955. get control(): BABYLON.Nullable<Control>;
  75956. set control(value: BABYLON.Nullable<Control>);
  75957. /** Gets or sets the mesh associated with this point */
  75958. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75959. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  75960. /** Resets links */
  75961. resetLinks(): void;
  75962. /**
  75963. * Gets a translation vector
  75964. * @returns the translation vector
  75965. */
  75966. translate(): BABYLON.Vector2;
  75967. private _translatePoint;
  75968. /** Release associated resources */
  75969. dispose(): void;
  75970. }
  75971. }
  75972. declare module BABYLON.GUI {
  75973. /**
  75974. * Class used to create multi line control
  75975. */
  75976. export class MultiLine extends Control {
  75977. name?: string | undefined;
  75978. private _lineWidth;
  75979. private _dash;
  75980. private _points;
  75981. private _minX;
  75982. private _minY;
  75983. private _maxX;
  75984. private _maxY;
  75985. /**
  75986. * Creates a new MultiLine
  75987. * @param name defines the control name
  75988. */
  75989. constructor(name?: string | undefined);
  75990. /** Gets or sets dash pattern */
  75991. get dash(): Array<number>;
  75992. set dash(value: Array<number>);
  75993. /**
  75994. * Gets point stored at specified index
  75995. * @param index defines the index to look for
  75996. * @returns the requested point if found
  75997. */
  75998. getAt(index: number): MultiLinePoint;
  75999. /** Function called when a point is updated */
  76000. onPointUpdate: () => void;
  76001. /**
  76002. * Adds new points to the point collection
  76003. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76004. * @returns the list of created MultiLinePoint
  76005. */
  76006. add(...items: (AbstractMesh | Control | {
  76007. x: string | number;
  76008. y: string | number;
  76009. })[]): MultiLinePoint[];
  76010. /**
  76011. * Adds a new point to the point collection
  76012. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76013. * @returns the created MultiLinePoint
  76014. */
  76015. push(item?: (AbstractMesh | Control | {
  76016. x: string | number;
  76017. y: string | number;
  76018. })): MultiLinePoint;
  76019. /**
  76020. * Remove a specific value or point from the active point collection
  76021. * @param value defines the value or point to remove
  76022. */
  76023. remove(value: number | MultiLinePoint): void;
  76024. /**
  76025. * Resets this object to initial state (no point)
  76026. */
  76027. reset(): void;
  76028. /**
  76029. * Resets all links
  76030. */
  76031. resetLinks(): void;
  76032. /** Gets or sets line width */
  76033. get lineWidth(): number;
  76034. set lineWidth(value: number);
  76035. set horizontalAlignment(value: number);
  76036. set verticalAlignment(value: number);
  76037. protected _getTypeName(): string;
  76038. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76039. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76040. _measure(): void;
  76041. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76042. dispose(): void;
  76043. }
  76044. }
  76045. declare module BABYLON.GUI {
  76046. /**
  76047. * Class used to create radio button controls
  76048. */
  76049. export class RadioButton extends Control {
  76050. name?: string | undefined;
  76051. private _isChecked;
  76052. private _background;
  76053. private _checkSizeRatio;
  76054. private _thickness;
  76055. /** Gets or sets border thickness */
  76056. get thickness(): number;
  76057. set thickness(value: number);
  76058. /** Gets or sets group name */
  76059. group: string;
  76060. /** BABYLON.Observable raised when isChecked is changed */
  76061. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76062. /** Gets or sets a value indicating the ratio between overall size and check size */
  76063. get checkSizeRatio(): number;
  76064. set checkSizeRatio(value: number);
  76065. /** Gets or sets background color */
  76066. get background(): string;
  76067. set background(value: string);
  76068. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76069. get isChecked(): boolean;
  76070. set isChecked(value: boolean);
  76071. /**
  76072. * Creates a new RadioButton
  76073. * @param name defines the control name
  76074. */
  76075. constructor(name?: string | undefined);
  76076. protected _getTypeName(): string;
  76077. _draw(context: CanvasRenderingContext2D): void;
  76078. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76079. /**
  76080. * Utility function to easily create a radio button with a header
  76081. * @param title defines the label to use for the header
  76082. * @param group defines the group to use for the radio button
  76083. * @param isChecked defines the initial state of the radio button
  76084. * @param onValueChanged defines the callback to call when value changes
  76085. * @returns a StackPanel containing the radio button and a textBlock
  76086. */
  76087. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76088. }
  76089. }
  76090. declare module BABYLON.GUI {
  76091. /**
  76092. * Class used to create slider controls
  76093. */
  76094. export class BaseSlider extends Control {
  76095. name?: string | undefined;
  76096. protected _thumbWidth: ValueAndUnit;
  76097. private _minimum;
  76098. private _maximum;
  76099. private _value;
  76100. private _isVertical;
  76101. protected _barOffset: ValueAndUnit;
  76102. private _isThumbClamped;
  76103. protected _displayThumb: boolean;
  76104. private _step;
  76105. private _lastPointerDownID;
  76106. protected _effectiveBarOffset: number;
  76107. protected _renderLeft: number;
  76108. protected _renderTop: number;
  76109. protected _renderWidth: number;
  76110. protected _renderHeight: number;
  76111. protected _backgroundBoxLength: number;
  76112. protected _backgroundBoxThickness: number;
  76113. protected _effectiveThumbThickness: number;
  76114. /** BABYLON.Observable raised when the sldier value changes */
  76115. onValueChangedObservable: BABYLON.Observable<number>;
  76116. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76117. get displayThumb(): boolean;
  76118. set displayThumb(value: boolean);
  76119. /** Gets or sets a step to apply to values (0 by default) */
  76120. get step(): number;
  76121. set step(value: number);
  76122. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76123. get barOffset(): string | number;
  76124. /** Gets main bar offset in pixels*/
  76125. get barOffsetInPixels(): number;
  76126. set barOffset(value: string | number);
  76127. /** Gets or sets thumb width */
  76128. get thumbWidth(): string | number;
  76129. /** Gets thumb width in pixels */
  76130. get thumbWidthInPixels(): number;
  76131. set thumbWidth(value: string | number);
  76132. /** Gets or sets minimum value */
  76133. get minimum(): number;
  76134. set minimum(value: number);
  76135. /** Gets or sets maximum value */
  76136. get maximum(): number;
  76137. set maximum(value: number);
  76138. /** Gets or sets current value */
  76139. get value(): number;
  76140. set value(value: number);
  76141. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76142. get isVertical(): boolean;
  76143. set isVertical(value: boolean);
  76144. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76145. get isThumbClamped(): boolean;
  76146. set isThumbClamped(value: boolean);
  76147. /**
  76148. * Creates a new BaseSlider
  76149. * @param name defines the control name
  76150. */
  76151. constructor(name?: string | undefined);
  76152. protected _getTypeName(): string;
  76153. protected _getThumbPosition(): number;
  76154. protected _getThumbThickness(type: string): number;
  76155. protected _prepareRenderingData(type: string): void;
  76156. private _pointerIsDown;
  76157. /** @hidden */
  76158. protected _updateValueFromPointer(x: number, y: number): void;
  76159. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76160. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76161. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76162. }
  76163. }
  76164. declare module BABYLON.GUI {
  76165. /**
  76166. * Class used to create slider controls
  76167. */
  76168. export class Slider extends BaseSlider {
  76169. name?: string | undefined;
  76170. private _background;
  76171. private _borderColor;
  76172. private _isThumbCircle;
  76173. protected _displayValueBar: boolean;
  76174. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76175. get displayValueBar(): boolean;
  76176. set displayValueBar(value: boolean);
  76177. /** Gets or sets border color */
  76178. get borderColor(): string;
  76179. set borderColor(value: string);
  76180. /** Gets or sets background color */
  76181. get background(): string;
  76182. set background(value: string);
  76183. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76184. get isThumbCircle(): boolean;
  76185. set isThumbCircle(value: boolean);
  76186. /**
  76187. * Creates a new Slider
  76188. * @param name defines the control name
  76189. */
  76190. constructor(name?: string | undefined);
  76191. protected _getTypeName(): string;
  76192. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76193. }
  76194. }
  76195. declare module BABYLON.GUI {
  76196. /** Class used to create a RadioGroup
  76197. * which contains groups of radio buttons
  76198. */
  76199. export class SelectorGroup {
  76200. /** name of SelectorGroup */
  76201. name: string;
  76202. private _groupPanel;
  76203. private _selectors;
  76204. private _groupHeader;
  76205. /**
  76206. * Creates a new SelectorGroup
  76207. * @param name of group, used as a group heading
  76208. */
  76209. constructor(
  76210. /** name of SelectorGroup */
  76211. name: string);
  76212. /** Gets the groupPanel of the SelectorGroup */
  76213. get groupPanel(): StackPanel;
  76214. /** Gets the selectors array */
  76215. get selectors(): StackPanel[];
  76216. /** Gets and sets the group header */
  76217. get header(): string;
  76218. set header(label: string);
  76219. /** @hidden */
  76220. private _addGroupHeader;
  76221. /** @hidden*/
  76222. _getSelector(selectorNb: number): StackPanel | undefined;
  76223. /** Removes the selector at the given position
  76224. * @param selectorNb the position of the selector within the group
  76225. */
  76226. removeSelector(selectorNb: number): void;
  76227. }
  76228. /** Class used to create a CheckboxGroup
  76229. * which contains groups of checkbox buttons
  76230. */
  76231. export class CheckboxGroup extends SelectorGroup {
  76232. /** Adds a checkbox as a control
  76233. * @param text is the label for the selector
  76234. * @param func is the function called when the Selector is checked
  76235. * @param checked is true when Selector is checked
  76236. */
  76237. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76238. /** @hidden */
  76239. _setSelectorLabel(selectorNb: number, label: string): void;
  76240. /** @hidden */
  76241. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76242. /** @hidden */
  76243. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76244. /** @hidden */
  76245. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76246. }
  76247. /** Class used to create a RadioGroup
  76248. * which contains groups of radio buttons
  76249. */
  76250. export class RadioGroup extends SelectorGroup {
  76251. private _selectNb;
  76252. /** Adds a radio button as a control
  76253. * @param label is the label for the selector
  76254. * @param func is the function called when the Selector is checked
  76255. * @param checked is true when Selector is checked
  76256. */
  76257. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76258. /** @hidden */
  76259. _setSelectorLabel(selectorNb: number, label: string): void;
  76260. /** @hidden */
  76261. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76262. /** @hidden */
  76263. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76264. /** @hidden */
  76265. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76266. }
  76267. /** Class used to create a SliderGroup
  76268. * which contains groups of slider buttons
  76269. */
  76270. export class SliderGroup extends SelectorGroup {
  76271. /**
  76272. * Adds a slider to the SelectorGroup
  76273. * @param label is the label for the SliderBar
  76274. * @param func is the function called when the Slider moves
  76275. * @param unit is a string describing the units used, eg degrees or metres
  76276. * @param min is the minimum value for the Slider
  76277. * @param max is the maximum value for the Slider
  76278. * @param value is the start value for the Slider between min and max
  76279. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76280. */
  76281. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76282. /** @hidden */
  76283. _setSelectorLabel(selectorNb: number, label: string): void;
  76284. /** @hidden */
  76285. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76286. /** @hidden */
  76287. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76288. /** @hidden */
  76289. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76290. }
  76291. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76292. * @see http://doc.babylonjs.com/how_to/selector
  76293. */
  76294. export class SelectionPanel extends Rectangle {
  76295. /** name of SelectionPanel */
  76296. name: string;
  76297. /** an array of SelectionGroups */
  76298. groups: SelectorGroup[];
  76299. private _panel;
  76300. private _buttonColor;
  76301. private _buttonBackground;
  76302. private _headerColor;
  76303. private _barColor;
  76304. private _barHeight;
  76305. private _spacerHeight;
  76306. private _labelColor;
  76307. private _groups;
  76308. private _bars;
  76309. /**
  76310. * Creates a new SelectionPanel
  76311. * @param name of SelectionPanel
  76312. * @param groups is an array of SelectionGroups
  76313. */
  76314. constructor(
  76315. /** name of SelectionPanel */
  76316. name: string,
  76317. /** an array of SelectionGroups */
  76318. groups?: SelectorGroup[]);
  76319. protected _getTypeName(): string;
  76320. /** Gets or sets the headerColor */
  76321. get headerColor(): string;
  76322. set headerColor(color: string);
  76323. private _setHeaderColor;
  76324. /** Gets or sets the button color */
  76325. get buttonColor(): string;
  76326. set buttonColor(color: string);
  76327. private _setbuttonColor;
  76328. /** Gets or sets the label color */
  76329. get labelColor(): string;
  76330. set labelColor(color: string);
  76331. private _setLabelColor;
  76332. /** Gets or sets the button background */
  76333. get buttonBackground(): string;
  76334. set buttonBackground(color: string);
  76335. private _setButtonBackground;
  76336. /** Gets or sets the color of separator bar */
  76337. get barColor(): string;
  76338. set barColor(color: string);
  76339. private _setBarColor;
  76340. /** Gets or sets the height of separator bar */
  76341. get barHeight(): string;
  76342. set barHeight(value: string);
  76343. private _setBarHeight;
  76344. /** Gets or sets the height of spacers*/
  76345. get spacerHeight(): string;
  76346. set spacerHeight(value: string);
  76347. private _setSpacerHeight;
  76348. /** Adds a bar between groups */
  76349. private _addSpacer;
  76350. /** Add a group to the selection panel
  76351. * @param group is the selector group to add
  76352. */
  76353. addGroup(group: SelectorGroup): void;
  76354. /** Remove the group from the given position
  76355. * @param groupNb is the position of the group in the list
  76356. */
  76357. removeGroup(groupNb: number): void;
  76358. /** Change a group header label
  76359. * @param label is the new group header label
  76360. * @param groupNb is the number of the group to relabel
  76361. * */
  76362. setHeaderName(label: string, groupNb: number): void;
  76363. /** Change selector label to the one given
  76364. * @param label is the new selector label
  76365. * @param groupNb is the number of the groupcontaining the selector
  76366. * @param selectorNb is the number of the selector within a group to relabel
  76367. * */
  76368. relabel(label: string, groupNb: number, selectorNb: number): void;
  76369. /** For a given group position remove the selector at the given position
  76370. * @param groupNb is the number of the group to remove the selector from
  76371. * @param selectorNb is the number of the selector within the group
  76372. */
  76373. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  76374. /** For a given group position of correct type add a checkbox button
  76375. * @param groupNb is the number of the group to remove the selector from
  76376. * @param label is the label for the selector
  76377. * @param func is the function called when the Selector is checked
  76378. * @param checked is true when Selector is checked
  76379. */
  76380. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76381. /** For a given group position of correct type add a radio button
  76382. * @param groupNb is the number of the group to remove the selector from
  76383. * @param label is the label for the selector
  76384. * @param func is the function called when the Selector is checked
  76385. * @param checked is true when Selector is checked
  76386. */
  76387. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76388. /**
  76389. * For a given slider group add a slider
  76390. * @param groupNb is the number of the group to add the slider to
  76391. * @param label is the label for the Slider
  76392. * @param func is the function called when the Slider moves
  76393. * @param unit is a string describing the units used, eg degrees or metres
  76394. * @param min is the minimum value for the Slider
  76395. * @param max is the maximum value for the Slider
  76396. * @param value is the start value for the Slider between min and max
  76397. * @param onVal is the function used to format the value displayed, eg radians to degrees
  76398. */
  76399. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  76400. }
  76401. }
  76402. declare module BABYLON.GUI {
  76403. /**
  76404. * Class used to hold a the container for ScrollViewer
  76405. * @hidden
  76406. */
  76407. export class _ScrollViewerWindow extends Container {
  76408. parentClientWidth: number;
  76409. parentClientHeight: number;
  76410. private _freezeControls;
  76411. private _parentMeasure;
  76412. private _oldLeft;
  76413. private _oldTop;
  76414. get freezeControls(): boolean;
  76415. set freezeControls(value: boolean);
  76416. private _bucketWidth;
  76417. private _bucketHeight;
  76418. private _buckets;
  76419. private _bucketLen;
  76420. get bucketWidth(): number;
  76421. get bucketHeight(): number;
  76422. setBucketSizes(width: number, height: number): void;
  76423. private _useBuckets;
  76424. private _makeBuckets;
  76425. private _dispatchInBuckets;
  76426. private _updateMeasures;
  76427. private _updateChildrenMeasures;
  76428. private _restoreMeasures;
  76429. /**
  76430. * Creates a new ScrollViewerWindow
  76431. * @param name of ScrollViewerWindow
  76432. */
  76433. constructor(name?: string);
  76434. protected _getTypeName(): string;
  76435. /** @hidden */
  76436. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76437. /** @hidden */
  76438. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76439. private _scrollChildren;
  76440. private _scrollChildrenWithBuckets;
  76441. /** @hidden */
  76442. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76443. protected _postMeasure(): void;
  76444. }
  76445. }
  76446. declare module BABYLON.GUI {
  76447. /**
  76448. * Class used to create slider controls
  76449. */
  76450. export class ScrollBar extends BaseSlider {
  76451. name?: string | undefined;
  76452. private _background;
  76453. private _borderColor;
  76454. private _tempMeasure;
  76455. /** Gets or sets border color */
  76456. get borderColor(): string;
  76457. set borderColor(value: string);
  76458. /** Gets or sets background color */
  76459. get background(): string;
  76460. set background(value: string);
  76461. /**
  76462. * Creates a new Slider
  76463. * @param name defines the control name
  76464. */
  76465. constructor(name?: string | undefined);
  76466. protected _getTypeName(): string;
  76467. protected _getThumbThickness(): number;
  76468. _draw(context: CanvasRenderingContext2D): void;
  76469. private _first;
  76470. private _originX;
  76471. private _originY;
  76472. /** @hidden */
  76473. protected _updateValueFromPointer(x: number, y: number): void;
  76474. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76475. }
  76476. }
  76477. declare module BABYLON.GUI {
  76478. /**
  76479. * Class used to create slider controls
  76480. */
  76481. export class ImageScrollBar extends BaseSlider {
  76482. name?: string | undefined;
  76483. private _backgroundBaseImage;
  76484. private _backgroundImage;
  76485. private _thumbImage;
  76486. private _thumbBaseImage;
  76487. private _thumbLength;
  76488. private _thumbHeight;
  76489. private _barImageHeight;
  76490. private _tempMeasure;
  76491. /** Number of 90° rotation to apply on the images when in vertical mode */
  76492. num90RotationInVerticalMode: number;
  76493. /**
  76494. * Gets or sets the image used to render the background for horizontal bar
  76495. */
  76496. get backgroundImage(): Image;
  76497. set backgroundImage(value: Image);
  76498. /**
  76499. * Gets or sets the image used to render the thumb
  76500. */
  76501. get thumbImage(): Image;
  76502. set thumbImage(value: Image);
  76503. /**
  76504. * Gets or sets the length of the thumb
  76505. */
  76506. get thumbLength(): number;
  76507. set thumbLength(value: number);
  76508. /**
  76509. * Gets or sets the height of the thumb
  76510. */
  76511. get thumbHeight(): number;
  76512. set thumbHeight(value: number);
  76513. /**
  76514. * Gets or sets the height of the bar image
  76515. */
  76516. get barImageHeight(): number;
  76517. set barImageHeight(value: number);
  76518. /**
  76519. * Creates a new ImageScrollBar
  76520. * @param name defines the control name
  76521. */
  76522. constructor(name?: string | undefined);
  76523. protected _getTypeName(): string;
  76524. protected _getThumbThickness(): number;
  76525. _draw(context: CanvasRenderingContext2D): void;
  76526. private _first;
  76527. private _originX;
  76528. private _originY;
  76529. /** @hidden */
  76530. protected _updateValueFromPointer(x: number, y: number): void;
  76531. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76532. }
  76533. }
  76534. declare module BABYLON.GUI {
  76535. /**
  76536. * Class used to hold a viewer window and sliders in a grid
  76537. */
  76538. export class ScrollViewer extends Rectangle {
  76539. private _grid;
  76540. private _horizontalBarSpace;
  76541. private _verticalBarSpace;
  76542. private _dragSpace;
  76543. private _horizontalBar;
  76544. private _verticalBar;
  76545. private _barColor;
  76546. private _barBackground;
  76547. private _barImage;
  76548. private _horizontalBarImage;
  76549. private _verticalBarImage;
  76550. private _barBackgroundImage;
  76551. private _horizontalBarBackgroundImage;
  76552. private _verticalBarBackgroundImage;
  76553. private _barSize;
  76554. private _window;
  76555. private _pointerIsOver;
  76556. private _wheelPrecision;
  76557. private _onWheelObserver;
  76558. private _clientWidth;
  76559. private _clientHeight;
  76560. private _useImageBar;
  76561. private _thumbLength;
  76562. private _thumbHeight;
  76563. private _barImageHeight;
  76564. private _horizontalBarImageHeight;
  76565. private _verticalBarImageHeight;
  76566. private _oldWindowContentsWidth;
  76567. private _oldWindowContentsHeight;
  76568. /**
  76569. * Gets the horizontal scrollbar
  76570. */
  76571. get horizontalBar(): ScrollBar | ImageScrollBar;
  76572. /**
  76573. * Gets the vertical scrollbar
  76574. */
  76575. get verticalBar(): ScrollBar | ImageScrollBar;
  76576. /**
  76577. * Adds a new control to the current container
  76578. * @param control defines the control to add
  76579. * @returns the current container
  76580. */
  76581. addControl(control: BABYLON.Nullable<Control>): Container;
  76582. /**
  76583. * Removes a control from the current container
  76584. * @param control defines the control to remove
  76585. * @returns the current container
  76586. */
  76587. removeControl(control: Control): Container;
  76588. /** Gets the list of children */
  76589. get children(): Control[];
  76590. _flagDescendantsAsMatrixDirty(): void;
  76591. /**
  76592. * Freezes or unfreezes the controls in the window.
  76593. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  76594. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  76595. */
  76596. get freezeControls(): boolean;
  76597. set freezeControls(value: boolean);
  76598. /** Gets the bucket width */
  76599. get bucketWidth(): number;
  76600. /** Gets the bucket height */
  76601. get bucketHeight(): number;
  76602. /**
  76603. * Sets the bucket sizes.
  76604. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  76605. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  76606. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  76607. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  76608. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  76609. * used), that's why it is not enabled by default.
  76610. * @param width width of the bucket
  76611. * @param height height of the bucket
  76612. */
  76613. setBucketSizes(width: number, height: number): void;
  76614. private _forceHorizontalBar;
  76615. private _forceVerticalBar;
  76616. /**
  76617. * Forces the horizontal scroll bar to be displayed
  76618. */
  76619. get forceHorizontalBar(): boolean;
  76620. set forceHorizontalBar(value: boolean);
  76621. /**
  76622. * Forces the vertical scroll bar to be displayed
  76623. */
  76624. get forceVerticalBar(): boolean;
  76625. set forceVerticalBar(value: boolean);
  76626. /**
  76627. * Creates a new ScrollViewer
  76628. * @param name of ScrollViewer
  76629. */
  76630. constructor(name?: string, isImageBased?: boolean);
  76631. /** Reset the scroll viewer window to initial size */
  76632. resetWindow(): void;
  76633. protected _getTypeName(): string;
  76634. private _buildClientSizes;
  76635. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76636. protected _postMeasure(): void;
  76637. /**
  76638. * Gets or sets the mouse wheel precision
  76639. * from 0 to 1 with a default value of 0.05
  76640. * */
  76641. get wheelPrecision(): number;
  76642. set wheelPrecision(value: number);
  76643. /** Gets or sets the scroll bar container background color */
  76644. get scrollBackground(): string;
  76645. set scrollBackground(color: string);
  76646. /** Gets or sets the bar color */
  76647. get barColor(): string;
  76648. set barColor(color: string);
  76649. /** Gets or sets the bar image */
  76650. get thumbImage(): Image;
  76651. set thumbImage(value: Image);
  76652. /** Gets or sets the horizontal bar image */
  76653. get horizontalThumbImage(): Image;
  76654. set horizontalThumbImage(value: Image);
  76655. /** Gets or sets the vertical bar image */
  76656. get verticalThumbImage(): Image;
  76657. set verticalThumbImage(value: Image);
  76658. /** Gets or sets the size of the bar */
  76659. get barSize(): number;
  76660. set barSize(value: number);
  76661. /** Gets or sets the length of the thumb */
  76662. get thumbLength(): number;
  76663. set thumbLength(value: number);
  76664. /** Gets or sets the height of the thumb */
  76665. get thumbHeight(): number;
  76666. set thumbHeight(value: number);
  76667. /** Gets or sets the height of the bar image */
  76668. get barImageHeight(): number;
  76669. set barImageHeight(value: number);
  76670. /** Gets or sets the height of the horizontal bar image */
  76671. get horizontalBarImageHeight(): number;
  76672. set horizontalBarImageHeight(value: number);
  76673. /** Gets or sets the height of the vertical bar image */
  76674. get verticalBarImageHeight(): number;
  76675. set verticalBarImageHeight(value: number);
  76676. /** Gets or sets the bar background */
  76677. get barBackground(): string;
  76678. set barBackground(color: string);
  76679. /** Gets or sets the bar background image */
  76680. get barImage(): Image;
  76681. set barImage(value: Image);
  76682. /** Gets or sets the horizontal bar background image */
  76683. get horizontalBarImage(): Image;
  76684. set horizontalBarImage(value: Image);
  76685. /** Gets or sets the vertical bar background image */
  76686. get verticalBarImage(): Image;
  76687. set verticalBarImage(value: Image);
  76688. private _setWindowPosition;
  76689. /** @hidden */
  76690. private _updateScroller;
  76691. _link(host: AdvancedDynamicTexture): void;
  76692. /** @hidden */
  76693. private _addBar;
  76694. /** @hidden */
  76695. private _attachWheel;
  76696. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76697. /** Releases associated resources */
  76698. dispose(): void;
  76699. }
  76700. }
  76701. declare module BABYLON.GUI {
  76702. /** Class used to render a grid */
  76703. export class DisplayGrid extends Control {
  76704. name?: string | undefined;
  76705. private _cellWidth;
  76706. private _cellHeight;
  76707. private _minorLineTickness;
  76708. private _minorLineColor;
  76709. private _majorLineTickness;
  76710. private _majorLineColor;
  76711. private _majorLineFrequency;
  76712. private _background;
  76713. private _displayMajorLines;
  76714. private _displayMinorLines;
  76715. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  76716. get displayMinorLines(): boolean;
  76717. set displayMinorLines(value: boolean);
  76718. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  76719. get displayMajorLines(): boolean;
  76720. set displayMajorLines(value: boolean);
  76721. /** Gets or sets background color (Black by default) */
  76722. get background(): string;
  76723. set background(value: string);
  76724. /** Gets or sets the width of each cell (20 by default) */
  76725. get cellWidth(): number;
  76726. set cellWidth(value: number);
  76727. /** Gets or sets the height of each cell (20 by default) */
  76728. get cellHeight(): number;
  76729. set cellHeight(value: number);
  76730. /** Gets or sets the tickness of minor lines (1 by default) */
  76731. get minorLineTickness(): number;
  76732. set minorLineTickness(value: number);
  76733. /** Gets or sets the color of minor lines (DarkGray by default) */
  76734. get minorLineColor(): string;
  76735. set minorLineColor(value: string);
  76736. /** Gets or sets the tickness of major lines (2 by default) */
  76737. get majorLineTickness(): number;
  76738. set majorLineTickness(value: number);
  76739. /** Gets or sets the color of major lines (White by default) */
  76740. get majorLineColor(): string;
  76741. set majorLineColor(value: string);
  76742. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  76743. get majorLineFrequency(): number;
  76744. set majorLineFrequency(value: number);
  76745. /**
  76746. * Creates a new GridDisplayRectangle
  76747. * @param name defines the control name
  76748. */
  76749. constructor(name?: string | undefined);
  76750. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76751. protected _getTypeName(): string;
  76752. }
  76753. }
  76754. declare module BABYLON.GUI {
  76755. /**
  76756. * Class used to create slider controls based on images
  76757. */
  76758. export class ImageBasedSlider extends BaseSlider {
  76759. name?: string | undefined;
  76760. private _backgroundImage;
  76761. private _thumbImage;
  76762. private _valueBarImage;
  76763. private _tempMeasure;
  76764. get displayThumb(): boolean;
  76765. set displayThumb(value: boolean);
  76766. /**
  76767. * Gets or sets the image used to render the background
  76768. */
  76769. get backgroundImage(): Image;
  76770. set backgroundImage(value: Image);
  76771. /**
  76772. * Gets or sets the image used to render the value bar
  76773. */
  76774. get valueBarImage(): Image;
  76775. set valueBarImage(value: Image);
  76776. /**
  76777. * Gets or sets the image used to render the thumb
  76778. */
  76779. get thumbImage(): Image;
  76780. set thumbImage(value: Image);
  76781. /**
  76782. * Creates a new ImageBasedSlider
  76783. * @param name defines the control name
  76784. */
  76785. constructor(name?: string | undefined);
  76786. protected _getTypeName(): string;
  76787. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76788. }
  76789. }
  76790. declare module BABYLON.GUI {
  76791. /**
  76792. * Forcing an export so that this code will execute
  76793. * @hidden
  76794. */
  76795. const name = "Statics";
  76796. }
  76797. declare module BABYLON.GUI {
  76798. /**
  76799. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  76800. */
  76801. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  76802. /**
  76803. * Define the instrumented AdvancedDynamicTexture.
  76804. */
  76805. texture: AdvancedDynamicTexture;
  76806. private _captureRenderTime;
  76807. private _renderTime;
  76808. private _captureLayoutTime;
  76809. private _layoutTime;
  76810. private _onBeginRenderObserver;
  76811. private _onEndRenderObserver;
  76812. private _onBeginLayoutObserver;
  76813. private _onEndLayoutObserver;
  76814. /**
  76815. * Gets the perf counter used to capture render time
  76816. */
  76817. get renderTimeCounter(): BABYLON.PerfCounter;
  76818. /**
  76819. * Gets the perf counter used to capture layout time
  76820. */
  76821. get layoutTimeCounter(): BABYLON.PerfCounter;
  76822. /**
  76823. * Enable or disable the render time capture
  76824. */
  76825. get captureRenderTime(): boolean;
  76826. set captureRenderTime(value: boolean);
  76827. /**
  76828. * Enable or disable the layout time capture
  76829. */
  76830. get captureLayoutTime(): boolean;
  76831. set captureLayoutTime(value: boolean);
  76832. /**
  76833. * Instantiates a new advanced dynamic texture instrumentation.
  76834. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  76835. * @param texture Defines the AdvancedDynamicTexture to instrument
  76836. */
  76837. constructor(
  76838. /**
  76839. * Define the instrumented AdvancedDynamicTexture.
  76840. */
  76841. texture: AdvancedDynamicTexture);
  76842. /**
  76843. * Dispose and release associated resources.
  76844. */
  76845. dispose(): void;
  76846. }
  76847. }
  76848. declare module BABYLON.GUI {
  76849. /**
  76850. * Class used to load GUI via XML.
  76851. */
  76852. export class XmlLoader {
  76853. private _nodes;
  76854. private _nodeTypes;
  76855. private _isLoaded;
  76856. private _objectAttributes;
  76857. private _parentClass;
  76858. /**
  76859. * Create a new xml loader
  76860. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  76861. */
  76862. constructor(parentClass?: null);
  76863. private _getChainElement;
  76864. private _getClassAttribute;
  76865. private _createGuiElement;
  76866. private _parseGrid;
  76867. private _parseElement;
  76868. private _prepareSourceElement;
  76869. private _parseElementsFromSource;
  76870. private _parseXml;
  76871. /**
  76872. * Gets if the loading has finished.
  76873. * @returns whether the loading has finished or not
  76874. */
  76875. isLoaded(): boolean;
  76876. /**
  76877. * Gets a loaded node / control by id.
  76878. * @param id the Controls id set in the xml
  76879. * @returns element of type Control
  76880. */
  76881. getNodeById(id: string): any;
  76882. /**
  76883. * Gets all loaded nodes / controls
  76884. * @returns Array of controls
  76885. */
  76886. getNodes(): any;
  76887. /**
  76888. * Initiates the xml layout loading
  76889. * @param xmlFile defines the xml layout to load
  76890. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  76891. * @param callback defines the callback called on layout load.
  76892. */
  76893. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  76894. }
  76895. }
  76896. declare module BABYLON.GUI {
  76897. /**
  76898. * Class used to create containers for controls
  76899. */
  76900. export class Container3D extends Control3D {
  76901. private _blockLayout;
  76902. /**
  76903. * Gets the list of child controls
  76904. */
  76905. protected _children: Control3D[];
  76906. /**
  76907. * Gets the list of child controls
  76908. */
  76909. get children(): Array<Control3D>;
  76910. /**
  76911. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  76912. * This is helpful to optimize layout operation when adding multiple children in a row
  76913. */
  76914. get blockLayout(): boolean;
  76915. set blockLayout(value: boolean);
  76916. /**
  76917. * Creates a new container
  76918. * @param name defines the container name
  76919. */
  76920. constructor(name?: string);
  76921. /**
  76922. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  76923. * @returns the current container
  76924. */
  76925. updateLayout(): Container3D;
  76926. /**
  76927. * Gets a boolean indicating if the given control is in the children of this control
  76928. * @param control defines the control to check
  76929. * @returns true if the control is in the child list
  76930. */
  76931. containsControl(control: Control3D): boolean;
  76932. /**
  76933. * Adds a control to the children of this control
  76934. * @param control defines the control to add
  76935. * @returns the current container
  76936. */
  76937. addControl(control: Control3D): Container3D;
  76938. /**
  76939. * This function will be called everytime a new control is added
  76940. */
  76941. protected _arrangeChildren(): void;
  76942. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  76943. /**
  76944. * Removes a control from the children of this control
  76945. * @param control defines the control to remove
  76946. * @returns the current container
  76947. */
  76948. removeControl(control: Control3D): Container3D;
  76949. protected _getTypeName(): string;
  76950. /**
  76951. * Releases all associated resources
  76952. */
  76953. dispose(): void;
  76954. /** Control rotation will remain unchanged */
  76955. static readonly UNSET_ORIENTATION: number;
  76956. /** Control will rotate to make it look at sphere central axis */
  76957. static readonly FACEORIGIN_ORIENTATION: number;
  76958. /** Control will rotate to make it look back at sphere central axis */
  76959. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  76960. /** Control will rotate to look at z axis (0, 0, 1) */
  76961. static readonly FACEFORWARD_ORIENTATION: number;
  76962. /** Control will rotate to look at negative z axis (0, 0, -1) */
  76963. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  76964. }
  76965. }
  76966. declare module BABYLON.GUI {
  76967. /**
  76968. * Class used to manage 3D user interface
  76969. * @see http://doc.babylonjs.com/how_to/gui3d
  76970. */
  76971. export class GUI3DManager implements BABYLON.IDisposable {
  76972. private _scene;
  76973. private _sceneDisposeObserver;
  76974. private _utilityLayer;
  76975. private _rootContainer;
  76976. private _pointerObserver;
  76977. private _pointerOutObserver;
  76978. /** @hidden */
  76979. _lastPickedControl: Control3D;
  76980. /** @hidden */
  76981. _lastControlOver: {
  76982. [pointerId: number]: Control3D;
  76983. };
  76984. /** @hidden */
  76985. _lastControlDown: {
  76986. [pointerId: number]: Control3D;
  76987. };
  76988. /**
  76989. * BABYLON.Observable raised when the point picked by the pointer events changed
  76990. */
  76991. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  76992. /** @hidden */
  76993. _sharedMaterials: {
  76994. [key: string]: BABYLON.Material;
  76995. };
  76996. /** Gets the hosting scene */
  76997. get scene(): BABYLON.Scene;
  76998. /** Gets associated utility layer */
  76999. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77000. /**
  77001. * Creates a new GUI3DManager
  77002. * @param scene
  77003. */
  77004. constructor(scene?: BABYLON.Scene);
  77005. private _handlePointerOut;
  77006. private _doPicking;
  77007. /**
  77008. * Gets the root container
  77009. */
  77010. get rootContainer(): Container3D;
  77011. /**
  77012. * Gets a boolean indicating if the given control is in the root child list
  77013. * @param control defines the control to check
  77014. * @returns true if the control is in the root child list
  77015. */
  77016. containsControl(control: Control3D): boolean;
  77017. /**
  77018. * Adds a control to the root child list
  77019. * @param control defines the control to add
  77020. * @returns the current manager
  77021. */
  77022. addControl(control: Control3D): GUI3DManager;
  77023. /**
  77024. * Removes a control from the root child list
  77025. * @param control defines the control to remove
  77026. * @returns the current container
  77027. */
  77028. removeControl(control: Control3D): GUI3DManager;
  77029. /**
  77030. * Releases all associated resources
  77031. */
  77032. dispose(): void;
  77033. }
  77034. }
  77035. declare module BABYLON.GUI {
  77036. /**
  77037. * Class used to transport BABYLON.Vector3 information for pointer events
  77038. */
  77039. export class Vector3WithInfo extends BABYLON.Vector3 {
  77040. /** defines the current mouse button index */
  77041. buttonIndex: number;
  77042. /**
  77043. * Creates a new Vector3WithInfo
  77044. * @param source defines the vector3 data to transport
  77045. * @param buttonIndex defines the current mouse button index
  77046. */
  77047. constructor(source: BABYLON.Vector3,
  77048. /** defines the current mouse button index */
  77049. buttonIndex?: number);
  77050. }
  77051. }
  77052. declare module BABYLON.GUI {
  77053. /**
  77054. * Class used as base class for controls
  77055. */
  77056. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77057. /** Defines the control name */
  77058. name?: string | undefined;
  77059. /** @hidden */
  77060. _host: GUI3DManager;
  77061. private _node;
  77062. private _downCount;
  77063. private _enterCount;
  77064. private _downPointerIds;
  77065. private _isVisible;
  77066. /** Gets or sets the control position in world space */
  77067. get position(): BABYLON.Vector3;
  77068. set position(value: BABYLON.Vector3);
  77069. /** Gets or sets the control scaling in world space */
  77070. get scaling(): BABYLON.Vector3;
  77071. set scaling(value: BABYLON.Vector3);
  77072. /** Callback used to start pointer enter animation */
  77073. pointerEnterAnimation: () => void;
  77074. /** Callback used to start pointer out animation */
  77075. pointerOutAnimation: () => void;
  77076. /** Callback used to start pointer down animation */
  77077. pointerDownAnimation: () => void;
  77078. /** Callback used to start pointer up animation */
  77079. pointerUpAnimation: () => void;
  77080. /**
  77081. * An event triggered when the pointer move over the control
  77082. */
  77083. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77084. /**
  77085. * An event triggered when the pointer move out of the control
  77086. */
  77087. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77088. /**
  77089. * An event triggered when the pointer taps the control
  77090. */
  77091. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77092. /**
  77093. * An event triggered when pointer is up
  77094. */
  77095. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77096. /**
  77097. * An event triggered when a control is clicked on (with a mouse)
  77098. */
  77099. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77100. /**
  77101. * An event triggered when pointer enters the control
  77102. */
  77103. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77104. /**
  77105. * Gets or sets the parent container
  77106. */
  77107. parent: BABYLON.Nullable<Container3D>;
  77108. private _behaviors;
  77109. /**
  77110. * Gets the list of attached behaviors
  77111. * @see http://doc.babylonjs.com/features/behaviour
  77112. */
  77113. get behaviors(): BABYLON.Behavior<Control3D>[];
  77114. /**
  77115. * Attach a behavior to the control
  77116. * @see http://doc.babylonjs.com/features/behaviour
  77117. * @param behavior defines the behavior to attach
  77118. * @returns the current control
  77119. */
  77120. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77121. /**
  77122. * Remove an attached behavior
  77123. * @see http://doc.babylonjs.com/features/behaviour
  77124. * @param behavior defines the behavior to attach
  77125. * @returns the current control
  77126. */
  77127. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77128. /**
  77129. * Gets an attached behavior by name
  77130. * @param name defines the name of the behavior to look for
  77131. * @see http://doc.babylonjs.com/features/behaviour
  77132. * @returns null if behavior was not found else the requested behavior
  77133. */
  77134. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77135. /** Gets or sets a boolean indicating if the control is visible */
  77136. get isVisible(): boolean;
  77137. set isVisible(value: boolean);
  77138. /**
  77139. * Creates a new control
  77140. * @param name defines the control name
  77141. */
  77142. constructor(
  77143. /** Defines the control name */
  77144. name?: string | undefined);
  77145. /**
  77146. * Gets a string representing the class name
  77147. */
  77148. get typeName(): string;
  77149. /**
  77150. * Get the current class name of the control.
  77151. * @returns current class name
  77152. */
  77153. getClassName(): string;
  77154. protected _getTypeName(): string;
  77155. /**
  77156. * Gets the transform node used by this control
  77157. */
  77158. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77159. /**
  77160. * Gets the mesh used to render this control
  77161. */
  77162. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77163. /**
  77164. * Link the control as child of the given node
  77165. * @param node defines the node to link to. Use null to unlink the control
  77166. * @returns the current control
  77167. */
  77168. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77169. /** @hidden **/
  77170. _prepareNode(scene: BABYLON.Scene): void;
  77171. /**
  77172. * Node creation.
  77173. * Can be overriden by children
  77174. * @param scene defines the scene where the node must be attached
  77175. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77176. */
  77177. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77178. /**
  77179. * Affect a material to the given mesh
  77180. * @param mesh defines the mesh which will represent the control
  77181. */
  77182. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77183. /** @hidden */
  77184. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77185. /** @hidden */
  77186. _onPointerEnter(target: Control3D): boolean;
  77187. /** @hidden */
  77188. _onPointerOut(target: Control3D): void;
  77189. /** @hidden */
  77190. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77191. /** @hidden */
  77192. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77193. /** @hidden */
  77194. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77195. /** @hidden */
  77196. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77197. /** @hidden */
  77198. _disposeNode(): void;
  77199. /**
  77200. * Releases all associated resources
  77201. */
  77202. dispose(): void;
  77203. }
  77204. }
  77205. declare module BABYLON.GUI {
  77206. /**
  77207. * Class used as a root to all buttons
  77208. */
  77209. export class AbstractButton3D extends Control3D {
  77210. /**
  77211. * Creates a new button
  77212. * @param name defines the control name
  77213. */
  77214. constructor(name?: string);
  77215. protected _getTypeName(): string;
  77216. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77217. }
  77218. }
  77219. declare module BABYLON.GUI {
  77220. /**
  77221. * Class used to create a button in 3D
  77222. */
  77223. export class Button3D extends AbstractButton3D {
  77224. /** @hidden */
  77225. protected _currentMaterial: BABYLON.Material;
  77226. private _facadeTexture;
  77227. private _content;
  77228. private _contentResolution;
  77229. private _contentScaleRatio;
  77230. /**
  77231. * Gets or sets the texture resolution used to render content (512 by default)
  77232. */
  77233. get contentResolution(): BABYLON.int;
  77234. set contentResolution(value: BABYLON.int);
  77235. /**
  77236. * Gets or sets the texture scale ratio used to render content (2 by default)
  77237. */
  77238. get contentScaleRatio(): number;
  77239. set contentScaleRatio(value: number);
  77240. protected _disposeFacadeTexture(): void;
  77241. protected _resetContent(): void;
  77242. /**
  77243. * Creates a new button
  77244. * @param name defines the control name
  77245. */
  77246. constructor(name?: string);
  77247. /**
  77248. * Gets or sets the GUI 2D content used to display the button's facade
  77249. */
  77250. get content(): Control;
  77251. set content(value: Control);
  77252. /**
  77253. * Apply the facade texture (created from the content property).
  77254. * This function can be overloaded by child classes
  77255. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77256. */
  77257. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77258. protected _getTypeName(): string;
  77259. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77260. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77261. /**
  77262. * Releases all associated resources
  77263. */
  77264. dispose(): void;
  77265. }
  77266. }
  77267. declare module BABYLON.GUI {
  77268. /**
  77269. * Abstract class used to create a container panel deployed on the surface of a volume
  77270. */
  77271. export abstract class VolumeBasedPanel extends Container3D {
  77272. private _columns;
  77273. private _rows;
  77274. private _rowThenColum;
  77275. private _orientation;
  77276. protected _cellWidth: number;
  77277. protected _cellHeight: number;
  77278. /**
  77279. * Gets or sets the distance between elements
  77280. */
  77281. margin: number;
  77282. /**
  77283. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77284. * | Value | Type | Description |
  77285. * | ----- | ----------------------------------- | ----------- |
  77286. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77287. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77288. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77289. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77290. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77291. */
  77292. get orientation(): number;
  77293. set orientation(value: number);
  77294. /**
  77295. * Gets or sets the number of columns requested (10 by default).
  77296. * The panel will automatically compute the number of rows based on number of child controls.
  77297. */
  77298. get columns(): BABYLON.int;
  77299. set columns(value: BABYLON.int);
  77300. /**
  77301. * Gets or sets a the number of rows requested.
  77302. * The panel will automatically compute the number of columns based on number of child controls.
  77303. */
  77304. get rows(): BABYLON.int;
  77305. set rows(value: BABYLON.int);
  77306. /**
  77307. * Creates new VolumeBasedPanel
  77308. */
  77309. constructor();
  77310. protected _arrangeChildren(): void;
  77311. /** Child classes must implement this function to provide correct control positioning */
  77312. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77313. /** Child classes can implement this function to provide additional processing */
  77314. protected _finalProcessing(): void;
  77315. }
  77316. }
  77317. declare module BABYLON.GUI {
  77318. /**
  77319. * Class used to create a container panel deployed on the surface of a cylinder
  77320. */
  77321. export class CylinderPanel extends VolumeBasedPanel {
  77322. private _radius;
  77323. /**
  77324. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  77325. */
  77326. get radius(): BABYLON.float;
  77327. set radius(value: BABYLON.float);
  77328. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77329. private _cylindricalMapping;
  77330. }
  77331. }
  77332. declare module BABYLON.GUI {
  77333. /** @hidden */
  77334. export var fluentVertexShader: {
  77335. name: string;
  77336. shader: string;
  77337. };
  77338. }
  77339. declare module BABYLON.GUI {
  77340. /** @hidden */
  77341. export var fluentPixelShader: {
  77342. name: string;
  77343. shader: string;
  77344. };
  77345. }
  77346. declare module BABYLON.GUI {
  77347. /** @hidden */
  77348. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  77349. INNERGLOW: boolean;
  77350. BORDER: boolean;
  77351. HOVERLIGHT: boolean;
  77352. TEXTURE: boolean;
  77353. constructor();
  77354. }
  77355. /**
  77356. * Class used to render controls with fluent desgin
  77357. */
  77358. export class FluentMaterial extends BABYLON.PushMaterial {
  77359. /**
  77360. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  77361. */
  77362. innerGlowColorIntensity: number;
  77363. /**
  77364. * Gets or sets the inner glow color (white by default)
  77365. */
  77366. innerGlowColor: BABYLON.Color3;
  77367. /**
  77368. * Gets or sets alpha value (default is 1.0)
  77369. */
  77370. alpha: number;
  77371. /**
  77372. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  77373. */
  77374. albedoColor: BABYLON.Color3;
  77375. /**
  77376. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  77377. */
  77378. renderBorders: boolean;
  77379. /**
  77380. * Gets or sets border width (default is 0.5)
  77381. */
  77382. borderWidth: number;
  77383. /**
  77384. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  77385. */
  77386. edgeSmoothingValue: number;
  77387. /**
  77388. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  77389. */
  77390. borderMinValue: number;
  77391. /**
  77392. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  77393. */
  77394. renderHoverLight: boolean;
  77395. /**
  77396. * Gets or sets the radius used to render the hover light (default is 1.0)
  77397. */
  77398. hoverRadius: number;
  77399. /**
  77400. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  77401. */
  77402. hoverColor: BABYLON.Color4;
  77403. /**
  77404. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  77405. */
  77406. hoverPosition: BABYLON.Vector3;
  77407. private _albedoTexture;
  77408. /** Gets or sets the texture to use for albedo color */
  77409. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77410. /**
  77411. * Creates a new Fluent material
  77412. * @param name defines the name of the material
  77413. * @param scene defines the hosting scene
  77414. */
  77415. constructor(name: string, scene: BABYLON.Scene);
  77416. needAlphaBlending(): boolean;
  77417. needAlphaTesting(): boolean;
  77418. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77419. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77420. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77421. getActiveTextures(): BABYLON.BaseTexture[];
  77422. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77423. dispose(forceDisposeEffect?: boolean): void;
  77424. clone(name: string): FluentMaterial;
  77425. serialize(): any;
  77426. getClassName(): string;
  77427. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  77428. }
  77429. }
  77430. declare module BABYLON.GUI {
  77431. /**
  77432. * Class used to create a holographic button in 3D
  77433. */
  77434. export class HolographicButton extends Button3D {
  77435. private _backPlate;
  77436. private _textPlate;
  77437. private _frontPlate;
  77438. private _text;
  77439. private _imageUrl;
  77440. private _shareMaterials;
  77441. private _frontMaterial;
  77442. private _backMaterial;
  77443. private _plateMaterial;
  77444. private _pickedPointObserver;
  77445. private _tooltipFade;
  77446. private _tooltipTextBlock;
  77447. private _tooltipTexture;
  77448. private _tooltipMesh;
  77449. private _tooltipHoverObserver;
  77450. private _tooltipOutObserver;
  77451. private _disposeTooltip;
  77452. /**
  77453. * Rendering ground id of all the mesh in the button
  77454. */
  77455. set renderingGroupId(id: number);
  77456. get renderingGroupId(): number;
  77457. /**
  77458. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  77459. */
  77460. set tooltipText(text: BABYLON.Nullable<string>);
  77461. get tooltipText(): BABYLON.Nullable<string>;
  77462. /**
  77463. * Gets or sets text for the button
  77464. */
  77465. get text(): string;
  77466. set text(value: string);
  77467. /**
  77468. * Gets or sets the image url for the button
  77469. */
  77470. get imageUrl(): string;
  77471. set imageUrl(value: string);
  77472. /**
  77473. * Gets the back material used by this button
  77474. */
  77475. get backMaterial(): FluentMaterial;
  77476. /**
  77477. * Gets the front material used by this button
  77478. */
  77479. get frontMaterial(): FluentMaterial;
  77480. /**
  77481. * Gets the plate material used by this button
  77482. */
  77483. get plateMaterial(): BABYLON.StandardMaterial;
  77484. /**
  77485. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  77486. */
  77487. get shareMaterials(): boolean;
  77488. /**
  77489. * Creates a new button
  77490. * @param name defines the control name
  77491. */
  77492. constructor(name?: string, shareMaterials?: boolean);
  77493. protected _getTypeName(): string;
  77494. private _rebuildContent;
  77495. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77496. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77497. private _createBackMaterial;
  77498. private _createFrontMaterial;
  77499. private _createPlateMaterial;
  77500. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  77501. /**
  77502. * Releases all associated resources
  77503. */
  77504. dispose(): void;
  77505. }
  77506. }
  77507. declare module BABYLON.GUI {
  77508. /**
  77509. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  77510. */
  77511. export class MeshButton3D extends Button3D {
  77512. /** @hidden */
  77513. protected _currentMesh: BABYLON.Mesh;
  77514. /**
  77515. * Creates a new 3D button based on a mesh
  77516. * @param mesh mesh to become a 3D button
  77517. * @param name defines the control name
  77518. */
  77519. constructor(mesh: BABYLON.Mesh, name?: string);
  77520. protected _getTypeName(): string;
  77521. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77522. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77523. }
  77524. }
  77525. declare module BABYLON.GUI {
  77526. /**
  77527. * Class used to create a container panel deployed on the surface of a plane
  77528. */
  77529. export class PlanePanel extends VolumeBasedPanel {
  77530. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77531. }
  77532. }
  77533. declare module BABYLON.GUI {
  77534. /**
  77535. * Class used to create a container panel where items get randomized planar mapping
  77536. */
  77537. export class ScatterPanel extends VolumeBasedPanel {
  77538. private _iteration;
  77539. /**
  77540. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  77541. */
  77542. get iteration(): BABYLON.float;
  77543. set iteration(value: BABYLON.float);
  77544. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77545. private _scatterMapping;
  77546. protected _finalProcessing(): void;
  77547. }
  77548. }
  77549. declare module BABYLON.GUI {
  77550. /**
  77551. * Class used to create a container panel deployed on the surface of a sphere
  77552. */
  77553. export class SpherePanel extends VolumeBasedPanel {
  77554. private _radius;
  77555. /**
  77556. * Gets or sets the radius of the sphere where to project controls (5 by default)
  77557. */
  77558. get radius(): BABYLON.float;
  77559. set radius(value: BABYLON.float);
  77560. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77561. private _sphericalMapping;
  77562. }
  77563. }
  77564. declare module BABYLON.GUI {
  77565. /**
  77566. * Class used to create a stack panel in 3D on XY plane
  77567. */
  77568. export class StackPanel3D extends Container3D {
  77569. private _isVertical;
  77570. /**
  77571. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  77572. */
  77573. get isVertical(): boolean;
  77574. set isVertical(value: boolean);
  77575. /**
  77576. * Gets or sets the distance between elements
  77577. */
  77578. margin: number;
  77579. /**
  77580. * Creates new StackPanel
  77581. * @param isVertical
  77582. */
  77583. constructor(isVertical?: boolean);
  77584. protected _arrangeChildren(): void;
  77585. }
  77586. }
  77587. declare module BABYLON {
  77588. /**
  77589. * Configuration for glTF validation
  77590. */
  77591. export interface IGLTFValidationConfiguration {
  77592. /**
  77593. * The url of the glTF validator.
  77594. */
  77595. url: string;
  77596. }
  77597. /**
  77598. * glTF validation
  77599. */
  77600. export class GLTFValidation {
  77601. /**
  77602. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  77603. */
  77604. static Configuration: IGLTFValidationConfiguration;
  77605. private static _LoadScriptPromise;
  77606. /**
  77607. * Validate a glTF asset using the glTF-Validator.
  77608. * @param data The JSON of a glTF or the array buffer of a binary glTF
  77609. * @param rootUrl The root url for the glTF
  77610. * @param fileName The file name for the glTF
  77611. * @param getExternalResource The callback to get external resources for the glTF validator
  77612. * @returns A promise that resolves with the glTF validation results once complete
  77613. */
  77614. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  77615. }
  77616. }
  77617. declare module BABYLON {
  77618. /**
  77619. * Mode that determines the coordinate system to use.
  77620. */
  77621. export enum GLTFLoaderCoordinateSystemMode {
  77622. /**
  77623. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  77624. */
  77625. AUTO = 0,
  77626. /**
  77627. * Sets the useRightHandedSystem flag on the scene.
  77628. */
  77629. FORCE_RIGHT_HANDED = 1
  77630. }
  77631. /**
  77632. * Mode that determines what animations will start.
  77633. */
  77634. export enum GLTFLoaderAnimationStartMode {
  77635. /**
  77636. * No animation will start.
  77637. */
  77638. NONE = 0,
  77639. /**
  77640. * The first animation will start.
  77641. */
  77642. FIRST = 1,
  77643. /**
  77644. * All animations will start.
  77645. */
  77646. ALL = 2
  77647. }
  77648. /**
  77649. * Interface that contains the data for the glTF asset.
  77650. */
  77651. export interface IGLTFLoaderData {
  77652. /**
  77653. * The object that represents the glTF JSON.
  77654. */
  77655. json: Object;
  77656. /**
  77657. * The BIN chunk of a binary glTF.
  77658. */
  77659. bin: Nullable<IDataBuffer>;
  77660. }
  77661. /**
  77662. * Interface for extending the loader.
  77663. */
  77664. export interface IGLTFLoaderExtension {
  77665. /**
  77666. * The name of this extension.
  77667. */
  77668. readonly name: string;
  77669. /**
  77670. * Defines whether this extension is enabled.
  77671. */
  77672. enabled: boolean;
  77673. /**
  77674. * Defines the order of this extension.
  77675. * The loader sorts the extensions using these values when loading.
  77676. */
  77677. order?: number;
  77678. }
  77679. /**
  77680. * Loader state.
  77681. */
  77682. export enum GLTFLoaderState {
  77683. /**
  77684. * The asset is loading.
  77685. */
  77686. LOADING = 0,
  77687. /**
  77688. * The asset is ready for rendering.
  77689. */
  77690. READY = 1,
  77691. /**
  77692. * The asset is completely loaded.
  77693. */
  77694. COMPLETE = 2
  77695. }
  77696. /** @hidden */
  77697. export interface IImportMeshAsyncOutput {
  77698. meshes: AbstractMesh[];
  77699. particleSystems: IParticleSystem[];
  77700. skeletons: Skeleton[];
  77701. animationGroups: AnimationGroup[];
  77702. lights: Light[];
  77703. transformNodes: TransformNode[];
  77704. }
  77705. /** @hidden */
  77706. export interface IGLTFLoader extends IDisposable {
  77707. readonly state: Nullable<GLTFLoaderState>;
  77708. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  77709. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  77710. }
  77711. /**
  77712. * File loader for loading glTF files into a scene.
  77713. */
  77714. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77715. /** @hidden */
  77716. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77717. /** @hidden */
  77718. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77719. /**
  77720. * Raised when the asset has been parsed
  77721. */
  77722. onParsedObservable: Observable<IGLTFLoaderData>;
  77723. private _onParsedObserver;
  77724. /**
  77725. * Raised when the asset has been parsed
  77726. */
  77727. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  77728. /**
  77729. * 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.
  77730. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  77731. * Defaults to true.
  77732. * @hidden
  77733. */
  77734. static IncrementalLoading: boolean;
  77735. /**
  77736. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  77737. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  77738. * @hidden
  77739. */
  77740. static HomogeneousCoordinates: boolean;
  77741. /**
  77742. * The coordinate system mode. Defaults to AUTO.
  77743. */
  77744. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  77745. /**
  77746. * The animation start mode. Defaults to FIRST.
  77747. */
  77748. animationStartMode: GLTFLoaderAnimationStartMode;
  77749. /**
  77750. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  77751. */
  77752. compileMaterials: boolean;
  77753. /**
  77754. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  77755. */
  77756. useClipPlane: boolean;
  77757. /**
  77758. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  77759. */
  77760. compileShadowGenerators: boolean;
  77761. /**
  77762. * Defines if the Alpha blended materials are only applied as coverage.
  77763. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  77764. * If true, no extra effects are applied to transparent pixels.
  77765. */
  77766. transparencyAsCoverage: boolean;
  77767. /**
  77768. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  77769. * Enabling will disable offline support and glTF validator.
  77770. * Defaults to false.
  77771. */
  77772. useRangeRequests: boolean;
  77773. /**
  77774. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  77775. */
  77776. createInstances: boolean;
  77777. /**
  77778. * Function called before loading a url referenced by the asset.
  77779. */
  77780. preprocessUrlAsync: (url: string) => Promise<string>;
  77781. /**
  77782. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77783. */
  77784. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  77785. private _onMeshLoadedObserver;
  77786. /**
  77787. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77788. */
  77789. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  77790. /**
  77791. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  77792. */
  77793. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  77794. private _onTextureLoadedObserver;
  77795. /**
  77796. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  77797. */
  77798. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  77799. /**
  77800. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  77801. */
  77802. readonly onMaterialLoadedObservable: Observable<Material>;
  77803. private _onMaterialLoadedObserver;
  77804. /**
  77805. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  77806. */
  77807. set onMaterialLoaded(callback: (material: Material) => void);
  77808. /**
  77809. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  77810. */
  77811. readonly onCameraLoadedObservable: Observable<Camera>;
  77812. private _onCameraLoadedObserver;
  77813. /**
  77814. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  77815. */
  77816. set onCameraLoaded(callback: (camera: Camera) => void);
  77817. /**
  77818. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  77819. * For assets with LODs, raised when all of the LODs are complete.
  77820. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77821. */
  77822. readonly onCompleteObservable: Observable<void>;
  77823. private _onCompleteObserver;
  77824. /**
  77825. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  77826. * For assets with LODs, raised when all of the LODs are complete.
  77827. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77828. */
  77829. set onComplete(callback: () => void);
  77830. /**
  77831. * Observable raised when an error occurs.
  77832. */
  77833. readonly onErrorObservable: Observable<any>;
  77834. private _onErrorObserver;
  77835. /**
  77836. * Callback raised when an error occurs.
  77837. */
  77838. set onError(callback: (reason: any) => void);
  77839. /**
  77840. * Observable raised after the loader is disposed.
  77841. */
  77842. readonly onDisposeObservable: Observable<void>;
  77843. private _onDisposeObserver;
  77844. /**
  77845. * Callback raised after the loader is disposed.
  77846. */
  77847. set onDispose(callback: () => void);
  77848. /**
  77849. * Observable raised after a loader extension is created.
  77850. * Set additional options for a loader extension in this event.
  77851. */
  77852. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  77853. private _onExtensionLoadedObserver;
  77854. /**
  77855. * Callback raised after a loader extension is created.
  77856. */
  77857. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  77858. /**
  77859. * Defines if the loader logging is enabled.
  77860. */
  77861. get loggingEnabled(): boolean;
  77862. set loggingEnabled(value: boolean);
  77863. /**
  77864. * Defines if the loader should capture performance counters.
  77865. */
  77866. get capturePerformanceCounters(): boolean;
  77867. set capturePerformanceCounters(value: boolean);
  77868. /**
  77869. * Defines if the loader should validate the asset.
  77870. */
  77871. validate: boolean;
  77872. /**
  77873. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  77874. */
  77875. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  77876. private _onValidatedObserver;
  77877. /**
  77878. * Callback raised after a loader extension is created.
  77879. */
  77880. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  77881. private _loader;
  77882. /**
  77883. * Name of the loader ("gltf")
  77884. */
  77885. name: string;
  77886. /** @hidden */
  77887. extensions: ISceneLoaderPluginExtensions;
  77888. /**
  77889. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  77890. */
  77891. dispose(): void;
  77892. /** @hidden */
  77893. _clear(): void;
  77894. /** @hidden */
  77895. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  77896. /** @hidden */
  77897. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  77898. /** @hidden */
  77899. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77900. meshes: AbstractMesh[];
  77901. particleSystems: IParticleSystem[];
  77902. skeletons: Skeleton[];
  77903. animationGroups: AnimationGroup[];
  77904. }>;
  77905. /** @hidden */
  77906. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77907. /** @hidden */
  77908. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77909. /** @hidden */
  77910. canDirectLoad(data: string): boolean;
  77911. /** @hidden */
  77912. directLoad(scene: Scene, data: string): any;
  77913. /**
  77914. * The callback that allows custom handling of the root url based on the response url.
  77915. * @param rootUrl the original root url
  77916. * @param responseURL the response url if available
  77917. * @returns the new root url
  77918. */
  77919. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  77920. /** @hidden */
  77921. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  77922. /**
  77923. * The loader state or null if the loader is not active.
  77924. */
  77925. get loaderState(): Nullable<GLTFLoaderState>;
  77926. /**
  77927. * Returns a promise that resolves when the asset is completely loaded.
  77928. * @returns a promise that resolves when the asset is completely loaded.
  77929. */
  77930. whenCompleteAsync(): Promise<void>;
  77931. private _validate;
  77932. private _getLoader;
  77933. private _parseJson;
  77934. private _unpackBinaryAsync;
  77935. private _unpackBinaryV1Async;
  77936. private _unpackBinaryV2Async;
  77937. private static _parseVersion;
  77938. private static _compareVersion;
  77939. private static readonly _logSpaces;
  77940. private _logIndentLevel;
  77941. private _loggingEnabled;
  77942. /** @hidden */
  77943. _log: (message: string) => void;
  77944. /** @hidden */
  77945. _logOpen(message: string): void;
  77946. /** @hidden */
  77947. _logClose(): void;
  77948. private _logEnabled;
  77949. private _logDisabled;
  77950. private _capturePerformanceCounters;
  77951. /** @hidden */
  77952. _startPerformanceCounter: (counterName: string) => void;
  77953. /** @hidden */
  77954. _endPerformanceCounter: (counterName: string) => void;
  77955. private _startPerformanceCounterEnabled;
  77956. private _startPerformanceCounterDisabled;
  77957. private _endPerformanceCounterEnabled;
  77958. private _endPerformanceCounterDisabled;
  77959. }
  77960. }
  77961. declare module BABYLON.GLTF1 {
  77962. /**
  77963. * Enums
  77964. * @hidden
  77965. */
  77966. export enum EComponentType {
  77967. BYTE = 5120,
  77968. UNSIGNED_BYTE = 5121,
  77969. SHORT = 5122,
  77970. UNSIGNED_SHORT = 5123,
  77971. FLOAT = 5126
  77972. }
  77973. /** @hidden */
  77974. export enum EShaderType {
  77975. FRAGMENT = 35632,
  77976. VERTEX = 35633
  77977. }
  77978. /** @hidden */
  77979. export enum EParameterType {
  77980. BYTE = 5120,
  77981. UNSIGNED_BYTE = 5121,
  77982. SHORT = 5122,
  77983. UNSIGNED_SHORT = 5123,
  77984. INT = 5124,
  77985. UNSIGNED_INT = 5125,
  77986. FLOAT = 5126,
  77987. FLOAT_VEC2 = 35664,
  77988. FLOAT_VEC3 = 35665,
  77989. FLOAT_VEC4 = 35666,
  77990. INT_VEC2 = 35667,
  77991. INT_VEC3 = 35668,
  77992. INT_VEC4 = 35669,
  77993. BOOL = 35670,
  77994. BOOL_VEC2 = 35671,
  77995. BOOL_VEC3 = 35672,
  77996. BOOL_VEC4 = 35673,
  77997. FLOAT_MAT2 = 35674,
  77998. FLOAT_MAT3 = 35675,
  77999. FLOAT_MAT4 = 35676,
  78000. SAMPLER_2D = 35678
  78001. }
  78002. /** @hidden */
  78003. export enum ETextureWrapMode {
  78004. CLAMP_TO_EDGE = 33071,
  78005. MIRRORED_REPEAT = 33648,
  78006. REPEAT = 10497
  78007. }
  78008. /** @hidden */
  78009. export enum ETextureFilterType {
  78010. NEAREST = 9728,
  78011. LINEAR = 9728,
  78012. NEAREST_MIPMAP_NEAREST = 9984,
  78013. LINEAR_MIPMAP_NEAREST = 9985,
  78014. NEAREST_MIPMAP_LINEAR = 9986,
  78015. LINEAR_MIPMAP_LINEAR = 9987
  78016. }
  78017. /** @hidden */
  78018. export enum ETextureFormat {
  78019. ALPHA = 6406,
  78020. RGB = 6407,
  78021. RGBA = 6408,
  78022. LUMINANCE = 6409,
  78023. LUMINANCE_ALPHA = 6410
  78024. }
  78025. /** @hidden */
  78026. export enum ECullingType {
  78027. FRONT = 1028,
  78028. BACK = 1029,
  78029. FRONT_AND_BACK = 1032
  78030. }
  78031. /** @hidden */
  78032. export enum EBlendingFunction {
  78033. ZERO = 0,
  78034. ONE = 1,
  78035. SRC_COLOR = 768,
  78036. ONE_MINUS_SRC_COLOR = 769,
  78037. DST_COLOR = 774,
  78038. ONE_MINUS_DST_COLOR = 775,
  78039. SRC_ALPHA = 770,
  78040. ONE_MINUS_SRC_ALPHA = 771,
  78041. DST_ALPHA = 772,
  78042. ONE_MINUS_DST_ALPHA = 773,
  78043. CONSTANT_COLOR = 32769,
  78044. ONE_MINUS_CONSTANT_COLOR = 32770,
  78045. CONSTANT_ALPHA = 32771,
  78046. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78047. SRC_ALPHA_SATURATE = 776
  78048. }
  78049. /** @hidden */
  78050. export interface IGLTFProperty {
  78051. extensions?: {
  78052. [key: string]: any;
  78053. };
  78054. extras?: Object;
  78055. }
  78056. /** @hidden */
  78057. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78058. name?: string;
  78059. }
  78060. /** @hidden */
  78061. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78062. bufferView: string;
  78063. byteOffset: number;
  78064. byteStride: number;
  78065. count: number;
  78066. type: string;
  78067. componentType: EComponentType;
  78068. max?: number[];
  78069. min?: number[];
  78070. name?: string;
  78071. }
  78072. /** @hidden */
  78073. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78074. buffer: string;
  78075. byteOffset: number;
  78076. byteLength: number;
  78077. byteStride: number;
  78078. target?: number;
  78079. }
  78080. /** @hidden */
  78081. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78082. uri: string;
  78083. byteLength?: number;
  78084. type?: string;
  78085. }
  78086. /** @hidden */
  78087. export interface IGLTFShader extends IGLTFChildRootProperty {
  78088. uri: string;
  78089. type: EShaderType;
  78090. }
  78091. /** @hidden */
  78092. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78093. attributes: string[];
  78094. fragmentShader: string;
  78095. vertexShader: string;
  78096. }
  78097. /** @hidden */
  78098. export interface IGLTFTechniqueParameter {
  78099. type: number;
  78100. count?: number;
  78101. semantic?: string;
  78102. node?: string;
  78103. value?: number | boolean | string | Array<any>;
  78104. source?: string;
  78105. babylonValue?: any;
  78106. }
  78107. /** @hidden */
  78108. export interface IGLTFTechniqueCommonProfile {
  78109. lightingModel: string;
  78110. texcoordBindings: Object;
  78111. parameters?: Array<any>;
  78112. }
  78113. /** @hidden */
  78114. export interface IGLTFTechniqueStatesFunctions {
  78115. blendColor?: number[];
  78116. blendEquationSeparate?: number[];
  78117. blendFuncSeparate?: number[];
  78118. colorMask: boolean[];
  78119. cullFace: number[];
  78120. }
  78121. /** @hidden */
  78122. export interface IGLTFTechniqueStates {
  78123. enable: number[];
  78124. functions: IGLTFTechniqueStatesFunctions;
  78125. }
  78126. /** @hidden */
  78127. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78128. parameters: {
  78129. [key: string]: IGLTFTechniqueParameter;
  78130. };
  78131. program: string;
  78132. attributes: {
  78133. [key: string]: string;
  78134. };
  78135. uniforms: {
  78136. [key: string]: string;
  78137. };
  78138. states: IGLTFTechniqueStates;
  78139. }
  78140. /** @hidden */
  78141. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78142. technique?: string;
  78143. values: string[];
  78144. }
  78145. /** @hidden */
  78146. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78147. attributes: {
  78148. [key: string]: string;
  78149. };
  78150. indices: string;
  78151. material: string;
  78152. mode?: number;
  78153. }
  78154. /** @hidden */
  78155. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78156. primitives: IGLTFMeshPrimitive[];
  78157. }
  78158. /** @hidden */
  78159. export interface IGLTFImage extends IGLTFChildRootProperty {
  78160. uri: string;
  78161. }
  78162. /** @hidden */
  78163. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78164. magFilter?: number;
  78165. minFilter?: number;
  78166. wrapS?: number;
  78167. wrapT?: number;
  78168. }
  78169. /** @hidden */
  78170. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78171. sampler: string;
  78172. source: string;
  78173. format?: ETextureFormat;
  78174. internalFormat?: ETextureFormat;
  78175. target?: number;
  78176. type?: number;
  78177. babylonTexture?: Texture;
  78178. }
  78179. /** @hidden */
  78180. export interface IGLTFAmbienLight {
  78181. color?: number[];
  78182. }
  78183. /** @hidden */
  78184. export interface IGLTFDirectionalLight {
  78185. color?: number[];
  78186. }
  78187. /** @hidden */
  78188. export interface IGLTFPointLight {
  78189. color?: number[];
  78190. constantAttenuation?: number;
  78191. linearAttenuation?: number;
  78192. quadraticAttenuation?: number;
  78193. }
  78194. /** @hidden */
  78195. export interface IGLTFSpotLight {
  78196. color?: number[];
  78197. constantAttenuation?: number;
  78198. fallOfAngle?: number;
  78199. fallOffExponent?: number;
  78200. linearAttenuation?: number;
  78201. quadraticAttenuation?: number;
  78202. }
  78203. /** @hidden */
  78204. export interface IGLTFLight extends IGLTFChildRootProperty {
  78205. type: string;
  78206. }
  78207. /** @hidden */
  78208. export interface IGLTFCameraOrthographic {
  78209. xmag: number;
  78210. ymag: number;
  78211. zfar: number;
  78212. znear: number;
  78213. }
  78214. /** @hidden */
  78215. export interface IGLTFCameraPerspective {
  78216. aspectRatio: number;
  78217. yfov: number;
  78218. zfar: number;
  78219. znear: number;
  78220. }
  78221. /** @hidden */
  78222. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78223. type: string;
  78224. }
  78225. /** @hidden */
  78226. export interface IGLTFAnimationChannelTarget {
  78227. id: string;
  78228. path: string;
  78229. }
  78230. /** @hidden */
  78231. export interface IGLTFAnimationChannel {
  78232. sampler: string;
  78233. target: IGLTFAnimationChannelTarget;
  78234. }
  78235. /** @hidden */
  78236. export interface IGLTFAnimationSampler {
  78237. input: string;
  78238. output: string;
  78239. interpolation?: string;
  78240. }
  78241. /** @hidden */
  78242. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78243. channels?: IGLTFAnimationChannel[];
  78244. parameters?: {
  78245. [key: string]: string;
  78246. };
  78247. samplers?: {
  78248. [key: string]: IGLTFAnimationSampler;
  78249. };
  78250. }
  78251. /** @hidden */
  78252. export interface IGLTFNodeInstanceSkin {
  78253. skeletons: string[];
  78254. skin: string;
  78255. meshes: string[];
  78256. }
  78257. /** @hidden */
  78258. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78259. bindShapeMatrix: number[];
  78260. inverseBindMatrices: string;
  78261. jointNames: string[];
  78262. babylonSkeleton?: Skeleton;
  78263. }
  78264. /** @hidden */
  78265. export interface IGLTFNode extends IGLTFChildRootProperty {
  78266. camera?: string;
  78267. children: string[];
  78268. skin?: string;
  78269. jointName?: string;
  78270. light?: string;
  78271. matrix: number[];
  78272. mesh?: string;
  78273. meshes?: string[];
  78274. rotation?: number[];
  78275. scale?: number[];
  78276. translation?: number[];
  78277. babylonNode?: Node;
  78278. }
  78279. /** @hidden */
  78280. export interface IGLTFScene extends IGLTFChildRootProperty {
  78281. nodes: string[];
  78282. }
  78283. /** @hidden */
  78284. export interface IGLTFRuntime {
  78285. extensions: {
  78286. [key: string]: any;
  78287. };
  78288. accessors: {
  78289. [key: string]: IGLTFAccessor;
  78290. };
  78291. buffers: {
  78292. [key: string]: IGLTFBuffer;
  78293. };
  78294. bufferViews: {
  78295. [key: string]: IGLTFBufferView;
  78296. };
  78297. meshes: {
  78298. [key: string]: IGLTFMesh;
  78299. };
  78300. lights: {
  78301. [key: string]: IGLTFLight;
  78302. };
  78303. cameras: {
  78304. [key: string]: IGLTFCamera;
  78305. };
  78306. nodes: {
  78307. [key: string]: IGLTFNode;
  78308. };
  78309. images: {
  78310. [key: string]: IGLTFImage;
  78311. };
  78312. textures: {
  78313. [key: string]: IGLTFTexture;
  78314. };
  78315. shaders: {
  78316. [key: string]: IGLTFShader;
  78317. };
  78318. programs: {
  78319. [key: string]: IGLTFProgram;
  78320. };
  78321. samplers: {
  78322. [key: string]: IGLTFSampler;
  78323. };
  78324. techniques: {
  78325. [key: string]: IGLTFTechnique;
  78326. };
  78327. materials: {
  78328. [key: string]: IGLTFMaterial;
  78329. };
  78330. animations: {
  78331. [key: string]: IGLTFAnimation;
  78332. };
  78333. skins: {
  78334. [key: string]: IGLTFSkins;
  78335. };
  78336. currentScene?: Object;
  78337. scenes: {
  78338. [key: string]: IGLTFScene;
  78339. };
  78340. extensionsUsed: string[];
  78341. extensionsRequired?: string[];
  78342. buffersCount: number;
  78343. shaderscount: number;
  78344. scene: Scene;
  78345. rootUrl: string;
  78346. loadedBufferCount: number;
  78347. loadedBufferViews: {
  78348. [name: string]: ArrayBufferView;
  78349. };
  78350. loadedShaderCount: number;
  78351. importOnlyMeshes: boolean;
  78352. importMeshesNames?: string[];
  78353. dummyNodes: Node[];
  78354. forAssetContainer: boolean;
  78355. }
  78356. /** @hidden */
  78357. export interface INodeToRoot {
  78358. bone: Bone;
  78359. node: IGLTFNode;
  78360. id: string;
  78361. }
  78362. /** @hidden */
  78363. export interface IJointNode {
  78364. node: IGLTFNode;
  78365. id: string;
  78366. }
  78367. }
  78368. declare module BABYLON.GLTF1 {
  78369. /**
  78370. * Utils functions for GLTF
  78371. * @hidden
  78372. */
  78373. export class GLTFUtils {
  78374. /**
  78375. * Sets the given "parameter" matrix
  78376. * @param scene: the Scene object
  78377. * @param source: the source node where to pick the matrix
  78378. * @param parameter: the GLTF technique parameter
  78379. * @param uniformName: the name of the shader's uniform
  78380. * @param shaderMaterial: the shader material
  78381. */
  78382. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  78383. /**
  78384. * Sets the given "parameter" matrix
  78385. * @param shaderMaterial: the shader material
  78386. * @param uniform: the name of the shader's uniform
  78387. * @param value: the value of the uniform
  78388. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  78389. */
  78390. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  78391. /**
  78392. * Returns the wrap mode of the texture
  78393. * @param mode: the mode value
  78394. */
  78395. static GetWrapMode(mode: number): number;
  78396. /**
  78397. * Returns the byte stride giving an accessor
  78398. * @param accessor: the GLTF accessor objet
  78399. */
  78400. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  78401. /**
  78402. * Returns the texture filter mode giving a mode value
  78403. * @param mode: the filter mode value
  78404. */
  78405. static GetTextureFilterMode(mode: number): ETextureFilterType;
  78406. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  78407. /**
  78408. * Returns a buffer from its accessor
  78409. * @param gltfRuntime: the GLTF runtime
  78410. * @param accessor: the GLTF accessor
  78411. */
  78412. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  78413. /**
  78414. * Decodes a buffer view into a string
  78415. * @param view: the buffer view
  78416. */
  78417. static DecodeBufferToText(view: ArrayBufferView): string;
  78418. /**
  78419. * Returns the default material of gltf. Related to
  78420. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  78421. * @param scene: the Babylon.js scene
  78422. */
  78423. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  78424. private static _DefaultMaterial;
  78425. }
  78426. }
  78427. declare module BABYLON.GLTF1 {
  78428. /**
  78429. * Implementation of the base glTF spec
  78430. * @hidden
  78431. */
  78432. export class GLTFLoaderBase {
  78433. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  78434. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78435. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  78436. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78437. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  78438. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78439. }
  78440. /**
  78441. * glTF V1 Loader
  78442. * @hidden
  78443. */
  78444. export class GLTFLoader implements IGLTFLoader {
  78445. static Extensions: {
  78446. [name: string]: GLTFLoaderExtension;
  78447. };
  78448. static RegisterExtension(extension: GLTFLoaderExtension): void;
  78449. state: Nullable<GLTFLoaderState>;
  78450. dispose(): void;
  78451. private _importMeshAsync;
  78452. /**
  78453. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  78454. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78455. * @param scene the scene the meshes should be added to
  78456. * @param forAssetContainer defines if the entities must be stored in the scene
  78457. * @param data gltf data containing information of the meshes in a loaded file
  78458. * @param rootUrl root url to load from
  78459. * @param onProgress event that fires when loading progress has occured
  78460. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78461. */
  78462. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  78463. private _loadAsync;
  78464. /**
  78465. * Imports all objects from a loaded gltf file and adds them to the scene
  78466. * @param scene the scene the objects should be added to
  78467. * @param data gltf data containing information of the meshes in a loaded file
  78468. * @param rootUrl root url to load from
  78469. * @param onProgress event that fires when loading progress has occured
  78470. * @returns a promise which completes when objects have been loaded to the scene
  78471. */
  78472. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  78473. private _loadShadersAsync;
  78474. private _loadBuffersAsync;
  78475. private _createNodes;
  78476. }
  78477. /** @hidden */
  78478. export abstract class GLTFLoaderExtension {
  78479. private _name;
  78480. constructor(name: string);
  78481. get name(): string;
  78482. /**
  78483. * Defines an override for loading the runtime
  78484. * Return true to stop further extensions from loading the runtime
  78485. */
  78486. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  78487. /**
  78488. * Defines an onverride for creating gltf runtime
  78489. * Return true to stop further extensions from creating the runtime
  78490. */
  78491. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  78492. /**
  78493. * Defines an override for loading buffers
  78494. * Return true to stop further extensions from loading this buffer
  78495. */
  78496. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  78497. /**
  78498. * Defines an override for loading texture buffers
  78499. * Return true to stop further extensions from loading this texture data
  78500. */
  78501. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78502. /**
  78503. * Defines an override for creating textures
  78504. * Return true to stop further extensions from loading this texture
  78505. */
  78506. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  78507. /**
  78508. * Defines an override for loading shader strings
  78509. * Return true to stop further extensions from loading this shader data
  78510. */
  78511. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78512. /**
  78513. * Defines an override for loading materials
  78514. * Return true to stop further extensions from loading this material
  78515. */
  78516. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78517. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  78518. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  78519. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78520. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78521. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  78522. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78523. private static LoadTextureBufferAsync;
  78524. private static CreateTextureAsync;
  78525. private static ApplyExtensions;
  78526. }
  78527. }
  78528. declare module BABYLON.GLTF1 {
  78529. /** @hidden */
  78530. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  78531. private _bin;
  78532. constructor();
  78533. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  78534. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78535. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78536. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78537. }
  78538. }
  78539. declare module BABYLON.GLTF1 {
  78540. /** @hidden */
  78541. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  78542. constructor();
  78543. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  78544. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78545. private _loadTexture;
  78546. }
  78547. }
  78548. declare module BABYLON.GLTF2.Loader {
  78549. /**
  78550. * Loader interface with an index field.
  78551. */
  78552. export interface IArrayItem {
  78553. /**
  78554. * The index of this item in the array.
  78555. */
  78556. index: number;
  78557. }
  78558. /**
  78559. * Loader interface with additional members.
  78560. */
  78561. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  78562. /** @hidden */
  78563. _data?: Promise<ArrayBufferView>;
  78564. /** @hidden */
  78565. _babylonVertexBuffer?: Promise<VertexBuffer>;
  78566. }
  78567. /**
  78568. * Loader interface with additional members.
  78569. */
  78570. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  78571. }
  78572. /** @hidden */
  78573. export interface _IAnimationSamplerData {
  78574. input: Float32Array;
  78575. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  78576. output: Float32Array;
  78577. }
  78578. /**
  78579. * Loader interface with additional members.
  78580. */
  78581. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  78582. /** @hidden */
  78583. _data?: Promise<_IAnimationSamplerData>;
  78584. }
  78585. /**
  78586. * Loader interface with additional members.
  78587. */
  78588. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  78589. channels: IAnimationChannel[];
  78590. samplers: IAnimationSampler[];
  78591. /** @hidden */
  78592. _babylonAnimationGroup?: AnimationGroup;
  78593. }
  78594. /**
  78595. * Loader interface with additional members.
  78596. */
  78597. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  78598. /** @hidden */
  78599. _data?: Promise<ArrayBufferView>;
  78600. }
  78601. /**
  78602. * Loader interface with additional members.
  78603. */
  78604. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  78605. /** @hidden */
  78606. _data?: Promise<ArrayBufferView>;
  78607. /** @hidden */
  78608. _babylonBuffer?: Promise<Buffer>;
  78609. }
  78610. /**
  78611. * Loader interface with additional members.
  78612. */
  78613. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  78614. }
  78615. /**
  78616. * Loader interface with additional members.
  78617. */
  78618. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  78619. /** @hidden */
  78620. _data?: Promise<ArrayBufferView>;
  78621. }
  78622. /**
  78623. * Loader interface with additional members.
  78624. */
  78625. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  78626. }
  78627. /**
  78628. * Loader interface with additional members.
  78629. */
  78630. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  78631. }
  78632. /**
  78633. * Loader interface with additional members.
  78634. */
  78635. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  78636. baseColorTexture?: ITextureInfo;
  78637. metallicRoughnessTexture?: ITextureInfo;
  78638. }
  78639. /**
  78640. * Loader interface with additional members.
  78641. */
  78642. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  78643. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78644. normalTexture?: IMaterialNormalTextureInfo;
  78645. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78646. emissiveTexture?: ITextureInfo;
  78647. /** @hidden */
  78648. _data?: {
  78649. [babylonDrawMode: number]: {
  78650. babylonMaterial: Material;
  78651. babylonMeshes: AbstractMesh[];
  78652. promise: Promise<void>;
  78653. };
  78654. };
  78655. }
  78656. /**
  78657. * Loader interface with additional members.
  78658. */
  78659. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  78660. primitives: IMeshPrimitive[];
  78661. }
  78662. /**
  78663. * Loader interface with additional members.
  78664. */
  78665. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  78666. /** @hidden */
  78667. _instanceData?: {
  78668. babylonSourceMesh: Mesh;
  78669. promise: Promise<any>;
  78670. };
  78671. }
  78672. /**
  78673. * Loader interface with additional members.
  78674. */
  78675. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  78676. /**
  78677. * The parent glTF node.
  78678. */
  78679. parent?: INode;
  78680. /** @hidden */
  78681. _babylonTransformNode?: TransformNode;
  78682. /** @hidden */
  78683. _primitiveBabylonMeshes?: AbstractMesh[];
  78684. /** @hidden */
  78685. _babylonBones?: Bone[];
  78686. /** @hidden */
  78687. _numMorphTargets?: number;
  78688. }
  78689. /** @hidden */
  78690. export interface _ISamplerData {
  78691. noMipMaps: boolean;
  78692. samplingMode: number;
  78693. wrapU: number;
  78694. wrapV: number;
  78695. }
  78696. /**
  78697. * Loader interface with additional members.
  78698. */
  78699. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  78700. /** @hidden */
  78701. _data?: _ISamplerData;
  78702. }
  78703. /**
  78704. * Loader interface with additional members.
  78705. */
  78706. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  78707. }
  78708. /**
  78709. * Loader interface with additional members.
  78710. */
  78711. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  78712. /** @hidden */
  78713. _data?: {
  78714. babylonSkeleton: Skeleton;
  78715. promise: Promise<void>;
  78716. };
  78717. }
  78718. /**
  78719. * Loader interface with additional members.
  78720. */
  78721. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  78722. }
  78723. /**
  78724. * Loader interface with additional members.
  78725. */
  78726. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  78727. }
  78728. /**
  78729. * Loader interface with additional members.
  78730. */
  78731. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  78732. accessors?: IAccessor[];
  78733. animations?: IAnimation[];
  78734. buffers?: IBuffer[];
  78735. bufferViews?: IBufferView[];
  78736. cameras?: ICamera[];
  78737. images?: IImage[];
  78738. materials?: IMaterial[];
  78739. meshes?: IMesh[];
  78740. nodes?: INode[];
  78741. samplers?: ISampler[];
  78742. scenes?: IScene[];
  78743. skins?: ISkin[];
  78744. textures?: ITexture[];
  78745. }
  78746. }
  78747. declare module BABYLON.GLTF2 {
  78748. /**
  78749. * Interface for a glTF loader extension.
  78750. */
  78751. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  78752. /**
  78753. * Called after the loader state changes to LOADING.
  78754. */
  78755. onLoading?(): void;
  78756. /**
  78757. * Called after the loader state changes to READY.
  78758. */
  78759. onReady?(): void;
  78760. /**
  78761. * Define this method to modify the default behavior when loading scenes.
  78762. * @param context The context when loading the asset
  78763. * @param scene The glTF scene property
  78764. * @returns A promise that resolves when the load is complete or null if not handled
  78765. */
  78766. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  78767. /**
  78768. * Define this method to modify the default behavior when loading nodes.
  78769. * @param context The context when loading the asset
  78770. * @param node The glTF node property
  78771. * @param assign A function called synchronously after parsing the glTF properties
  78772. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  78773. */
  78774. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78775. /**
  78776. * Define this method to modify the default behavior when loading cameras.
  78777. * @param context The context when loading the asset
  78778. * @param camera The glTF camera property
  78779. * @param assign A function called synchronously after parsing the glTF properties
  78780. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  78781. */
  78782. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  78783. /**
  78784. * @hidden
  78785. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  78786. * @param context The context when loading the asset
  78787. * @param primitive The glTF mesh primitive property
  78788. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  78789. */
  78790. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  78791. /**
  78792. * @hidden
  78793. * Define this method to modify the default behavior when loading data for mesh primitives.
  78794. * @param context The context when loading the asset
  78795. * @param name The mesh name when loading the asset
  78796. * @param node The glTF node when loading the asset
  78797. * @param mesh The glTF mesh when loading the asset
  78798. * @param primitive The glTF mesh primitive property
  78799. * @param assign A function called synchronously after parsing the glTF properties
  78800. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  78801. */
  78802. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  78803. /**
  78804. * @hidden
  78805. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  78806. * @param context The context when loading the asset
  78807. * @param material The glTF material property
  78808. * @param assign A function called synchronously after parsing the glTF properties
  78809. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  78810. */
  78811. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  78812. /**
  78813. * Define this method to modify the default behavior when creating materials.
  78814. * @param context The context when loading the asset
  78815. * @param material The glTF material property
  78816. * @param babylonDrawMode The draw mode for the Babylon material
  78817. * @returns The Babylon material or null if not handled
  78818. */
  78819. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  78820. /**
  78821. * Define this method to modify the default behavior when loading material properties.
  78822. * @param context The context when loading the asset
  78823. * @param material The glTF material property
  78824. * @param babylonMaterial The Babylon material
  78825. * @returns A promise that resolves when the load is complete or null if not handled
  78826. */
  78827. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78828. /**
  78829. * Define this method to modify the default behavior when loading texture infos.
  78830. * @param context The context when loading the asset
  78831. * @param textureInfo The glTF texture info property
  78832. * @param assign A function called synchronously after parsing the glTF properties
  78833. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  78834. */
  78835. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78836. /**
  78837. * @hidden
  78838. * Define this method to modify the default behavior when loading textures.
  78839. * @param context The context when loading the asset
  78840. * @param texture The glTF texture property
  78841. * @param assign A function called synchronously after parsing the glTF properties
  78842. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  78843. */
  78844. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78845. /**
  78846. * Define this method to modify the default behavior when loading animations.
  78847. * @param context The context when loading the asset
  78848. * @param animation The glTF animation property
  78849. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  78850. */
  78851. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  78852. /**
  78853. * @hidden
  78854. * Define this method to modify the default behavior when loading skins.
  78855. * @param context The context when loading the asset
  78856. * @param node The glTF node property
  78857. * @param skin The glTF skin property
  78858. * @returns A promise that resolves when the load is complete or null if not handled
  78859. */
  78860. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  78861. /**
  78862. * @hidden
  78863. * Define this method to modify the default behavior when loading uris.
  78864. * @param context The context when loading the asset
  78865. * @param property The glTF property associated with the uri
  78866. * @param uri The uri to load
  78867. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78868. */
  78869. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  78870. /**
  78871. * Define this method to modify the default behavior when loading buffer views.
  78872. * @param context The context when loading the asset
  78873. * @param bufferView The glTF buffer view property
  78874. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78875. */
  78876. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  78877. /**
  78878. * Define this method to modify the default behavior when loading buffers.
  78879. * @param context The context when loading the asset
  78880. * @param buffer The glTF buffer property
  78881. * @param byteOffset The byte offset to load
  78882. * @param byteLength The byte length to load
  78883. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78884. */
  78885. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  78886. }
  78887. }
  78888. declare module BABYLON.GLTF2 {
  78889. /**
  78890. * Helper class for working with arrays when loading the glTF asset
  78891. */
  78892. export class ArrayItem {
  78893. /**
  78894. * Gets an item from the given array.
  78895. * @param context The context when loading the asset
  78896. * @param array The array to get the item from
  78897. * @param index The index to the array
  78898. * @returns The array item
  78899. */
  78900. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  78901. /**
  78902. * Assign an `index` field to each item of the given array.
  78903. * @param array The array of items
  78904. */
  78905. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  78906. }
  78907. /**
  78908. * The glTF 2.0 loader
  78909. */
  78910. export class GLTFLoader implements IGLTFLoader {
  78911. /** @hidden */
  78912. _completePromises: Promise<any>[];
  78913. /** @hidden */
  78914. _forAssetContainer: boolean;
  78915. /** Storage */
  78916. _babylonLights: Light[];
  78917. private _disposed;
  78918. private _parent;
  78919. private _state;
  78920. private _extensions;
  78921. private _rootUrl;
  78922. private _fileName;
  78923. private _uniqueRootUrl;
  78924. private _gltf;
  78925. private _bin;
  78926. private _babylonScene;
  78927. private _rootBabylonMesh;
  78928. private _defaultBabylonMaterialData;
  78929. private _progressCallback?;
  78930. private _requests;
  78931. private static _RegisteredExtensions;
  78932. /**
  78933. * The default glTF sampler.
  78934. */
  78935. static readonly DefaultSampler: ISampler;
  78936. /**
  78937. * Registers a loader extension.
  78938. * @param name The name of the loader extension.
  78939. * @param factory The factory function that creates the loader extension.
  78940. */
  78941. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  78942. /**
  78943. * Unregisters a loader extension.
  78944. * @param name The name of the loader extension.
  78945. * @returns A boolean indicating whether the extension has been unregistered
  78946. */
  78947. static UnregisterExtension(name: string): boolean;
  78948. /**
  78949. * The loader state.
  78950. */
  78951. get state(): Nullable<GLTFLoaderState>;
  78952. /**
  78953. * The object that represents the glTF JSON.
  78954. */
  78955. get gltf(): IGLTF;
  78956. /**
  78957. * The BIN chunk of a binary glTF.
  78958. */
  78959. get bin(): Nullable<IDataBuffer>;
  78960. /**
  78961. * The parent file loader.
  78962. */
  78963. get parent(): GLTFFileLoader;
  78964. /**
  78965. * The Babylon scene when loading the asset.
  78966. */
  78967. get babylonScene(): Scene;
  78968. /**
  78969. * The root Babylon mesh when loading the asset.
  78970. */
  78971. get rootBabylonMesh(): Mesh;
  78972. /** @hidden */
  78973. constructor(parent: GLTFFileLoader);
  78974. /** @hidden */
  78975. dispose(): void;
  78976. /** @hidden */
  78977. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  78978. /** @hidden */
  78979. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78980. private _loadAsync;
  78981. private _loadData;
  78982. private _setupData;
  78983. private _loadExtensions;
  78984. private _checkExtensions;
  78985. private _setState;
  78986. private _createRootNode;
  78987. /**
  78988. * Loads a glTF scene.
  78989. * @param context The context when loading the asset
  78990. * @param scene The glTF scene property
  78991. * @returns A promise that resolves when the load is complete
  78992. */
  78993. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  78994. private _forEachPrimitive;
  78995. private _getMeshes;
  78996. private _getTransformNodes;
  78997. private _getSkeletons;
  78998. private _getAnimationGroups;
  78999. private _startAnimations;
  79000. /**
  79001. * Loads a glTF node.
  79002. * @param context The context when loading the asset
  79003. * @param node The glTF node property
  79004. * @param assign A function called synchronously after parsing the glTF properties
  79005. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79006. */
  79007. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79008. private _loadMeshAsync;
  79009. /**
  79010. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79011. * @param context The context when loading the asset
  79012. * @param name The mesh name when loading the asset
  79013. * @param node The glTF node when loading the asset
  79014. * @param mesh The glTF mesh when loading the asset
  79015. * @param primitive The glTF mesh primitive property
  79016. * @param assign A function called synchronously after parsing the glTF properties
  79017. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79018. */
  79019. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79020. private _loadVertexDataAsync;
  79021. private _createMorphTargets;
  79022. private _loadMorphTargetsAsync;
  79023. private _loadMorphTargetVertexDataAsync;
  79024. private static _LoadTransform;
  79025. private _loadSkinAsync;
  79026. private _loadBones;
  79027. private _loadBone;
  79028. private _loadSkinInverseBindMatricesDataAsync;
  79029. private _updateBoneMatrices;
  79030. private _getNodeMatrix;
  79031. /**
  79032. * Loads a glTF camera.
  79033. * @param context The context when loading the asset
  79034. * @param camera The glTF camera property
  79035. * @param assign A function called synchronously after parsing the glTF properties
  79036. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79037. */
  79038. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79039. private _loadAnimationsAsync;
  79040. /**
  79041. * Loads a glTF animation.
  79042. * @param context The context when loading the asset
  79043. * @param animation The glTF animation property
  79044. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79045. */
  79046. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79047. /**
  79048. * @hidden Loads a glTF animation channel.
  79049. * @param context The context when loading the asset
  79050. * @param animationContext The context of the animation when loading the asset
  79051. * @param animation The glTF animation property
  79052. * @param channel The glTF animation channel property
  79053. * @param babylonAnimationGroup The babylon animation group property
  79054. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79055. * @returns A void promise when the channel load is complete
  79056. */
  79057. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79058. private _loadAnimationSamplerAsync;
  79059. private _loadBufferAsync;
  79060. /**
  79061. * Loads a glTF buffer view.
  79062. * @param context The context when loading the asset
  79063. * @param bufferView The glTF buffer view property
  79064. * @returns A promise that resolves with the loaded data when the load is complete
  79065. */
  79066. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79067. private _loadAccessorAsync;
  79068. /** @hidden */
  79069. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79070. private _loadIndicesAccessorAsync;
  79071. private _loadVertexBufferViewAsync;
  79072. private _loadVertexAccessorAsync;
  79073. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79074. /** @hidden */
  79075. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79076. private _createDefaultMaterial;
  79077. /**
  79078. * Creates a Babylon material from a glTF material.
  79079. * @param context The context when loading the asset
  79080. * @param material The glTF material property
  79081. * @param babylonDrawMode The draw mode for the Babylon material
  79082. * @returns The Babylon material
  79083. */
  79084. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79085. /**
  79086. * Loads properties from a glTF material into a Babylon material.
  79087. * @param context The context when loading the asset
  79088. * @param material The glTF material property
  79089. * @param babylonMaterial The Babylon material
  79090. * @returns A promise that resolves when the load is complete
  79091. */
  79092. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79093. /**
  79094. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79095. * @param context The context when loading the asset
  79096. * @param material The glTF material property
  79097. * @param babylonMaterial The Babylon material
  79098. * @returns A promise that resolves when the load is complete
  79099. */
  79100. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79101. /**
  79102. * Loads the alpha properties from a glTF material into a Babylon material.
  79103. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79104. * @param context The context when loading the asset
  79105. * @param material The glTF material property
  79106. * @param babylonMaterial The Babylon material
  79107. */
  79108. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79109. /**
  79110. * Loads a glTF texture info.
  79111. * @param context The context when loading the asset
  79112. * @param textureInfo The glTF texture info property
  79113. * @param assign A function called synchronously after parsing the glTF properties
  79114. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79115. */
  79116. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79117. /** @hidden */
  79118. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79119. /** @hidden */
  79120. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79121. private _loadSampler;
  79122. /**
  79123. * Loads a glTF image.
  79124. * @param context The context when loading the asset
  79125. * @param image The glTF image property
  79126. * @returns A promise that resolves with the loaded data when the load is complete
  79127. */
  79128. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79129. /**
  79130. * Loads a glTF uri.
  79131. * @param context The context when loading the asset
  79132. * @param property The glTF property associated with the uri
  79133. * @param uri The base64 or relative uri
  79134. * @returns A promise that resolves with the loaded data when the load is complete
  79135. */
  79136. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79137. private _onProgress;
  79138. /**
  79139. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79140. * @param babylonObject the Babylon object with metadata
  79141. * @param pointer the JSON pointer
  79142. */
  79143. static AddPointerMetadata(babylonObject: {
  79144. metadata: any;
  79145. }, pointer: string): void;
  79146. private static _GetTextureWrapMode;
  79147. private static _GetTextureSamplingMode;
  79148. private static _GetTypedArrayConstructor;
  79149. private static _GetTypedArray;
  79150. private static _GetNumComponents;
  79151. private static _ValidateUri;
  79152. private static _GetDrawMode;
  79153. private _compileMaterialsAsync;
  79154. private _compileShadowGeneratorsAsync;
  79155. private _forEachExtensions;
  79156. private _applyExtensions;
  79157. private _extensionsOnLoading;
  79158. private _extensionsOnReady;
  79159. private _extensionsLoadSceneAsync;
  79160. private _extensionsLoadNodeAsync;
  79161. private _extensionsLoadCameraAsync;
  79162. private _extensionsLoadVertexDataAsync;
  79163. private _extensionsLoadMeshPrimitiveAsync;
  79164. private _extensionsLoadMaterialAsync;
  79165. private _extensionsCreateMaterial;
  79166. private _extensionsLoadMaterialPropertiesAsync;
  79167. private _extensionsLoadTextureInfoAsync;
  79168. private _extensionsLoadTextureAsync;
  79169. private _extensionsLoadAnimationAsync;
  79170. private _extensionsLoadSkinAsync;
  79171. private _extensionsLoadUriAsync;
  79172. private _extensionsLoadBufferViewAsync;
  79173. private _extensionsLoadBufferAsync;
  79174. /**
  79175. * Helper method called by a loader extension to load an glTF extension.
  79176. * @param context The context when loading the asset
  79177. * @param property The glTF property to load the extension from
  79178. * @param extensionName The name of the extension to load
  79179. * @param actionAsync The action to run
  79180. * @returns The promise returned by actionAsync or null if the extension does not exist
  79181. */
  79182. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79183. /**
  79184. * Helper method called by a loader extension to load a glTF extra.
  79185. * @param context The context when loading the asset
  79186. * @param property The glTF property to load the extra from
  79187. * @param extensionName The name of the extension to load
  79188. * @param actionAsync The action to run
  79189. * @returns The promise returned by actionAsync or null if the extra does not exist
  79190. */
  79191. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79192. /**
  79193. * Checks for presence of an extension.
  79194. * @param name The name of the extension to check
  79195. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79196. */
  79197. isExtensionUsed(name: string): boolean;
  79198. /**
  79199. * Increments the indentation level and logs a message.
  79200. * @param message The message to log
  79201. */
  79202. logOpen(message: string): void;
  79203. /**
  79204. * Decrements the indentation level.
  79205. */
  79206. logClose(): void;
  79207. /**
  79208. * Logs a message
  79209. * @param message The message to log
  79210. */
  79211. log(message: string): void;
  79212. /**
  79213. * Starts a performance counter.
  79214. * @param counterName The name of the performance counter
  79215. */
  79216. startPerformanceCounter(counterName: string): void;
  79217. /**
  79218. * Ends a performance counter.
  79219. * @param counterName The name of the performance counter
  79220. */
  79221. endPerformanceCounter(counterName: string): void;
  79222. }
  79223. }
  79224. declare module BABYLON.GLTF2.Loader.Extensions {
  79225. /**
  79226. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79227. */
  79228. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79229. /**
  79230. * The name of this extension.
  79231. */
  79232. readonly name: string;
  79233. /**
  79234. * Defines whether this extension is enabled.
  79235. */
  79236. enabled: boolean;
  79237. private _loader;
  79238. private _lights?;
  79239. /** @hidden */
  79240. constructor(loader: GLTFLoader);
  79241. /** @hidden */
  79242. dispose(): void;
  79243. /** @hidden */
  79244. onLoading(): void;
  79245. /** @hidden */
  79246. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79247. private _loadLightAsync;
  79248. }
  79249. }
  79250. declare module BABYLON.GLTF2.Loader.Extensions {
  79251. /**
  79252. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79253. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79254. * !!! Experimental Extension Subject to Changes !!!
  79255. */
  79256. export class EXT_mesh_gpu_instancing 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. private _loader;
  79266. /** @hidden */
  79267. constructor(loader: GLTFLoader);
  79268. /** @hidden */
  79269. dispose(): void;
  79270. /** @hidden */
  79271. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79272. }
  79273. }
  79274. declare module BABYLON.GLTF2.Loader.Extensions {
  79275. /**
  79276. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79277. */
  79278. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79279. /**
  79280. * The name of this extension.
  79281. */
  79282. readonly name: string;
  79283. /**
  79284. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79285. */
  79286. dracoCompression?: DracoCompression;
  79287. /**
  79288. * Defines whether this extension is enabled.
  79289. */
  79290. enabled: boolean;
  79291. private _loader;
  79292. /** @hidden */
  79293. constructor(loader: GLTFLoader);
  79294. /** @hidden */
  79295. dispose(): void;
  79296. /** @hidden */
  79297. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79298. }
  79299. }
  79300. declare module BABYLON.GLTF2.Loader.Extensions {
  79301. /**
  79302. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79303. */
  79304. export class KHR_lights implements IGLTFLoaderExtension {
  79305. /**
  79306. * The name of this extension.
  79307. */
  79308. readonly name: string;
  79309. /**
  79310. * Defines whether this extension is enabled.
  79311. */
  79312. enabled: boolean;
  79313. private _loader;
  79314. private _lights?;
  79315. /** @hidden */
  79316. constructor(loader: GLTFLoader);
  79317. /** @hidden */
  79318. dispose(): void;
  79319. /** @hidden */
  79320. onLoading(): void;
  79321. /** @hidden */
  79322. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79323. }
  79324. }
  79325. declare module BABYLON.GLTF2.Loader.Extensions {
  79326. /**
  79327. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  79328. */
  79329. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  79330. /**
  79331. * The name of this extension.
  79332. */
  79333. readonly name: string;
  79334. /**
  79335. * Defines whether this extension is enabled.
  79336. */
  79337. enabled: boolean;
  79338. /**
  79339. * Defines a number that determines the order the extensions are applied.
  79340. */
  79341. order: number;
  79342. private _loader;
  79343. /** @hidden */
  79344. constructor(loader: GLTFLoader);
  79345. /** @hidden */
  79346. dispose(): void;
  79347. /** @hidden */
  79348. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79349. private _loadSpecularGlossinessPropertiesAsync;
  79350. }
  79351. }
  79352. declare module BABYLON.GLTF2.Loader.Extensions {
  79353. /**
  79354. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  79355. */
  79356. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  79357. /**
  79358. * The name of this extension.
  79359. */
  79360. readonly name: string;
  79361. /**
  79362. * Defines whether this extension is enabled.
  79363. */
  79364. enabled: boolean;
  79365. /**
  79366. * Defines a number that determines the order the extensions are applied.
  79367. */
  79368. order: number;
  79369. private _loader;
  79370. /** @hidden */
  79371. constructor(loader: GLTFLoader);
  79372. /** @hidden */
  79373. dispose(): void;
  79374. /** @hidden */
  79375. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79376. private _loadUnlitPropertiesAsync;
  79377. }
  79378. }
  79379. declare module BABYLON.GLTF2.Loader.Extensions {
  79380. /**
  79381. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  79382. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  79383. * !!! Experimental Extension Subject to Changes !!!
  79384. */
  79385. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  79386. /**
  79387. * The name of this extension.
  79388. */
  79389. readonly name: string;
  79390. /**
  79391. * Defines whether this extension is enabled.
  79392. */
  79393. enabled: boolean;
  79394. /**
  79395. * Defines a number that determines the order the extensions are applied.
  79396. */
  79397. order: number;
  79398. private _loader;
  79399. /** @hidden */
  79400. constructor(loader: GLTFLoader);
  79401. /** @hidden */
  79402. dispose(): void;
  79403. /** @hidden */
  79404. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79405. private _loadClearCoatPropertiesAsync;
  79406. }
  79407. }
  79408. declare module BABYLON.GLTF2.Loader.Extensions {
  79409. /**
  79410. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  79411. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  79412. * !!! Experimental Extension Subject to Changes !!!
  79413. */
  79414. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  79415. /**
  79416. * The name of this extension.
  79417. */
  79418. readonly name: string;
  79419. /**
  79420. * Defines whether this extension is enabled.
  79421. */
  79422. enabled: boolean;
  79423. /**
  79424. * Defines a number that determines the order the extensions are applied.
  79425. */
  79426. order: number;
  79427. private _loader;
  79428. /** @hidden */
  79429. constructor(loader: GLTFLoader);
  79430. /** @hidden */
  79431. dispose(): void;
  79432. /** @hidden */
  79433. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79434. private _loadSheenPropertiesAsync;
  79435. }
  79436. }
  79437. declare module BABYLON.GLTF2.Loader.Extensions {
  79438. /**
  79439. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  79440. * !!! Experimental Extension Subject to Changes !!!
  79441. */
  79442. export class KHR_materials_specular implements IGLTFLoaderExtension {
  79443. /**
  79444. * The name of this extension.
  79445. */
  79446. readonly name: string;
  79447. /**
  79448. * Defines whether this extension is enabled.
  79449. */
  79450. enabled: boolean;
  79451. /**
  79452. * Defines a number that determines the order the extensions are applied.
  79453. */
  79454. order: number;
  79455. private _loader;
  79456. /** @hidden */
  79457. constructor(loader: GLTFLoader);
  79458. /** @hidden */
  79459. dispose(): void;
  79460. /** @hidden */
  79461. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79462. private _loadSpecularPropertiesAsync;
  79463. }
  79464. }
  79465. declare module BABYLON.GLTF2.Loader.Extensions {
  79466. /**
  79467. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  79468. * !!! Experimental Extension Subject to Changes !!!
  79469. */
  79470. export class KHR_materials_ior implements IGLTFLoaderExtension {
  79471. /**
  79472. * Default ior Value from the spec.
  79473. */
  79474. private static readonly _DEFAULT_IOR;
  79475. /**
  79476. * The name of this extension.
  79477. */
  79478. readonly name: string;
  79479. /**
  79480. * Defines whether this extension is enabled.
  79481. */
  79482. enabled: boolean;
  79483. /**
  79484. * Defines a number that determines the order the extensions are applied.
  79485. */
  79486. order: number;
  79487. private _loader;
  79488. /** @hidden */
  79489. constructor(loader: GLTFLoader);
  79490. /** @hidden */
  79491. dispose(): void;
  79492. /** @hidden */
  79493. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79494. private _loadIorPropertiesAsync;
  79495. }
  79496. }
  79497. declare module BABYLON.GLTF2.Loader.Extensions {
  79498. /**
  79499. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  79500. */
  79501. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  79502. /**
  79503. * The name of this extension.
  79504. */
  79505. readonly name: string;
  79506. /**
  79507. * Defines whether this extension is enabled.
  79508. */
  79509. enabled: boolean;
  79510. /** @hidden */
  79511. constructor(loader: GLTFLoader);
  79512. /** @hidden */
  79513. dispose(): void;
  79514. }
  79515. }
  79516. declare module BABYLON.GLTF2.Loader.Extensions {
  79517. /**
  79518. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  79519. * !!! Experimental Extension Subject to Changes !!!
  79520. */
  79521. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  79522. /** The name of this extension. */
  79523. readonly name: string;
  79524. /** Defines whether this extension is enabled. */
  79525. enabled: boolean;
  79526. private _loader;
  79527. /** @hidden */
  79528. constructor(loader: GLTFLoader);
  79529. /** @hidden */
  79530. dispose(): void;
  79531. /** @hidden */
  79532. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79533. }
  79534. }
  79535. declare module BABYLON.GLTF2.Loader.Extensions {
  79536. /**
  79537. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  79538. */
  79539. export class KHR_texture_transform implements IGLTFLoaderExtension {
  79540. /**
  79541. * The name of this extension.
  79542. */
  79543. readonly name: string;
  79544. /**
  79545. * Defines whether this extension is enabled.
  79546. */
  79547. enabled: boolean;
  79548. private _loader;
  79549. /** @hidden */
  79550. constructor(loader: GLTFLoader);
  79551. /** @hidden */
  79552. dispose(): void;
  79553. /** @hidden */
  79554. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79555. }
  79556. }
  79557. declare module BABYLON.GLTF2.Loader.Extensions {
  79558. /**
  79559. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  79560. */
  79561. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  79562. /**
  79563. * The name of this extension.
  79564. */
  79565. readonly name: string;
  79566. /**
  79567. * Defines whether this extension is enabled.
  79568. */
  79569. enabled: boolean;
  79570. private _loader;
  79571. private _clips;
  79572. private _emitters;
  79573. /** @hidden */
  79574. constructor(loader: GLTFLoader);
  79575. /** @hidden */
  79576. dispose(): void;
  79577. /** @hidden */
  79578. onLoading(): void;
  79579. /** @hidden */
  79580. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79581. /** @hidden */
  79582. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79583. /** @hidden */
  79584. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79585. private _loadClipAsync;
  79586. private _loadEmitterAsync;
  79587. private _getEventAction;
  79588. private _loadAnimationEventAsync;
  79589. }
  79590. }
  79591. declare module BABYLON.GLTF2.Loader.Extensions {
  79592. /**
  79593. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  79594. */
  79595. export class MSFT_lod implements IGLTFLoaderExtension {
  79596. /**
  79597. * The name of this extension.
  79598. */
  79599. readonly name: string;
  79600. /**
  79601. * Defines whether this extension is enabled.
  79602. */
  79603. enabled: boolean;
  79604. /**
  79605. * Defines a number that determines the order the extensions are applied.
  79606. */
  79607. order: number;
  79608. /**
  79609. * Maximum number of LODs to load, starting from the lowest LOD.
  79610. */
  79611. maxLODsToLoad: number;
  79612. /**
  79613. * Observable raised when all node LODs of one level are loaded.
  79614. * The event data is the index of the loaded LOD starting from zero.
  79615. * Dispose the loader to cancel the loading of the next level of LODs.
  79616. */
  79617. onNodeLODsLoadedObservable: Observable<number>;
  79618. /**
  79619. * Observable raised when all material LODs of one level are loaded.
  79620. * The event data is the index of the loaded LOD starting from zero.
  79621. * Dispose the loader to cancel the loading of the next level of LODs.
  79622. */
  79623. onMaterialLODsLoadedObservable: Observable<number>;
  79624. private _loader;
  79625. private _nodeIndexLOD;
  79626. private _nodeSignalLODs;
  79627. private _nodePromiseLODs;
  79628. private _materialIndexLOD;
  79629. private _materialSignalLODs;
  79630. private _materialPromiseLODs;
  79631. private _indexLOD;
  79632. private _bufferLODs;
  79633. /** @hidden */
  79634. constructor(loader: GLTFLoader);
  79635. /** @hidden */
  79636. dispose(): void;
  79637. /** @hidden */
  79638. onReady(): void;
  79639. /** @hidden */
  79640. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79641. /** @hidden */
  79642. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79643. /** @hidden */
  79644. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79645. /** @hidden */
  79646. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79647. /** @hidden */
  79648. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79649. private _loadBufferLOD;
  79650. /**
  79651. * Gets an array of LOD properties from lowest to highest.
  79652. */
  79653. private _getLODs;
  79654. private _disposeTransformNode;
  79655. private _disposeMaterials;
  79656. }
  79657. }
  79658. declare module BABYLON.GLTF2.Loader.Extensions {
  79659. /** @hidden */
  79660. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  79661. readonly name: string;
  79662. enabled: boolean;
  79663. private _loader;
  79664. constructor(loader: GLTFLoader);
  79665. dispose(): void;
  79666. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79667. }
  79668. }
  79669. declare module BABYLON.GLTF2.Loader.Extensions {
  79670. /** @hidden */
  79671. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  79672. readonly name: string;
  79673. enabled: boolean;
  79674. private _loader;
  79675. constructor(loader: GLTFLoader);
  79676. dispose(): void;
  79677. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79678. }
  79679. }
  79680. declare module BABYLON.GLTF2.Loader.Extensions {
  79681. /**
  79682. * Store glTF extras (if present) in BJS objects' metadata
  79683. */
  79684. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  79685. /**
  79686. * The name of this extension.
  79687. */
  79688. readonly name: string;
  79689. /**
  79690. * Defines whether this extension is enabled.
  79691. */
  79692. enabled: boolean;
  79693. private _loader;
  79694. private _assignExtras;
  79695. /** @hidden */
  79696. constructor(loader: GLTFLoader);
  79697. /** @hidden */
  79698. dispose(): void;
  79699. /** @hidden */
  79700. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79701. /** @hidden */
  79702. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79703. /** @hidden */
  79704. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79705. }
  79706. }
  79707. declare module BABYLON {
  79708. /**
  79709. * Class reading and parsing the MTL file bundled with the obj file.
  79710. */
  79711. export class MTLFileLoader {
  79712. /**
  79713. * Invert Y-Axis of referenced textures on load
  79714. */
  79715. static INVERT_TEXTURE_Y: boolean;
  79716. /**
  79717. * All material loaded from the mtl will be set here
  79718. */
  79719. materials: StandardMaterial[];
  79720. /**
  79721. * This function will read the mtl file and create each material described inside
  79722. * This function could be improve by adding :
  79723. * -some component missing (Ni, Tf...)
  79724. * -including the specific options available
  79725. *
  79726. * @param scene defines the scene the material will be created in
  79727. * @param data defines the mtl data to parse
  79728. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  79729. * @param forAssetContainer defines if the material should be registered in the scene
  79730. */
  79731. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  79732. /**
  79733. * Gets the texture for the material.
  79734. *
  79735. * If the material is imported from input file,
  79736. * We sanitize the url to ensure it takes the textre from aside the material.
  79737. *
  79738. * @param rootUrl The root url to load from
  79739. * @param value The value stored in the mtl
  79740. * @return The Texture
  79741. */
  79742. private static _getTexture;
  79743. }
  79744. }
  79745. declare module BABYLON {
  79746. /**
  79747. * Options for loading OBJ/MTL files
  79748. */
  79749. type MeshLoadOptions = {
  79750. /**
  79751. * Defines if UVs are optimized by default during load.
  79752. */
  79753. OptimizeWithUV: boolean;
  79754. /**
  79755. * Defines custom scaling of UV coordinates of loaded meshes.
  79756. */
  79757. UVScaling: Vector2;
  79758. /**
  79759. * Invert model on y-axis (does a model scaling inversion)
  79760. */
  79761. InvertY: boolean;
  79762. /**
  79763. * Invert Y-Axis of referenced textures on load
  79764. */
  79765. InvertTextureY: boolean;
  79766. /**
  79767. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  79768. */
  79769. ImportVertexColors: boolean;
  79770. /**
  79771. * Compute the normals for the model, even if normals are present in the file.
  79772. */
  79773. ComputeNormals: boolean;
  79774. /**
  79775. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  79776. */
  79777. SkipMaterials: boolean;
  79778. /**
  79779. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  79780. */
  79781. MaterialLoadingFailsSilently: boolean;
  79782. };
  79783. /**
  79784. * OBJ file type loader.
  79785. * This is a babylon scene loader plugin.
  79786. */
  79787. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79788. /**
  79789. * Defines if UVs are optimized by default during load.
  79790. */
  79791. static OPTIMIZE_WITH_UV: boolean;
  79792. /**
  79793. * Invert model on y-axis (does a model scaling inversion)
  79794. */
  79795. static INVERT_Y: boolean;
  79796. /**
  79797. * Invert Y-Axis of referenced textures on load
  79798. */
  79799. static get INVERT_TEXTURE_Y(): boolean;
  79800. static set INVERT_TEXTURE_Y(value: boolean);
  79801. /**
  79802. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  79803. */
  79804. static IMPORT_VERTEX_COLORS: boolean;
  79805. /**
  79806. * Compute the normals for the model, even if normals are present in the file.
  79807. */
  79808. static COMPUTE_NORMALS: boolean;
  79809. /**
  79810. * Defines custom scaling of UV coordinates of loaded meshes.
  79811. */
  79812. static UV_SCALING: Vector2;
  79813. /**
  79814. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  79815. */
  79816. static SKIP_MATERIALS: boolean;
  79817. /**
  79818. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  79819. *
  79820. * Defaults to true for backwards compatibility.
  79821. */
  79822. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  79823. /**
  79824. * Defines the name of the plugin.
  79825. */
  79826. name: string;
  79827. /**
  79828. * Defines the extension the plugin is able to load.
  79829. */
  79830. extensions: string;
  79831. /** @hidden */
  79832. obj: RegExp;
  79833. /** @hidden */
  79834. group: RegExp;
  79835. /** @hidden */
  79836. mtllib: RegExp;
  79837. /** @hidden */
  79838. usemtl: RegExp;
  79839. /** @hidden */
  79840. smooth: RegExp;
  79841. /** @hidden */
  79842. vertexPattern: RegExp;
  79843. /** @hidden */
  79844. normalPattern: RegExp;
  79845. /** @hidden */
  79846. uvPattern: RegExp;
  79847. /** @hidden */
  79848. facePattern1: RegExp;
  79849. /** @hidden */
  79850. facePattern2: RegExp;
  79851. /** @hidden */
  79852. facePattern3: RegExp;
  79853. /** @hidden */
  79854. facePattern4: RegExp;
  79855. /** @hidden */
  79856. facePattern5: RegExp;
  79857. private _forAssetContainer;
  79858. private _meshLoadOptions;
  79859. /**
  79860. * Creates loader for .OBJ files
  79861. *
  79862. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  79863. */
  79864. constructor(meshLoadOptions?: MeshLoadOptions);
  79865. private static get currentMeshLoadOptions();
  79866. /**
  79867. * Calls synchronously the MTL file attached to this obj.
  79868. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  79869. * Without this function materials are not displayed in the first frame (but displayed after).
  79870. * In consequence it is impossible to get material information in your HTML file
  79871. *
  79872. * @param url The URL of the MTL file
  79873. * @param rootUrl
  79874. * @param onSuccess Callback function to be called when the MTL file is loaded
  79875. * @private
  79876. */
  79877. private _loadMTL;
  79878. /**
  79879. * Instantiates a OBJ file loader plugin.
  79880. * @returns the created plugin
  79881. */
  79882. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  79883. /**
  79884. * If the data string can be loaded directly.
  79885. *
  79886. * @param data string containing the file data
  79887. * @returns if the data can be loaded directly
  79888. */
  79889. canDirectLoad(data: string): boolean;
  79890. /**
  79891. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  79892. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79893. * @param scene the scene the meshes should be added to
  79894. * @param data the OBJ data to load
  79895. * @param rootUrl root url to load from
  79896. * @param onProgress event that fires when loading progress has occured
  79897. * @param fileName Defines the name of the file to load
  79898. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79899. */
  79900. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79901. meshes: AbstractMesh[];
  79902. particleSystems: IParticleSystem[];
  79903. skeletons: Skeleton[];
  79904. animationGroups: AnimationGroup[];
  79905. }>;
  79906. /**
  79907. * Imports all objects from the loaded OBJ data and adds them to the scene
  79908. * @param scene the scene the objects should be added to
  79909. * @param data the OBJ data to load
  79910. * @param rootUrl root url to load from
  79911. * @param onProgress event that fires when loading progress has occured
  79912. * @param fileName Defines the name of the file to load
  79913. * @returns a promise which completes when objects have been loaded to the scene
  79914. */
  79915. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79916. /**
  79917. * Load into an asset container.
  79918. * @param scene The scene to load into
  79919. * @param data The data to import
  79920. * @param rootUrl The root url for scene and resources
  79921. * @param onProgress The callback when the load progresses
  79922. * @param fileName Defines the name of the file to load
  79923. * @returns The loaded asset container
  79924. */
  79925. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79926. /**
  79927. * Read the OBJ file and create an Array of meshes.
  79928. * Each mesh contains all information given by the OBJ and the MTL file.
  79929. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  79930. *
  79931. * @param meshesNames
  79932. * @param scene Scene The scene where are displayed the data
  79933. * @param data String The content of the obj file
  79934. * @param rootUrl String The path to the folder
  79935. * @returns Array<AbstractMesh>
  79936. * @private
  79937. */
  79938. private _parseSolid;
  79939. }
  79940. }
  79941. declare module BABYLON {
  79942. /**
  79943. * STL file type loader.
  79944. * This is a babylon scene loader plugin.
  79945. */
  79946. export class STLFileLoader implements ISceneLoaderPlugin {
  79947. /** @hidden */
  79948. solidPattern: RegExp;
  79949. /** @hidden */
  79950. facetsPattern: RegExp;
  79951. /** @hidden */
  79952. normalPattern: RegExp;
  79953. /** @hidden */
  79954. vertexPattern: RegExp;
  79955. /**
  79956. * Defines the name of the plugin.
  79957. */
  79958. name: string;
  79959. /**
  79960. * Defines the extensions the stl loader is able to load.
  79961. * force data to come in as an ArrayBuffer
  79962. * we'll convert to string if it looks like it's an ASCII .stl
  79963. */
  79964. extensions: ISceneLoaderPluginExtensions;
  79965. /**
  79966. * Import meshes into a scene.
  79967. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  79968. * @param scene The scene to import into
  79969. * @param data The data to import
  79970. * @param rootUrl The root url for scene and resources
  79971. * @param meshes The meshes array to import into
  79972. * @param particleSystems The particle systems array to import into
  79973. * @param skeletons The skeletons array to import into
  79974. * @param onError The callback when import fails
  79975. * @returns True if successful or false otherwise
  79976. */
  79977. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  79978. /**
  79979. * Load into a scene.
  79980. * @param scene The scene to load into
  79981. * @param data The data to import
  79982. * @param rootUrl The root url for scene and resources
  79983. * @param onError The callback when import fails
  79984. * @returns true if successful or false otherwise
  79985. */
  79986. load(scene: Scene, data: any, rootUrl: string): boolean;
  79987. /**
  79988. * Load into an asset container.
  79989. * @param scene The scene to load into
  79990. * @param data The data to import
  79991. * @param rootUrl The root url for scene and resources
  79992. * @param onError The callback when import fails
  79993. * @returns The loaded asset container
  79994. */
  79995. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  79996. private _isBinary;
  79997. private _parseBinary;
  79998. private _parseASCII;
  79999. }
  80000. }
  80001. declare module BABYLON {
  80002. /**
  80003. * Class for generating OBJ data from a Babylon scene.
  80004. */
  80005. export class OBJExport {
  80006. /**
  80007. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80008. * @param mesh defines the list of meshes to serialize
  80009. * @param materials defines if materials should be exported
  80010. * @param matlibname defines the name of the associated mtl file
  80011. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80012. * @returns the OBJ content
  80013. */
  80014. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80015. /**
  80016. * Exports the material(s) of a mesh in .MTL file format (text)
  80017. * @param mesh defines the mesh to extract the material from
  80018. * @returns the mtl content
  80019. */
  80020. static MTL(mesh: Mesh): string;
  80021. }
  80022. }
  80023. declare module BABYLON {
  80024. /** @hidden */
  80025. export var __IGLTFExporterExtension: number;
  80026. /**
  80027. * Interface for extending the exporter
  80028. * @hidden
  80029. */
  80030. export interface IGLTFExporterExtension {
  80031. /**
  80032. * The name of this extension
  80033. */
  80034. readonly name: string;
  80035. /**
  80036. * Defines whether this extension is enabled
  80037. */
  80038. enabled: boolean;
  80039. /**
  80040. * Defines whether this extension is required
  80041. */
  80042. required: boolean;
  80043. }
  80044. }
  80045. declare module BABYLON.GLTF2.Exporter {
  80046. /** @hidden */
  80047. export var __IGLTFExporterExtensionV2: number;
  80048. /**
  80049. * Interface for a glTF exporter extension
  80050. * @hidden
  80051. */
  80052. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80053. /**
  80054. * Define this method to modify the default behavior before exporting a texture
  80055. * @param context The context when loading the asset
  80056. * @param babylonTexture The Babylon.js texture
  80057. * @param mimeType The mime-type of the generated image
  80058. * @returns A promise that resolves with the exported texture
  80059. */
  80060. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80061. /**
  80062. * Define this method to get notified when a texture info is created
  80063. * @param context The context when loading the asset
  80064. * @param textureInfo The glTF texture info
  80065. * @param babylonTexture The Babylon.js texture
  80066. */
  80067. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80068. /**
  80069. * Define this method to modify the default behavior when exporting texture info
  80070. * @param context The context when loading the asset
  80071. * @param meshPrimitive glTF mesh primitive
  80072. * @param babylonSubMesh Babylon submesh
  80073. * @param binaryWriter glTF serializer binary writer instance
  80074. * @returns nullable IMeshPrimitive promise
  80075. */
  80076. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80077. /**
  80078. * Define this method to modify the default behavior when exporting a node
  80079. * @param context The context when exporting the node
  80080. * @param node glTF node
  80081. * @param babylonNode BabylonJS node
  80082. * @returns nullable INode promise
  80083. */
  80084. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80085. [key: number]: number;
  80086. }): Promise<Nullable<INode>>;
  80087. /**
  80088. * Define this method to modify the default behavior when exporting a material
  80089. * @param material glTF material
  80090. * @param babylonMaterial BabylonJS material
  80091. * @returns nullable IMaterial promise
  80092. */
  80093. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80094. /**
  80095. * Define this method to return additional textures to export from a material
  80096. * @param material glTF material
  80097. * @param babylonMaterial BabylonJS material
  80098. * @returns List of textures
  80099. */
  80100. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80101. /** Gets a boolean indicating that this extension was used */
  80102. wasUsed: boolean;
  80103. /** Gets a boolean indicating that this extension is required for the file to work */
  80104. required: boolean;
  80105. /**
  80106. * Called after the exporter state changes to EXPORTING
  80107. */
  80108. onExporting?(): void;
  80109. }
  80110. }
  80111. declare module BABYLON.GLTF2.Exporter {
  80112. /**
  80113. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80114. * @hidden
  80115. */
  80116. export class _GLTFMaterialExporter {
  80117. /**
  80118. * Represents the dielectric specular values for R, G and B
  80119. */
  80120. private static readonly _DielectricSpecular;
  80121. /**
  80122. * Allows the maximum specular power to be defined for material calculations
  80123. */
  80124. private static readonly _MaxSpecularPower;
  80125. /**
  80126. * Mapping to store textures
  80127. */
  80128. private _textureMap;
  80129. /**
  80130. * Numeric tolerance value
  80131. */
  80132. private static readonly _Epsilon;
  80133. /**
  80134. * Reference to the glTF Exporter
  80135. */
  80136. private _exporter;
  80137. constructor(exporter: _Exporter);
  80138. /**
  80139. * Specifies if two colors are approximately equal in value
  80140. * @param color1 first color to compare to
  80141. * @param color2 second color to compare to
  80142. * @param epsilon threshold value
  80143. */
  80144. private static FuzzyEquals;
  80145. /**
  80146. * Gets the materials from a Babylon scene and converts them to glTF materials
  80147. * @param scene babylonjs scene
  80148. * @param mimeType texture mime type
  80149. * @param images array of images
  80150. * @param textures array of textures
  80151. * @param materials array of materials
  80152. * @param imageData mapping of texture names to base64 textures
  80153. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80154. */
  80155. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80156. /**
  80157. * Makes a copy of the glTF material without the texture parameters
  80158. * @param originalMaterial original glTF material
  80159. * @returns glTF material without texture parameters
  80160. */
  80161. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80162. /**
  80163. * Specifies if the material has any texture parameters present
  80164. * @param material glTF Material
  80165. * @returns boolean specifying if texture parameters are present
  80166. */
  80167. _hasTexturesPresent(material: IMaterial): boolean;
  80168. /**
  80169. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80170. * @param babylonStandardMaterial
  80171. * @returns glTF Metallic Roughness Material representation
  80172. */
  80173. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80174. /**
  80175. * Computes the metallic factor
  80176. * @param diffuse diffused value
  80177. * @param specular specular value
  80178. * @param oneMinusSpecularStrength one minus the specular strength
  80179. * @returns metallic value
  80180. */
  80181. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80182. /**
  80183. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80184. * @param glTFMaterial glTF material
  80185. * @param babylonMaterial Babylon material
  80186. */
  80187. private static _SetAlphaMode;
  80188. /**
  80189. * Converts a Babylon Standard Material to a glTF Material
  80190. * @param babylonStandardMaterial BJS Standard Material
  80191. * @param mimeType mime type to use for the textures
  80192. * @param images array of glTF image interfaces
  80193. * @param textures array of glTF texture interfaces
  80194. * @param materials array of glTF material interfaces
  80195. * @param imageData map of image file name to data
  80196. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80197. */
  80198. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80199. private _finishMaterial;
  80200. /**
  80201. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80202. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  80203. * @param mimeType mime type to use for the textures
  80204. * @param images array of glTF image interfaces
  80205. * @param textures array of glTF texture interfaces
  80206. * @param materials array of glTF material interfaces
  80207. * @param imageData map of image file name to data
  80208. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80209. */
  80210. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80211. /**
  80212. * Converts an image typed array buffer to a base64 image
  80213. * @param buffer typed array buffer
  80214. * @param width width of the image
  80215. * @param height height of the image
  80216. * @param mimeType mimetype of the image
  80217. * @returns base64 image string
  80218. */
  80219. private _createBase64FromCanvasAsync;
  80220. /**
  80221. * Generates a white texture based on the specified width and height
  80222. * @param width width of the texture in pixels
  80223. * @param height height of the texture in pixels
  80224. * @param scene babylonjs scene
  80225. * @returns white texture
  80226. */
  80227. private _createWhiteTexture;
  80228. /**
  80229. * 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
  80230. * @param texture1 first texture to resize
  80231. * @param texture2 second texture to resize
  80232. * @param scene babylonjs scene
  80233. * @returns resized textures or null
  80234. */
  80235. private _resizeTexturesToSameDimensions;
  80236. /**
  80237. * Converts an array of pixels to a Float32Array
  80238. * Throws an error if the pixel format is not supported
  80239. * @param pixels - array buffer containing pixel values
  80240. * @returns Float32 of pixels
  80241. */
  80242. private _convertPixelArrayToFloat32;
  80243. /**
  80244. * Convert Specular Glossiness Textures to Metallic Roughness
  80245. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  80246. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  80247. * @param diffuseTexture texture used to store diffuse information
  80248. * @param specularGlossinessTexture texture used to store specular and glossiness information
  80249. * @param factors specular glossiness material factors
  80250. * @param mimeType the mime type to use for the texture
  80251. * @returns pbr metallic roughness interface or null
  80252. */
  80253. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  80254. /**
  80255. * Converts specular glossiness material properties to metallic roughness
  80256. * @param specularGlossiness interface with specular glossiness material properties
  80257. * @returns interface with metallic roughness material properties
  80258. */
  80259. private _convertSpecularGlossinessToMetallicRoughness;
  80260. /**
  80261. * Calculates the surface reflectance, independent of lighting conditions
  80262. * @param color Color source to calculate brightness from
  80263. * @returns number representing the perceived brightness, or zero if color is undefined
  80264. */
  80265. private _getPerceivedBrightness;
  80266. /**
  80267. * Returns the maximum color component value
  80268. * @param color
  80269. * @returns maximum color component value, or zero if color is null or undefined
  80270. */
  80271. private _getMaxComponent;
  80272. /**
  80273. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  80274. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80275. * @param mimeType mime type to use for the textures
  80276. * @param images array of glTF image interfaces
  80277. * @param textures array of glTF texture interfaces
  80278. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80279. * @param imageData map of image file name to data
  80280. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80281. * @returns glTF PBR Metallic Roughness factors
  80282. */
  80283. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  80284. private _getGLTFTextureSampler;
  80285. private _getGLTFTextureWrapMode;
  80286. private _getGLTFTextureWrapModesSampler;
  80287. /**
  80288. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  80289. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80290. * @param mimeType mime type to use for the textures
  80291. * @param images array of glTF image interfaces
  80292. * @param textures array of glTF texture interfaces
  80293. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80294. * @param imageData map of image file name to data
  80295. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80296. * @returns glTF PBR Metallic Roughness factors
  80297. */
  80298. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  80299. /**
  80300. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80301. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80302. * @param mimeType mime type to use for the textures
  80303. * @param images array of glTF image interfaces
  80304. * @param textures array of glTF texture interfaces
  80305. * @param materials array of glTF material interfaces
  80306. * @param imageData map of image file name to data
  80307. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80308. */
  80309. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80310. private setMetallicRoughnessPbrMaterial;
  80311. private getPixelsFromTexture;
  80312. /**
  80313. * Extracts a texture from a Babylon texture into file data and glTF data
  80314. * @param babylonTexture Babylon texture to extract
  80315. * @param mimeType Mime Type of the babylonTexture
  80316. * @return glTF texture info, or null if the texture format is not supported
  80317. */
  80318. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80319. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80320. /**
  80321. * Builds a texture from base64 string
  80322. * @param base64Texture base64 texture string
  80323. * @param baseTextureName Name to use for the texture
  80324. * @param mimeType image mime type for the texture
  80325. * @param images array of images
  80326. * @param textures array of textures
  80327. * @param imageData map of image data
  80328. * @returns glTF texture info, or null if the texture format is not supported
  80329. */
  80330. private _getTextureInfoFromBase64;
  80331. }
  80332. }
  80333. declare module BABYLON {
  80334. /**
  80335. * Class for holding and downloading glTF file data
  80336. */
  80337. export class GLTFData {
  80338. /**
  80339. * Object which contains the file name as the key and its data as the value
  80340. */
  80341. glTFFiles: {
  80342. [fileName: string]: string | Blob;
  80343. };
  80344. /**
  80345. * Initializes the glTF file object
  80346. */
  80347. constructor();
  80348. /**
  80349. * Downloads the glTF data as files based on their names and data
  80350. */
  80351. downloadFiles(): void;
  80352. }
  80353. }
  80354. declare module BABYLON {
  80355. /**
  80356. * Holds a collection of exporter options and parameters
  80357. */
  80358. export interface IExportOptions {
  80359. /**
  80360. * Function which indicates whether a babylon node should be exported or not
  80361. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  80362. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  80363. */
  80364. shouldExportNode?(node: Node): boolean;
  80365. /**
  80366. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  80367. * @param metadata source metadata to read from
  80368. * @returns the data to store to glTF node extras
  80369. */
  80370. metadataSelector?(metadata: any): any;
  80371. /**
  80372. * The sample rate to bake animation curves
  80373. */
  80374. animationSampleRate?: number;
  80375. /**
  80376. * Begin serialization without waiting for the scene to be ready
  80377. */
  80378. exportWithoutWaitingForScene?: boolean;
  80379. /**
  80380. * Indicates if coordinate system swapping root nodes should be included in export
  80381. */
  80382. includeCoordinateSystemConversionNodes?: boolean;
  80383. }
  80384. /**
  80385. * Class for generating glTF data from a Babylon scene.
  80386. */
  80387. export class GLTF2Export {
  80388. /**
  80389. * Exports the geometry of the scene to .gltf file format asynchronously
  80390. * @param scene Babylon scene with scene hierarchy information
  80391. * @param filePrefix File prefix to use when generating the glTF file
  80392. * @param options Exporter options
  80393. * @returns Returns an object with a .gltf file and associates texture names
  80394. * as keys and their data and paths as values
  80395. */
  80396. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80397. private static _PreExportAsync;
  80398. private static _PostExportAsync;
  80399. /**
  80400. * Exports the geometry of the scene to .glb file format asychronously
  80401. * @param scene Babylon scene with scene hierarchy information
  80402. * @param filePrefix File prefix to use when generating glb file
  80403. * @param options Exporter options
  80404. * @returns Returns an object with a .glb filename as key and data as value
  80405. */
  80406. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80407. }
  80408. }
  80409. declare module BABYLON.GLTF2.Exporter {
  80410. /**
  80411. * @hidden
  80412. */
  80413. export class _GLTFUtilities {
  80414. /**
  80415. * Creates a buffer view based on the supplied arguments
  80416. * @param bufferIndex index value of the specified buffer
  80417. * @param byteOffset byte offset value
  80418. * @param byteLength byte length of the bufferView
  80419. * @param byteStride byte distance between conequential elements
  80420. * @param name name of the buffer view
  80421. * @returns bufferView for glTF
  80422. */
  80423. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  80424. /**
  80425. * Creates an accessor based on the supplied arguments
  80426. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  80427. * @param name The name of the accessor
  80428. * @param type The type of the accessor
  80429. * @param componentType The datatype of components in the attribute
  80430. * @param count The number of attributes referenced by this accessor
  80431. * @param byteOffset The offset relative to the start of the bufferView in bytes
  80432. * @param min Minimum value of each component in this attribute
  80433. * @param max Maximum value of each component in this attribute
  80434. * @returns accessor for glTF
  80435. */
  80436. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  80437. /**
  80438. * Calculates the minimum and maximum values of an array of position floats
  80439. * @param positions Positions array of a mesh
  80440. * @param vertexStart Starting vertex offset to calculate min and max values
  80441. * @param vertexCount Number of vertices to check for min and max values
  80442. * @returns min number array and max number array
  80443. */
  80444. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  80445. min: number[];
  80446. max: number[];
  80447. };
  80448. /**
  80449. * Converts a new right-handed Vector3
  80450. * @param vector vector3 array
  80451. * @returns right-handed Vector3
  80452. */
  80453. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  80454. /**
  80455. * Converts a Vector3 to right-handed
  80456. * @param vector Vector3 to convert to right-handed
  80457. */
  80458. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  80459. /**
  80460. * Converts a three element number array to right-handed
  80461. * @param vector number array to convert to right-handed
  80462. */
  80463. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  80464. /**
  80465. * Converts a new right-handed Vector3
  80466. * @param vector vector3 array
  80467. * @returns right-handed Vector3
  80468. */
  80469. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  80470. /**
  80471. * Converts a Vector3 to right-handed
  80472. * @param vector Vector3 to convert to right-handed
  80473. */
  80474. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  80475. /**
  80476. * Converts a three element number array to right-handed
  80477. * @param vector number array to convert to right-handed
  80478. */
  80479. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  80480. /**
  80481. * Converts a Vector4 to right-handed
  80482. * @param vector Vector4 to convert to right-handed
  80483. */
  80484. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  80485. /**
  80486. * Converts a Vector4 to right-handed
  80487. * @param vector Vector4 to convert to right-handed
  80488. */
  80489. static _GetRightHandedArray4FromRef(vector: number[]): void;
  80490. /**
  80491. * Converts a Quaternion to right-handed
  80492. * @param quaternion Source quaternion to convert to right-handed
  80493. */
  80494. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  80495. /**
  80496. * Converts a Quaternion to right-handed
  80497. * @param quaternion Source quaternion to convert to right-handed
  80498. */
  80499. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  80500. static _NormalizeTangentFromRef(tangent: Vector4): void;
  80501. }
  80502. }
  80503. declare module BABYLON.GLTF2.Exporter {
  80504. /**
  80505. * Converts Babylon Scene into glTF 2.0.
  80506. * @hidden
  80507. */
  80508. export class _Exporter {
  80509. /**
  80510. * Stores the glTF to export
  80511. */
  80512. _glTF: IGLTF;
  80513. /**
  80514. * Stores all generated buffer views, which represents views into the main glTF buffer data
  80515. */
  80516. _bufferViews: IBufferView[];
  80517. /**
  80518. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  80519. */
  80520. _accessors: IAccessor[];
  80521. /**
  80522. * Stores all the generated nodes, which contains transform and/or mesh information per node
  80523. */
  80524. _nodes: INode[];
  80525. /**
  80526. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  80527. */
  80528. private _scenes;
  80529. /**
  80530. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  80531. */
  80532. private _meshes;
  80533. /**
  80534. * Stores all the generated material information, which represents the appearance of each primitive
  80535. */
  80536. _materials: IMaterial[];
  80537. _materialMap: {
  80538. [materialID: number]: number;
  80539. };
  80540. /**
  80541. * Stores all the generated texture information, which is referenced by glTF materials
  80542. */
  80543. _textures: ITexture[];
  80544. /**
  80545. * Stores all the generated image information, which is referenced by glTF textures
  80546. */
  80547. _images: IImage[];
  80548. /**
  80549. * Stores all the texture samplers
  80550. */
  80551. _samplers: ISampler[];
  80552. /**
  80553. * Stores all the generated animation samplers, which is referenced by glTF animations
  80554. */
  80555. /**
  80556. * Stores the animations for glTF models
  80557. */
  80558. private _animations;
  80559. /**
  80560. * Stores the total amount of bytes stored in the glTF buffer
  80561. */
  80562. private _totalByteLength;
  80563. /**
  80564. * Stores a reference to the Babylon scene containing the source geometry and material information
  80565. */
  80566. _babylonScene: Scene;
  80567. /**
  80568. * Stores a map of the image data, where the key is the file name and the value
  80569. * is the image data
  80570. */
  80571. _imageData: {
  80572. [fileName: string]: {
  80573. data: Uint8Array;
  80574. mimeType: ImageMimeType;
  80575. };
  80576. };
  80577. /**
  80578. * Stores a map of the unique id of a node to its index in the node array
  80579. */
  80580. _nodeMap: {
  80581. [key: number]: number;
  80582. };
  80583. /**
  80584. * Specifies if the source Babylon scene was left handed, and needed conversion.
  80585. */
  80586. _convertToRightHandedSystem: boolean;
  80587. /**
  80588. * Specifies if a Babylon node should be converted to right-handed on export
  80589. */
  80590. _convertToRightHandedSystemMap: {
  80591. [nodeId: number]: boolean;
  80592. };
  80593. _includeCoordinateSystemConversionNodes: boolean;
  80594. /**
  80595. * Baked animation sample rate
  80596. */
  80597. private _animationSampleRate;
  80598. private _options;
  80599. private _localEngine;
  80600. _glTFMaterialExporter: _GLTFMaterialExporter;
  80601. private _extensions;
  80602. private static _ExtensionNames;
  80603. private static _ExtensionFactories;
  80604. private _applyExtension;
  80605. private _applyExtensions;
  80606. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  80607. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  80608. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80609. [key: number]: number;
  80610. }): Promise<Nullable<INode>>;
  80611. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  80612. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  80613. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80614. private _forEachExtensions;
  80615. private _extensionsOnExporting;
  80616. /**
  80617. * Load glTF serializer extensions
  80618. */
  80619. private _loadExtensions;
  80620. /**
  80621. * Creates a glTF Exporter instance, which can accept optional exporter options
  80622. * @param babylonScene Babylon scene object
  80623. * @param options Options to modify the behavior of the exporter
  80624. */
  80625. constructor(babylonScene: Scene, options?: IExportOptions);
  80626. dispose(): void;
  80627. /**
  80628. * Registers a glTF exporter extension
  80629. * @param name Name of the extension to export
  80630. * @param factory The factory function that creates the exporter extension
  80631. */
  80632. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  80633. /**
  80634. * Un-registers an exporter extension
  80635. * @param name The name fo the exporter extension
  80636. * @returns A boolean indicating whether the extension has been un-registered
  80637. */
  80638. static UnregisterExtension(name: string): boolean;
  80639. /**
  80640. * Lazy load a local engine
  80641. */
  80642. _getLocalEngine(): Engine;
  80643. private reorderIndicesBasedOnPrimitiveMode;
  80644. /**
  80645. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  80646. * clock-wise during export to glTF
  80647. * @param submesh BabylonJS submesh
  80648. * @param primitiveMode Primitive mode of the mesh
  80649. * @param sideOrientation the winding order of the submesh
  80650. * @param vertexBufferKind The type of vertex attribute
  80651. * @param meshAttributeArray The vertex attribute data
  80652. * @param byteOffset The offset to the binary data
  80653. * @param binaryWriter The binary data for the glTF file
  80654. * @param convertToRightHandedSystem Converts the values to right-handed
  80655. */
  80656. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  80657. /**
  80658. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  80659. * clock-wise during export to glTF
  80660. * @param submesh BabylonJS submesh
  80661. * @param primitiveMode Primitive mode of the mesh
  80662. * @param sideOrientation the winding order of the submesh
  80663. * @param vertexBufferKind The type of vertex attribute
  80664. * @param meshAttributeArray The vertex attribute data
  80665. * @param byteOffset The offset to the binary data
  80666. * @param binaryWriter The binary data for the glTF file
  80667. * @param convertToRightHandedSystem Converts the values to right-handed
  80668. */
  80669. private reorderTriangleFillMode;
  80670. /**
  80671. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  80672. * clock-wise during export to glTF
  80673. * @param submesh BabylonJS submesh
  80674. * @param primitiveMode Primitive mode of the mesh
  80675. * @param sideOrientation the winding order of the submesh
  80676. * @param vertexBufferKind The type of vertex attribute
  80677. * @param meshAttributeArray The vertex attribute data
  80678. * @param byteOffset The offset to the binary data
  80679. * @param binaryWriter The binary data for the glTF file
  80680. * @param convertToRightHandedSystem Converts the values to right-handed
  80681. */
  80682. private reorderTriangleStripDrawMode;
  80683. /**
  80684. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  80685. * clock-wise during export to glTF
  80686. * @param submesh BabylonJS submesh
  80687. * @param primitiveMode Primitive mode of the mesh
  80688. * @param sideOrientation the winding order of the submesh
  80689. * @param vertexBufferKind The type of vertex attribute
  80690. * @param meshAttributeArray The vertex attribute data
  80691. * @param byteOffset The offset to the binary data
  80692. * @param binaryWriter The binary data for the glTF file
  80693. * @param convertToRightHandedSystem Converts the values to right-handed
  80694. */
  80695. private reorderTriangleFanMode;
  80696. /**
  80697. * Writes the vertex attribute data to binary
  80698. * @param vertices The vertices to write to the binary writer
  80699. * @param byteOffset The offset into the binary writer to overwrite binary data
  80700. * @param vertexAttributeKind The vertex attribute type
  80701. * @param meshAttributeArray The vertex attribute data
  80702. * @param binaryWriter The writer containing the binary data
  80703. * @param convertToRightHandedSystem Converts the values to right-handed
  80704. */
  80705. private writeVertexAttributeData;
  80706. /**
  80707. * Writes mesh attribute data to a data buffer
  80708. * Returns the bytelength of the data
  80709. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  80710. * @param meshAttributeArray Array containing the attribute data
  80711. * @param binaryWriter The buffer to write the binary data to
  80712. * @param indices Used to specify the order of the vertex data
  80713. * @param convertToRightHandedSystem Converts the values to right-handed
  80714. */
  80715. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  80716. /**
  80717. * Generates glTF json data
  80718. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  80719. * @param glTFPrefix Text to use when prefixing a glTF file
  80720. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  80721. * @returns json data as string
  80722. */
  80723. private generateJSON;
  80724. /**
  80725. * Generates data for .gltf and .bin files based on the glTF prefix string
  80726. * @param glTFPrefix Text to use when prefixing a glTF file
  80727. * @param dispose Dispose the exporter
  80728. * @returns GLTFData with glTF file data
  80729. */
  80730. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80731. /**
  80732. * Creates a binary buffer for glTF
  80733. * @returns array buffer for binary data
  80734. */
  80735. private _generateBinaryAsync;
  80736. /**
  80737. * Pads the number to a multiple of 4
  80738. * @param num number to pad
  80739. * @returns padded number
  80740. */
  80741. private _getPadding;
  80742. /**
  80743. * @hidden
  80744. */
  80745. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80746. /**
  80747. * Sets the TRS for each node
  80748. * @param node glTF Node for storing the transformation data
  80749. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  80750. * @param convertToRightHandedSystem Converts the values to right-handed
  80751. */
  80752. private setNodeTransformation;
  80753. private getVertexBufferFromMesh;
  80754. /**
  80755. * Creates a bufferview based on the vertices type for the Babylon mesh
  80756. * @param kind Indicates the type of vertices data
  80757. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  80758. * @param binaryWriter The buffer to write the bufferview data to
  80759. * @param convertToRightHandedSystem Converts the values to right-handed
  80760. */
  80761. private createBufferViewKind;
  80762. /**
  80763. * The primitive mode of the Babylon mesh
  80764. * @param babylonMesh The BabylonJS mesh
  80765. */
  80766. private getMeshPrimitiveMode;
  80767. /**
  80768. * Sets the primitive mode of the glTF mesh primitive
  80769. * @param meshPrimitive glTF mesh primitive
  80770. * @param primitiveMode The primitive mode
  80771. */
  80772. private setPrimitiveMode;
  80773. /**
  80774. * Sets the vertex attribute accessor based of the glTF mesh primitive
  80775. * @param meshPrimitive glTF mesh primitive
  80776. * @param attributeKind vertex attribute
  80777. * @returns boolean specifying if uv coordinates are present
  80778. */
  80779. private setAttributeKind;
  80780. /**
  80781. * Sets data for the primitive attributes of each submesh
  80782. * @param mesh glTF Mesh object to store the primitive attribute information
  80783. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  80784. * @param binaryWriter Buffer to write the attribute data to
  80785. * @param convertToRightHandedSystem Converts the values to right-handed
  80786. */
  80787. private setPrimitiveAttributesAsync;
  80788. /**
  80789. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  80790. * @param node The node to check
  80791. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  80792. */
  80793. private isBabylonCoordinateSystemConvertingNode;
  80794. /**
  80795. * Creates a glTF scene based on the array of meshes
  80796. * Returns the the total byte offset
  80797. * @param babylonScene Babylon scene to get the mesh data from
  80798. * @param binaryWriter Buffer to write binary data to
  80799. */
  80800. private createSceneAsync;
  80801. /**
  80802. * Creates a mapping of Node unique id to node index and handles animations
  80803. * @param babylonScene Babylon Scene
  80804. * @param nodes Babylon transform nodes
  80805. * @param binaryWriter Buffer to write binary data to
  80806. * @returns Node mapping of unique id to index
  80807. */
  80808. private createNodeMapAndAnimationsAsync;
  80809. /**
  80810. * Creates a glTF node from a Babylon mesh
  80811. * @param babylonMesh Source Babylon mesh
  80812. * @param binaryWriter Buffer for storing geometry data
  80813. * @param convertToRightHandedSystem Converts the values to right-handed
  80814. * @param nodeMap Node mapping of unique id to glTF node index
  80815. * @returns glTF node
  80816. */
  80817. private createNodeAsync;
  80818. }
  80819. /**
  80820. * @hidden
  80821. *
  80822. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  80823. */
  80824. export class _BinaryWriter {
  80825. /**
  80826. * Array buffer which stores all binary data
  80827. */
  80828. private _arrayBuffer;
  80829. /**
  80830. * View of the array buffer
  80831. */
  80832. private _dataView;
  80833. /**
  80834. * byte offset of data in array buffer
  80835. */
  80836. private _byteOffset;
  80837. /**
  80838. * Initialize binary writer with an initial byte length
  80839. * @param byteLength Initial byte length of the array buffer
  80840. */
  80841. constructor(byteLength: number);
  80842. /**
  80843. * Resize the array buffer to the specified byte length
  80844. * @param byteLength
  80845. */
  80846. private resizeBuffer;
  80847. /**
  80848. * Get an array buffer with the length of the byte offset
  80849. * @returns ArrayBuffer resized to the byte offset
  80850. */
  80851. getArrayBuffer(): ArrayBuffer;
  80852. /**
  80853. * Get the byte offset of the array buffer
  80854. * @returns byte offset
  80855. */
  80856. getByteOffset(): number;
  80857. /**
  80858. * Stores an UInt8 in the array buffer
  80859. * @param entry
  80860. * @param byteOffset If defined, specifies where to set the value as an offset.
  80861. */
  80862. setUInt8(entry: number, byteOffset?: number): void;
  80863. /**
  80864. * Gets an UInt32 in the array buffer
  80865. * @param entry
  80866. * @param byteOffset If defined, specifies where to set the value as an offset.
  80867. */
  80868. getUInt32(byteOffset: number): number;
  80869. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  80870. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  80871. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  80872. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  80873. /**
  80874. * Stores a Float32 in the array buffer
  80875. * @param entry
  80876. */
  80877. setFloat32(entry: number, byteOffset?: number): void;
  80878. /**
  80879. * Stores an UInt32 in the array buffer
  80880. * @param entry
  80881. * @param byteOffset If defined, specifies where to set the value as an offset.
  80882. */
  80883. setUInt32(entry: number, byteOffset?: number): void;
  80884. }
  80885. }
  80886. declare module BABYLON.GLTF2.Exporter {
  80887. /**
  80888. * @hidden
  80889. * Interface to store animation data.
  80890. */
  80891. export interface _IAnimationData {
  80892. /**
  80893. * Keyframe data.
  80894. */
  80895. inputs: number[];
  80896. /**
  80897. * Value data.
  80898. */
  80899. outputs: number[][];
  80900. /**
  80901. * Animation interpolation data.
  80902. */
  80903. samplerInterpolation: AnimationSamplerInterpolation;
  80904. /**
  80905. * Minimum keyframe value.
  80906. */
  80907. inputsMin: number;
  80908. /**
  80909. * Maximum keyframe value.
  80910. */
  80911. inputsMax: number;
  80912. }
  80913. /**
  80914. * @hidden
  80915. */
  80916. export interface _IAnimationInfo {
  80917. /**
  80918. * The target channel for the animation
  80919. */
  80920. animationChannelTargetPath: AnimationChannelTargetPath;
  80921. /**
  80922. * The glTF accessor type for the data.
  80923. */
  80924. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  80925. /**
  80926. * Specifies if quaternions should be used.
  80927. */
  80928. useQuaternion: boolean;
  80929. }
  80930. /**
  80931. * @hidden
  80932. * Utility class for generating glTF animation data from BabylonJS.
  80933. */
  80934. export class _GLTFAnimation {
  80935. /**
  80936. * @ignore
  80937. *
  80938. * Creates glTF channel animation from BabylonJS animation.
  80939. * @param babylonTransformNode - BabylonJS mesh.
  80940. * @param animation - animation.
  80941. * @param animationChannelTargetPath - The target animation channel.
  80942. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  80943. * @param useQuaternion - Specifies if quaternions are used.
  80944. * @returns nullable IAnimationData
  80945. */
  80946. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  80947. private static _DeduceAnimationInfo;
  80948. /**
  80949. * @ignore
  80950. * Create node animations from the transform node animations
  80951. * @param babylonNode
  80952. * @param runtimeGLTFAnimation
  80953. * @param idleGLTFAnimations
  80954. * @param nodeMap
  80955. * @param nodes
  80956. * @param binaryWriter
  80957. * @param bufferViews
  80958. * @param accessors
  80959. * @param convertToRightHandedSystem
  80960. * @param animationSampleRate
  80961. */
  80962. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  80963. [key: number]: number;
  80964. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  80965. /**
  80966. * @ignore
  80967. * Create node animations from the animation groups
  80968. * @param babylonScene
  80969. * @param glTFAnimations
  80970. * @param nodeMap
  80971. * @param nodes
  80972. * @param binaryWriter
  80973. * @param bufferViews
  80974. * @param accessors
  80975. * @param convertToRightHandedSystemMap
  80976. * @param animationSampleRate
  80977. */
  80978. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  80979. [key: number]: number;
  80980. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  80981. [nodeId: number]: boolean;
  80982. }, animationSampleRate: number): void;
  80983. private static AddAnimation;
  80984. /**
  80985. * Create a baked animation
  80986. * @param babylonTransformNode BabylonJS mesh
  80987. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  80988. * @param animationChannelTargetPath animation target channel
  80989. * @param minFrame minimum animation frame
  80990. * @param maxFrame maximum animation frame
  80991. * @param fps frames per second of the animation
  80992. * @param inputs input key frames of the animation
  80993. * @param outputs output key frame data of the animation
  80994. * @param convertToRightHandedSystem converts the values to right-handed
  80995. * @param useQuaternion specifies if quaternions should be used
  80996. */
  80997. private static _CreateBakedAnimation;
  80998. private static _ConvertFactorToVector3OrQuaternion;
  80999. private static _SetInterpolatedValue;
  81000. /**
  81001. * Creates linear animation from the animation key frames
  81002. * @param babylonTransformNode BabylonJS mesh
  81003. * @param animation BabylonJS animation
  81004. * @param animationChannelTargetPath The target animation channel
  81005. * @param frameDelta The difference between the last and first frame of the animation
  81006. * @param inputs Array to store the key frame times
  81007. * @param outputs Array to store the key frame data
  81008. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81009. * @param useQuaternion Specifies if quaternions are used in the animation
  81010. */
  81011. private static _CreateLinearOrStepAnimation;
  81012. /**
  81013. * Creates cubic spline animation from the animation key frames
  81014. * @param babylonTransformNode BabylonJS mesh
  81015. * @param animation BabylonJS animation
  81016. * @param animationChannelTargetPath The target animation channel
  81017. * @param frameDelta The difference between the last and first frame of the animation
  81018. * @param inputs Array to store the key frame times
  81019. * @param outputs Array to store the key frame data
  81020. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81021. * @param useQuaternion Specifies if quaternions are used in the animation
  81022. */
  81023. private static _CreateCubicSplineAnimation;
  81024. private static _GetBasePositionRotationOrScale;
  81025. /**
  81026. * Adds a key frame value
  81027. * @param keyFrame
  81028. * @param animation
  81029. * @param outputs
  81030. * @param animationChannelTargetPath
  81031. * @param basePositionRotationOrScale
  81032. * @param convertToRightHandedSystem
  81033. * @param useQuaternion
  81034. */
  81035. private static _AddKeyframeValue;
  81036. /**
  81037. * Determine the interpolation based on the key frames
  81038. * @param keyFrames
  81039. * @param animationChannelTargetPath
  81040. * @param useQuaternion
  81041. */
  81042. private static _DeduceInterpolation;
  81043. /**
  81044. * Adds an input tangent or output tangent to the output data
  81045. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81046. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81047. * @param outputs The animation data by keyframe
  81048. * @param animationChannelTargetPath The target animation channel
  81049. * @param interpolation The interpolation type
  81050. * @param keyFrame The key frame with the animation data
  81051. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81052. * @param useQuaternion Specifies if quaternions are used
  81053. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81054. */
  81055. private static AddSplineTangent;
  81056. /**
  81057. * Get the minimum and maximum key frames' frame values
  81058. * @param keyFrames animation key frames
  81059. * @returns the minimum and maximum key frame value
  81060. */
  81061. private static calculateMinMaxKeyFrames;
  81062. }
  81063. }
  81064. declare module BABYLON.GLTF2.Exporter {
  81065. /** @hidden */
  81066. export var textureTransformPixelShader: {
  81067. name: string;
  81068. shader: string;
  81069. };
  81070. }
  81071. declare module BABYLON.GLTF2.Exporter.Extensions {
  81072. /**
  81073. * @hidden
  81074. */
  81075. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81076. private _recordedTextures;
  81077. /** Name of this extension */
  81078. readonly name: string;
  81079. /** Defines whether this extension is enabled */
  81080. enabled: boolean;
  81081. /** Defines whether this extension is required */
  81082. required: boolean;
  81083. /** Reference to the glTF exporter */
  81084. private _wasUsed;
  81085. constructor(exporter: _Exporter);
  81086. dispose(): void;
  81087. /** @hidden */
  81088. get wasUsed(): boolean;
  81089. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81090. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81091. /**
  81092. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81093. * @param babylonTexture
  81094. * @param offset
  81095. * @param rotation
  81096. * @param scale
  81097. * @param scene
  81098. */
  81099. private _textureTransformTextureAsync;
  81100. }
  81101. }
  81102. declare module BABYLON.GLTF2.Exporter.Extensions {
  81103. /**
  81104. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81105. */
  81106. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81107. /** The name of this extension. */
  81108. readonly name: string;
  81109. /** Defines whether this extension is enabled. */
  81110. enabled: boolean;
  81111. /** Defines whether this extension is required */
  81112. required: boolean;
  81113. /** Reference to the glTF exporter */
  81114. private _exporter;
  81115. private _lights;
  81116. /** @hidden */
  81117. constructor(exporter: _Exporter);
  81118. /** @hidden */
  81119. dispose(): void;
  81120. /** @hidden */
  81121. get wasUsed(): boolean;
  81122. /** @hidden */
  81123. onExporting(): void;
  81124. /**
  81125. * Define this method to modify the default behavior when exporting a node
  81126. * @param context The context when exporting the node
  81127. * @param node glTF node
  81128. * @param babylonNode BabylonJS node
  81129. * @param nodeMap Node mapping of unique id to glTF node index
  81130. * @returns nullable INode promise
  81131. */
  81132. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81133. [key: number]: number;
  81134. }): Promise<Nullable<INode>>;
  81135. }
  81136. }
  81137. declare module BABYLON.GLTF2.Exporter.Extensions {
  81138. /**
  81139. * @hidden
  81140. */
  81141. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81142. /** Name of this extension */
  81143. readonly name: string;
  81144. /** Defines whether this extension is enabled */
  81145. enabled: boolean;
  81146. /** Defines whether this extension is required */
  81147. required: boolean;
  81148. /** Reference to the glTF exporter */
  81149. private _textureInfos;
  81150. private _exportedTextures;
  81151. private _wasUsed;
  81152. constructor(exporter: _Exporter);
  81153. dispose(): void;
  81154. /** @hidden */
  81155. get wasUsed(): boolean;
  81156. private _getTextureIndex;
  81157. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81158. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81159. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81160. }
  81161. }
  81162. declare module BABYLON {
  81163. /**
  81164. * Class for generating STL data from a Babylon scene.
  81165. */
  81166. export class STLExport {
  81167. /**
  81168. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81169. * @param meshes list defines the mesh to serialize
  81170. * @param download triggers the automatic download of the file.
  81171. * @param fileName changes the downloads fileName.
  81172. * @param binary changes the STL to a binary type.
  81173. * @param isLittleEndian toggle for binary type exporter.
  81174. * @returns the STL as UTF8 string
  81175. */
  81176. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81177. }
  81178. }
  81179. declare module "babylonjs-gltf2interface" {
  81180. export = BABYLON.GLTF2;
  81181. }
  81182. /**
  81183. * Module for glTF 2.0 Interface
  81184. */
  81185. declare module BABYLON.GLTF2 {
  81186. /**
  81187. * The datatype of the components in the attribute
  81188. */
  81189. const enum AccessorComponentType {
  81190. /**
  81191. * Byte
  81192. */
  81193. BYTE = 5120,
  81194. /**
  81195. * Unsigned Byte
  81196. */
  81197. UNSIGNED_BYTE = 5121,
  81198. /**
  81199. * Short
  81200. */
  81201. SHORT = 5122,
  81202. /**
  81203. * Unsigned Short
  81204. */
  81205. UNSIGNED_SHORT = 5123,
  81206. /**
  81207. * Unsigned Int
  81208. */
  81209. UNSIGNED_INT = 5125,
  81210. /**
  81211. * Float
  81212. */
  81213. FLOAT = 5126,
  81214. }
  81215. /**
  81216. * Specifies if the attirbute is a scalar, vector, or matrix
  81217. */
  81218. const enum AccessorType {
  81219. /**
  81220. * Scalar
  81221. */
  81222. SCALAR = "SCALAR",
  81223. /**
  81224. * Vector2
  81225. */
  81226. VEC2 = "VEC2",
  81227. /**
  81228. * Vector3
  81229. */
  81230. VEC3 = "VEC3",
  81231. /**
  81232. * Vector4
  81233. */
  81234. VEC4 = "VEC4",
  81235. /**
  81236. * Matrix2x2
  81237. */
  81238. MAT2 = "MAT2",
  81239. /**
  81240. * Matrix3x3
  81241. */
  81242. MAT3 = "MAT3",
  81243. /**
  81244. * Matrix4x4
  81245. */
  81246. MAT4 = "MAT4",
  81247. }
  81248. /**
  81249. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81250. */
  81251. const enum AnimationChannelTargetPath {
  81252. /**
  81253. * Translation
  81254. */
  81255. TRANSLATION = "translation",
  81256. /**
  81257. * Rotation
  81258. */
  81259. ROTATION = "rotation",
  81260. /**
  81261. * Scale
  81262. */
  81263. SCALE = "scale",
  81264. /**
  81265. * Weights
  81266. */
  81267. WEIGHTS = "weights",
  81268. }
  81269. /**
  81270. * Interpolation algorithm
  81271. */
  81272. const enum AnimationSamplerInterpolation {
  81273. /**
  81274. * The animated values are linearly interpolated between keyframes
  81275. */
  81276. LINEAR = "LINEAR",
  81277. /**
  81278. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  81279. */
  81280. STEP = "STEP",
  81281. /**
  81282. * The animation's interpolation is computed using a cubic spline with specified tangents
  81283. */
  81284. CUBICSPLINE = "CUBICSPLINE",
  81285. }
  81286. /**
  81287. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81288. */
  81289. const enum CameraType {
  81290. /**
  81291. * A perspective camera containing properties to create a perspective projection matrix
  81292. */
  81293. PERSPECTIVE = "perspective",
  81294. /**
  81295. * An orthographic camera containing properties to create an orthographic projection matrix
  81296. */
  81297. ORTHOGRAPHIC = "orthographic",
  81298. }
  81299. /**
  81300. * The mime-type of the image
  81301. */
  81302. const enum ImageMimeType {
  81303. /**
  81304. * JPEG Mime-type
  81305. */
  81306. JPEG = "image/jpeg",
  81307. /**
  81308. * PNG Mime-type
  81309. */
  81310. PNG = "image/png",
  81311. }
  81312. /**
  81313. * The alpha rendering mode of the material
  81314. */
  81315. const enum MaterialAlphaMode {
  81316. /**
  81317. * The alpha value is ignored and the rendered output is fully opaque
  81318. */
  81319. OPAQUE = "OPAQUE",
  81320. /**
  81321. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  81322. */
  81323. MASK = "MASK",
  81324. /**
  81325. * 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)
  81326. */
  81327. BLEND = "BLEND",
  81328. }
  81329. /**
  81330. * The type of the primitives to render
  81331. */
  81332. const enum MeshPrimitiveMode {
  81333. /**
  81334. * Points
  81335. */
  81336. POINTS = 0,
  81337. /**
  81338. * Lines
  81339. */
  81340. LINES = 1,
  81341. /**
  81342. * Line Loop
  81343. */
  81344. LINE_LOOP = 2,
  81345. /**
  81346. * Line Strip
  81347. */
  81348. LINE_STRIP = 3,
  81349. /**
  81350. * Triangles
  81351. */
  81352. TRIANGLES = 4,
  81353. /**
  81354. * Triangle Strip
  81355. */
  81356. TRIANGLE_STRIP = 5,
  81357. /**
  81358. * Triangle Fan
  81359. */
  81360. TRIANGLE_FAN = 6,
  81361. }
  81362. /**
  81363. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81364. */
  81365. const enum TextureMagFilter {
  81366. /**
  81367. * Nearest
  81368. */
  81369. NEAREST = 9728,
  81370. /**
  81371. * Linear
  81372. */
  81373. LINEAR = 9729,
  81374. }
  81375. /**
  81376. * Minification filter. All valid values correspond to WebGL enums
  81377. */
  81378. const enum TextureMinFilter {
  81379. /**
  81380. * Nearest
  81381. */
  81382. NEAREST = 9728,
  81383. /**
  81384. * Linear
  81385. */
  81386. LINEAR = 9729,
  81387. /**
  81388. * Nearest Mip-Map Nearest
  81389. */
  81390. NEAREST_MIPMAP_NEAREST = 9984,
  81391. /**
  81392. * Linear Mipmap Nearest
  81393. */
  81394. LINEAR_MIPMAP_NEAREST = 9985,
  81395. /**
  81396. * Nearest Mipmap Linear
  81397. */
  81398. NEAREST_MIPMAP_LINEAR = 9986,
  81399. /**
  81400. * Linear Mipmap Linear
  81401. */
  81402. LINEAR_MIPMAP_LINEAR = 9987,
  81403. }
  81404. /**
  81405. * S (U) wrapping mode. All valid values correspond to WebGL enums
  81406. */
  81407. const enum TextureWrapMode {
  81408. /**
  81409. * Clamp to Edge
  81410. */
  81411. CLAMP_TO_EDGE = 33071,
  81412. /**
  81413. * Mirrored Repeat
  81414. */
  81415. MIRRORED_REPEAT = 33648,
  81416. /**
  81417. * Repeat
  81418. */
  81419. REPEAT = 10497,
  81420. }
  81421. /**
  81422. * glTF Property
  81423. */
  81424. interface IProperty {
  81425. /**
  81426. * Dictionary object with extension-specific objects
  81427. */
  81428. extensions?: {
  81429. [key: string]: any;
  81430. };
  81431. /**
  81432. * Application-Specific data
  81433. */
  81434. extras?: any;
  81435. }
  81436. /**
  81437. * glTF Child of Root Property
  81438. */
  81439. interface IChildRootProperty extends IProperty {
  81440. /**
  81441. * The user-defined name of this object
  81442. */
  81443. name?: string;
  81444. }
  81445. /**
  81446. * Indices of those attributes that deviate from their initialization value
  81447. */
  81448. interface IAccessorSparseIndices extends IProperty {
  81449. /**
  81450. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81451. */
  81452. bufferView: number;
  81453. /**
  81454. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81455. */
  81456. byteOffset?: number;
  81457. /**
  81458. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  81459. */
  81460. componentType: AccessorComponentType;
  81461. }
  81462. /**
  81463. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  81464. */
  81465. interface IAccessorSparseValues extends IProperty {
  81466. /**
  81467. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81468. */
  81469. bufferView: number;
  81470. /**
  81471. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81472. */
  81473. byteOffset?: number;
  81474. }
  81475. /**
  81476. * Sparse storage of attributes that deviate from their initialization value
  81477. */
  81478. interface IAccessorSparse extends IProperty {
  81479. /**
  81480. * The number of attributes encoded in this sparse accessor
  81481. */
  81482. count: number;
  81483. /**
  81484. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  81485. */
  81486. indices: IAccessorSparseIndices;
  81487. /**
  81488. * 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
  81489. */
  81490. values: IAccessorSparseValues;
  81491. }
  81492. /**
  81493. * 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
  81494. */
  81495. interface IAccessor extends IChildRootProperty {
  81496. /**
  81497. * The index of the bufferview
  81498. */
  81499. bufferView?: number;
  81500. /**
  81501. * The offset relative to the start of the bufferView in bytes
  81502. */
  81503. byteOffset?: number;
  81504. /**
  81505. * The datatype of components in the attribute
  81506. */
  81507. componentType: AccessorComponentType;
  81508. /**
  81509. * Specifies whether integer data values should be normalized
  81510. */
  81511. normalized?: boolean;
  81512. /**
  81513. * The number of attributes referenced by this accessor
  81514. */
  81515. count: number;
  81516. /**
  81517. * Specifies if the attribute is a scalar, vector, or matrix
  81518. */
  81519. type: AccessorType;
  81520. /**
  81521. * Maximum value of each component in this attribute
  81522. */
  81523. max?: number[];
  81524. /**
  81525. * Minimum value of each component in this attribute
  81526. */
  81527. min?: number[];
  81528. /**
  81529. * Sparse storage of attributes that deviate from their initialization value
  81530. */
  81531. sparse?: IAccessorSparse;
  81532. }
  81533. /**
  81534. * Targets an animation's sampler at a node's property
  81535. */
  81536. interface IAnimationChannel extends IProperty {
  81537. /**
  81538. * The index of a sampler in this animation used to compute the value for the target
  81539. */
  81540. sampler: number;
  81541. /**
  81542. * The index of the node and TRS property to target
  81543. */
  81544. target: IAnimationChannelTarget;
  81545. }
  81546. /**
  81547. * The index of the node and TRS property that an animation channel targets
  81548. */
  81549. interface IAnimationChannelTarget extends IProperty {
  81550. /**
  81551. * The index of the node to target
  81552. */
  81553. node: number;
  81554. /**
  81555. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81556. */
  81557. path: AnimationChannelTargetPath;
  81558. }
  81559. /**
  81560. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81561. */
  81562. interface IAnimationSampler extends IProperty {
  81563. /**
  81564. * The index of an accessor containing keyframe input values, e.g., time
  81565. */
  81566. input: number;
  81567. /**
  81568. * Interpolation algorithm
  81569. */
  81570. interpolation?: AnimationSamplerInterpolation;
  81571. /**
  81572. * The index of an accessor, containing keyframe output values
  81573. */
  81574. output: number;
  81575. }
  81576. /**
  81577. * A keyframe animation
  81578. */
  81579. interface IAnimation extends IChildRootProperty {
  81580. /**
  81581. * An array of channels, each of which targets an animation's sampler at a node's property
  81582. */
  81583. channels: IAnimationChannel[];
  81584. /**
  81585. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81586. */
  81587. samplers: IAnimationSampler[];
  81588. }
  81589. /**
  81590. * Metadata about the glTF asset
  81591. */
  81592. interface IAsset extends IChildRootProperty {
  81593. /**
  81594. * A copyright message suitable for display to credit the content creator
  81595. */
  81596. copyright?: string;
  81597. /**
  81598. * Tool that generated this glTF model. Useful for debugging
  81599. */
  81600. generator?: string;
  81601. /**
  81602. * The glTF version that this asset targets
  81603. */
  81604. version: string;
  81605. /**
  81606. * The minimum glTF version that this asset targets
  81607. */
  81608. minVersion?: string;
  81609. }
  81610. /**
  81611. * A buffer points to binary geometry, animation, or skins
  81612. */
  81613. interface IBuffer extends IChildRootProperty {
  81614. /**
  81615. * 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
  81616. */
  81617. uri?: string;
  81618. /**
  81619. * The length of the buffer in bytes
  81620. */
  81621. byteLength: number;
  81622. }
  81623. /**
  81624. * A view into a buffer generally representing a subset of the buffer
  81625. */
  81626. interface IBufferView extends IChildRootProperty {
  81627. /**
  81628. * The index of the buffer
  81629. */
  81630. buffer: number;
  81631. /**
  81632. * The offset into the buffer in bytes
  81633. */
  81634. byteOffset?: number;
  81635. /**
  81636. * The lenth of the bufferView in bytes
  81637. */
  81638. byteLength: number;
  81639. /**
  81640. * The stride, in bytes
  81641. */
  81642. byteStride?: number;
  81643. }
  81644. /**
  81645. * An orthographic camera containing properties to create an orthographic projection matrix
  81646. */
  81647. interface ICameraOrthographic extends IProperty {
  81648. /**
  81649. * The floating-point horizontal magnification of the view. Must not be zero
  81650. */
  81651. xmag: number;
  81652. /**
  81653. * The floating-point vertical magnification of the view. Must not be zero
  81654. */
  81655. ymag: number;
  81656. /**
  81657. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  81658. */
  81659. zfar: number;
  81660. /**
  81661. * The floating-point distance to the near clipping plane
  81662. */
  81663. znear: number;
  81664. }
  81665. /**
  81666. * A perspective camera containing properties to create a perspective projection matrix
  81667. */
  81668. interface ICameraPerspective extends IProperty {
  81669. /**
  81670. * The floating-point aspect ratio of the field of view
  81671. */
  81672. aspectRatio?: number;
  81673. /**
  81674. * The floating-point vertical field of view in radians
  81675. */
  81676. yfov: number;
  81677. /**
  81678. * The floating-point distance to the far clipping plane
  81679. */
  81680. zfar?: number;
  81681. /**
  81682. * The floating-point distance to the near clipping plane
  81683. */
  81684. znear: number;
  81685. }
  81686. /**
  81687. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81688. */
  81689. interface ICamera extends IChildRootProperty {
  81690. /**
  81691. * An orthographic camera containing properties to create an orthographic projection matrix
  81692. */
  81693. orthographic?: ICameraOrthographic;
  81694. /**
  81695. * A perspective camera containing properties to create a perspective projection matrix
  81696. */
  81697. perspective?: ICameraPerspective;
  81698. /**
  81699. * Specifies if the camera uses a perspective or orthographic projection
  81700. */
  81701. type: CameraType;
  81702. }
  81703. /**
  81704. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  81705. */
  81706. interface IImage extends IChildRootProperty {
  81707. /**
  81708. * 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
  81709. */
  81710. uri?: string;
  81711. /**
  81712. * The image's MIME type
  81713. */
  81714. mimeType?: ImageMimeType;
  81715. /**
  81716. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  81717. */
  81718. bufferView?: number;
  81719. }
  81720. /**
  81721. * Material Normal Texture Info
  81722. */
  81723. interface IMaterialNormalTextureInfo extends ITextureInfo {
  81724. /**
  81725. * The scalar multiplier applied to each normal vector of the normal texture
  81726. */
  81727. scale?: number;
  81728. }
  81729. /**
  81730. * Material Occlusion Texture Info
  81731. */
  81732. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  81733. /**
  81734. * A scalar multiplier controlling the amount of occlusion applied
  81735. */
  81736. strength?: number;
  81737. }
  81738. /**
  81739. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  81740. */
  81741. interface IMaterialPbrMetallicRoughness {
  81742. /**
  81743. * The material's base color factor
  81744. */
  81745. baseColorFactor?: number[];
  81746. /**
  81747. * The base color texture
  81748. */
  81749. baseColorTexture?: ITextureInfo;
  81750. /**
  81751. * The metalness of the material
  81752. */
  81753. metallicFactor?: number;
  81754. /**
  81755. * The roughness of the material
  81756. */
  81757. roughnessFactor?: number;
  81758. /**
  81759. * The metallic-roughness texture
  81760. */
  81761. metallicRoughnessTexture?: ITextureInfo;
  81762. }
  81763. /**
  81764. * The material appearance of a primitive
  81765. */
  81766. interface IMaterial extends IChildRootProperty {
  81767. /**
  81768. * 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
  81769. */
  81770. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81771. /**
  81772. * The normal map texture
  81773. */
  81774. normalTexture?: IMaterialNormalTextureInfo;
  81775. /**
  81776. * The occlusion map texture
  81777. */
  81778. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81779. /**
  81780. * The emissive map texture
  81781. */
  81782. emissiveTexture?: ITextureInfo;
  81783. /**
  81784. * 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
  81785. */
  81786. emissiveFactor?: number[];
  81787. /**
  81788. * The alpha rendering mode of the material
  81789. */
  81790. alphaMode?: MaterialAlphaMode;
  81791. /**
  81792. * The alpha cutoff value of the material
  81793. */
  81794. alphaCutoff?: number;
  81795. /**
  81796. * Specifies whether the material is double sided
  81797. */
  81798. doubleSided?: boolean;
  81799. }
  81800. /**
  81801. * Geometry to be rendered with the given material
  81802. */
  81803. interface IMeshPrimitive extends IProperty {
  81804. /**
  81805. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  81806. */
  81807. attributes: {
  81808. [name: string]: number;
  81809. };
  81810. /**
  81811. * The index of the accessor that contains the indices
  81812. */
  81813. indices?: number;
  81814. /**
  81815. * The index of the material to apply to this primitive when rendering
  81816. */
  81817. material?: number;
  81818. /**
  81819. * The type of primitives to render. All valid values correspond to WebGL enums
  81820. */
  81821. mode?: MeshPrimitiveMode;
  81822. /**
  81823. * 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
  81824. */
  81825. targets?: {
  81826. [name: string]: number;
  81827. }[];
  81828. }
  81829. /**
  81830. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  81831. */
  81832. interface IMesh extends IChildRootProperty {
  81833. /**
  81834. * An array of primitives, each defining geometry to be rendered with a material
  81835. */
  81836. primitives: IMeshPrimitive[];
  81837. /**
  81838. * Array of weights to be applied to the Morph Targets
  81839. */
  81840. weights?: number[];
  81841. }
  81842. /**
  81843. * A node in the node hierarchy
  81844. */
  81845. interface INode extends IChildRootProperty {
  81846. /**
  81847. * The index of the camera referenced by this node
  81848. */
  81849. camera?: number;
  81850. /**
  81851. * The indices of this node's children
  81852. */
  81853. children?: number[];
  81854. /**
  81855. * The index of the skin referenced by this node
  81856. */
  81857. skin?: number;
  81858. /**
  81859. * A floating-point 4x4 transformation matrix stored in column-major order
  81860. */
  81861. matrix?: number[];
  81862. /**
  81863. * The index of the mesh in this node
  81864. */
  81865. mesh?: number;
  81866. /**
  81867. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  81868. */
  81869. rotation?: number[];
  81870. /**
  81871. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  81872. */
  81873. scale?: number[];
  81874. /**
  81875. * The node's translation along the x, y, and z axes
  81876. */
  81877. translation?: number[];
  81878. /**
  81879. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  81880. */
  81881. weights?: number[];
  81882. }
  81883. /**
  81884. * Texture sampler properties for filtering and wrapping modes
  81885. */
  81886. interface ISampler extends IChildRootProperty {
  81887. /**
  81888. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81889. */
  81890. magFilter?: TextureMagFilter;
  81891. /**
  81892. * Minification filter. All valid values correspond to WebGL enums
  81893. */
  81894. minFilter?: TextureMinFilter;
  81895. /**
  81896. * S (U) wrapping mode. All valid values correspond to WebGL enums
  81897. */
  81898. wrapS?: TextureWrapMode;
  81899. /**
  81900. * T (V) wrapping mode. All valid values correspond to WebGL enums
  81901. */
  81902. wrapT?: TextureWrapMode;
  81903. }
  81904. /**
  81905. * The root nodes of a scene
  81906. */
  81907. interface IScene extends IChildRootProperty {
  81908. /**
  81909. * The indices of each root node
  81910. */
  81911. nodes: number[];
  81912. }
  81913. /**
  81914. * Joints and matrices defining a skin
  81915. */
  81916. interface ISkin extends IChildRootProperty {
  81917. /**
  81918. * 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
  81919. */
  81920. inverseBindMatrices?: number;
  81921. /**
  81922. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  81923. */
  81924. skeleton?: number;
  81925. /**
  81926. * 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)
  81927. */
  81928. joints: number[];
  81929. }
  81930. /**
  81931. * A texture and its sampler
  81932. */
  81933. interface ITexture extends IChildRootProperty {
  81934. /**
  81935. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  81936. */
  81937. sampler?: number;
  81938. /**
  81939. * The index of the image used by this texture
  81940. */
  81941. source: number;
  81942. }
  81943. /**
  81944. * Reference to a texture
  81945. */
  81946. interface ITextureInfo extends IProperty {
  81947. /**
  81948. * The index of the texture
  81949. */
  81950. index: number;
  81951. /**
  81952. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  81953. */
  81954. texCoord?: number;
  81955. }
  81956. /**
  81957. * The root object for a glTF asset
  81958. */
  81959. interface IGLTF extends IProperty {
  81960. /**
  81961. * An array of accessors. An accessor is a typed view into a bufferView
  81962. */
  81963. accessors?: IAccessor[];
  81964. /**
  81965. * An array of keyframe animations
  81966. */
  81967. animations?: IAnimation[];
  81968. /**
  81969. * Metadata about the glTF asset
  81970. */
  81971. asset: IAsset;
  81972. /**
  81973. * An array of buffers. A buffer points to binary geometry, animation, or skins
  81974. */
  81975. buffers?: IBuffer[];
  81976. /**
  81977. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  81978. */
  81979. bufferViews?: IBufferView[];
  81980. /**
  81981. * An array of cameras
  81982. */
  81983. cameras?: ICamera[];
  81984. /**
  81985. * Names of glTF extensions used somewhere in this asset
  81986. */
  81987. extensionsUsed?: string[];
  81988. /**
  81989. * Names of glTF extensions required to properly load this asset
  81990. */
  81991. extensionsRequired?: string[];
  81992. /**
  81993. * An array of images. An image defines data used to create a texture
  81994. */
  81995. images?: IImage[];
  81996. /**
  81997. * An array of materials. A material defines the appearance of a primitive
  81998. */
  81999. materials?: IMaterial[];
  82000. /**
  82001. * An array of meshes. A mesh is a set of primitives to be rendered
  82002. */
  82003. meshes?: IMesh[];
  82004. /**
  82005. * An array of nodes
  82006. */
  82007. nodes?: INode[];
  82008. /**
  82009. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82010. */
  82011. samplers?: ISampler[];
  82012. /**
  82013. * The index of the default scene
  82014. */
  82015. scene?: number;
  82016. /**
  82017. * An array of scenes
  82018. */
  82019. scenes?: IScene[];
  82020. /**
  82021. * An array of skins. A skin is defined by joints and matrices
  82022. */
  82023. skins?: ISkin[];
  82024. /**
  82025. * An array of textures
  82026. */
  82027. textures?: ITexture[];
  82028. }
  82029. /**
  82030. * The glTF validation results
  82031. * @ignore
  82032. */
  82033. interface IGLTFValidationResults {
  82034. info: {
  82035. generator: string;
  82036. hasAnimations: boolean;
  82037. hasDefaultScene: boolean;
  82038. hasMaterials: boolean;
  82039. hasMorphTargets: boolean;
  82040. hasSkins: boolean;
  82041. hasTextures: boolean;
  82042. maxAttributesUsed: number;
  82043. primitivesCount: number
  82044. };
  82045. issues: {
  82046. messages: Array<string>;
  82047. numErrors: number;
  82048. numHints: number;
  82049. numInfos: number;
  82050. numWarnings: number;
  82051. truncated: boolean
  82052. };
  82053. mimeType: string;
  82054. uri: string;
  82055. validatedAt: string;
  82056. validatorVersion: string;
  82057. }
  82058. /**
  82059. * The glTF validation options
  82060. */
  82061. interface IGLTFValidationOptions {
  82062. /** Uri to use */
  82063. uri?: string;
  82064. /** Function used to load external resources */
  82065. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82066. /** Boolean indicating that we need to validate accessor data */
  82067. validateAccessorData?: boolean;
  82068. /** max number of issues allowed */
  82069. maxIssues?: number;
  82070. /** Ignored issues */
  82071. ignoredIssues?: Array<string>;
  82072. /** Value to override severy settings */
  82073. severityOverrides?: Object;
  82074. }
  82075. /**
  82076. * The glTF validator object
  82077. * @ignore
  82078. */
  82079. interface IGLTFValidator {
  82080. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82081. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82082. }
  82083. }
  82084. declare module BABYLON {
  82085. /** @hidden */
  82086. export var cellPixelShader: {
  82087. name: string;
  82088. shader: string;
  82089. };
  82090. }
  82091. declare module BABYLON {
  82092. /** @hidden */
  82093. export var cellVertexShader: {
  82094. name: string;
  82095. shader: string;
  82096. };
  82097. }
  82098. declare module BABYLON {
  82099. export class CellMaterial extends BABYLON.PushMaterial {
  82100. private _diffuseTexture;
  82101. diffuseTexture: BABYLON.BaseTexture;
  82102. diffuseColor: BABYLON.Color3;
  82103. _computeHighLevel: boolean;
  82104. computeHighLevel: boolean;
  82105. private _disableLighting;
  82106. disableLighting: boolean;
  82107. private _maxSimultaneousLights;
  82108. maxSimultaneousLights: number;
  82109. constructor(name: string, scene: BABYLON.Scene);
  82110. needAlphaBlending(): boolean;
  82111. needAlphaTesting(): boolean;
  82112. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82113. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82114. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82115. getAnimatables(): BABYLON.IAnimatable[];
  82116. getActiveTextures(): BABYLON.BaseTexture[];
  82117. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82118. dispose(forceDisposeEffect?: boolean): void;
  82119. getClassName(): string;
  82120. clone(name: string): CellMaterial;
  82121. serialize(): any;
  82122. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82123. }
  82124. }
  82125. declare module BABYLON {
  82126. export class CustomShaderStructure {
  82127. FragmentStore: string;
  82128. VertexStore: string;
  82129. constructor();
  82130. }
  82131. export class ShaderSpecialParts {
  82132. constructor();
  82133. Fragment_Begin: string;
  82134. Fragment_Definitions: string;
  82135. Fragment_MainBegin: string;
  82136. Fragment_Custom_Diffuse: string;
  82137. Fragment_Before_Lights: string;
  82138. Fragment_Before_Fog: string;
  82139. Fragment_Custom_Alpha: string;
  82140. Fragment_Before_FragColor: string;
  82141. Vertex_Begin: string;
  82142. Vertex_Definitions: string;
  82143. Vertex_MainBegin: string;
  82144. Vertex_Before_PositionUpdated: string;
  82145. Vertex_Before_NormalUpdated: string;
  82146. Vertex_After_WorldPosComputed: string;
  82147. Vertex_MainEnd: string;
  82148. }
  82149. export class CustomMaterial extends BABYLON.StandardMaterial {
  82150. static ShaderIndexer: number;
  82151. CustomParts: ShaderSpecialParts;
  82152. _isCreatedShader: boolean;
  82153. _createdShaderName: string;
  82154. _customUniform: string[];
  82155. _newUniforms: string[];
  82156. _newUniformInstances: {
  82157. [name: string]: any;
  82158. };
  82159. _newSamplerInstances: {
  82160. [name: string]: BABYLON.Texture;
  82161. };
  82162. _customAttributes: string[];
  82163. FragmentShader: string;
  82164. VertexShader: string;
  82165. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82166. ReviewUniform(name: string, arr: string[]): string[];
  82167. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82168. constructor(name: string, scene: BABYLON.Scene);
  82169. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82170. AddAttribute(name: string): CustomMaterial;
  82171. Fragment_Begin(shaderPart: string): CustomMaterial;
  82172. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82173. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82174. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82175. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82176. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82177. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82178. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82179. Vertex_Begin(shaderPart: string): CustomMaterial;
  82180. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82181. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82182. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82183. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82184. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82185. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82186. }
  82187. }
  82188. declare module BABYLON {
  82189. export class ShaderAlebdoParts {
  82190. constructor();
  82191. Fragment_Begin: string;
  82192. Fragment_Definitions: string;
  82193. Fragment_MainBegin: string;
  82194. Fragment_Custom_Albedo: string;
  82195. Fragment_Before_Lights: string;
  82196. Fragment_Custom_MetallicRoughness: string;
  82197. Fragment_Custom_MicroSurface: string;
  82198. Fragment_Before_Fog: string;
  82199. Fragment_Custom_Alpha: string;
  82200. Fragment_Before_FragColor: string;
  82201. Vertex_Begin: string;
  82202. Vertex_Definitions: string;
  82203. Vertex_MainBegin: string;
  82204. Vertex_Before_PositionUpdated: string;
  82205. Vertex_Before_NormalUpdated: string;
  82206. Vertex_After_WorldPosComputed: string;
  82207. Vertex_MainEnd: string;
  82208. }
  82209. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  82210. static ShaderIndexer: number;
  82211. CustomParts: ShaderAlebdoParts;
  82212. _isCreatedShader: boolean;
  82213. _createdShaderName: string;
  82214. _customUniform: string[];
  82215. _newUniforms: string[];
  82216. _newUniformInstances: {
  82217. [name: string]: any;
  82218. };
  82219. _newSamplerInstances: {
  82220. [name: string]: BABYLON.Texture;
  82221. };
  82222. _customAttributes: string[];
  82223. FragmentShader: string;
  82224. VertexShader: string;
  82225. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82226. ReviewUniform(name: string, arr: string[]): string[];
  82227. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82228. constructor(name: string, scene: BABYLON.Scene);
  82229. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  82230. AddAttribute(name: string): PBRCustomMaterial;
  82231. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  82232. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  82233. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  82234. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  82235. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  82236. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  82237. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  82238. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  82239. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  82240. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  82241. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  82242. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  82243. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  82244. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  82245. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  82246. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  82247. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  82248. }
  82249. }
  82250. declare module BABYLON {
  82251. /** @hidden */
  82252. export var firePixelShader: {
  82253. name: string;
  82254. shader: string;
  82255. };
  82256. }
  82257. declare module BABYLON {
  82258. /** @hidden */
  82259. export var fireVertexShader: {
  82260. name: string;
  82261. shader: string;
  82262. };
  82263. }
  82264. declare module BABYLON {
  82265. export class FireMaterial extends BABYLON.PushMaterial {
  82266. private _diffuseTexture;
  82267. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82268. private _distortionTexture;
  82269. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82270. private _opacityTexture;
  82271. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82272. diffuseColor: BABYLON.Color3;
  82273. speed: number;
  82274. private _scaledDiffuse;
  82275. private _lastTime;
  82276. constructor(name: string, scene: BABYLON.Scene);
  82277. needAlphaBlending(): boolean;
  82278. needAlphaTesting(): boolean;
  82279. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82280. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82281. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82282. getAnimatables(): BABYLON.IAnimatable[];
  82283. getActiveTextures(): BABYLON.BaseTexture[];
  82284. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82285. getClassName(): string;
  82286. dispose(forceDisposeEffect?: boolean): void;
  82287. clone(name: string): FireMaterial;
  82288. serialize(): any;
  82289. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  82290. }
  82291. }
  82292. declare module BABYLON {
  82293. /** @hidden */
  82294. export var furPixelShader: {
  82295. name: string;
  82296. shader: string;
  82297. };
  82298. }
  82299. declare module BABYLON {
  82300. /** @hidden */
  82301. export var furVertexShader: {
  82302. name: string;
  82303. shader: string;
  82304. };
  82305. }
  82306. declare module BABYLON {
  82307. export class FurMaterial extends BABYLON.PushMaterial {
  82308. private _diffuseTexture;
  82309. diffuseTexture: BABYLON.BaseTexture;
  82310. private _heightTexture;
  82311. heightTexture: BABYLON.BaseTexture;
  82312. diffuseColor: BABYLON.Color3;
  82313. furLength: number;
  82314. furAngle: number;
  82315. furColor: BABYLON.Color3;
  82316. furOffset: number;
  82317. furSpacing: number;
  82318. furGravity: BABYLON.Vector3;
  82319. furSpeed: number;
  82320. furDensity: number;
  82321. furOcclusion: number;
  82322. furTexture: BABYLON.DynamicTexture;
  82323. private _disableLighting;
  82324. disableLighting: boolean;
  82325. private _maxSimultaneousLights;
  82326. maxSimultaneousLights: number;
  82327. highLevelFur: boolean;
  82328. _meshes: BABYLON.AbstractMesh[];
  82329. private _furTime;
  82330. constructor(name: string, scene: BABYLON.Scene);
  82331. get furTime(): number;
  82332. set furTime(furTime: number);
  82333. needAlphaBlending(): boolean;
  82334. needAlphaTesting(): boolean;
  82335. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82336. updateFur(): void;
  82337. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82338. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82339. getAnimatables(): BABYLON.IAnimatable[];
  82340. getActiveTextures(): BABYLON.BaseTexture[];
  82341. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82342. dispose(forceDisposeEffect?: boolean): void;
  82343. clone(name: string): FurMaterial;
  82344. serialize(): any;
  82345. getClassName(): string;
  82346. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  82347. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  82348. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  82349. }
  82350. }
  82351. declare module BABYLON {
  82352. /** @hidden */
  82353. export var gradientPixelShader: {
  82354. name: string;
  82355. shader: string;
  82356. };
  82357. }
  82358. declare module BABYLON {
  82359. /** @hidden */
  82360. export var gradientVertexShader: {
  82361. name: string;
  82362. shader: string;
  82363. };
  82364. }
  82365. declare module BABYLON {
  82366. export class GradientMaterial extends BABYLON.PushMaterial {
  82367. private _maxSimultaneousLights;
  82368. maxSimultaneousLights: number;
  82369. topColor: BABYLON.Color3;
  82370. topColorAlpha: number;
  82371. bottomColor: BABYLON.Color3;
  82372. bottomColorAlpha: number;
  82373. offset: number;
  82374. scale: number;
  82375. smoothness: number;
  82376. private _disableLighting;
  82377. disableLighting: boolean;
  82378. constructor(name: string, scene: BABYLON.Scene);
  82379. needAlphaBlending(): boolean;
  82380. needAlphaTesting(): boolean;
  82381. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82382. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82383. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82384. getAnimatables(): BABYLON.IAnimatable[];
  82385. dispose(forceDisposeEffect?: boolean): void;
  82386. clone(name: string): GradientMaterial;
  82387. serialize(): any;
  82388. getClassName(): string;
  82389. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  82390. }
  82391. }
  82392. declare module BABYLON {
  82393. /** @hidden */
  82394. export var gridPixelShader: {
  82395. name: string;
  82396. shader: string;
  82397. };
  82398. }
  82399. declare module BABYLON {
  82400. /** @hidden */
  82401. export var gridVertexShader: {
  82402. name: string;
  82403. shader: string;
  82404. };
  82405. }
  82406. declare module BABYLON {
  82407. /**
  82408. * The grid materials allows you to wrap any shape with a grid.
  82409. * Colors are customizable.
  82410. */
  82411. export class GridMaterial extends BABYLON.PushMaterial {
  82412. /**
  82413. * Main color of the grid (e.g. between lines)
  82414. */
  82415. mainColor: BABYLON.Color3;
  82416. /**
  82417. * Color of the grid lines.
  82418. */
  82419. lineColor: BABYLON.Color3;
  82420. /**
  82421. * The scale of the grid compared to unit.
  82422. */
  82423. gridRatio: number;
  82424. /**
  82425. * Allows setting an offset for the grid lines.
  82426. */
  82427. gridOffset: BABYLON.Vector3;
  82428. /**
  82429. * The frequency of thicker lines.
  82430. */
  82431. majorUnitFrequency: number;
  82432. /**
  82433. * The visibility of minor units in the grid.
  82434. */
  82435. minorUnitVisibility: number;
  82436. /**
  82437. * The grid opacity outside of the lines.
  82438. */
  82439. opacity: number;
  82440. /**
  82441. * Determine RBG output is premultiplied by alpha value.
  82442. */
  82443. preMultiplyAlpha: boolean;
  82444. private _opacityTexture;
  82445. opacityTexture: BABYLON.BaseTexture;
  82446. private _gridControl;
  82447. /**
  82448. * constructor
  82449. * @param name The name given to the material in order to identify it afterwards.
  82450. * @param scene The scene the material is used in.
  82451. */
  82452. constructor(name: string, scene: BABYLON.Scene);
  82453. /**
  82454. * Returns wehter or not the grid requires alpha blending.
  82455. */
  82456. needAlphaBlending(): boolean;
  82457. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82458. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82459. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82460. /**
  82461. * Dispose the material and its associated resources.
  82462. * @param forceDisposeEffect will also dispose the used effect when true
  82463. */
  82464. dispose(forceDisposeEffect?: boolean): void;
  82465. clone(name: string): GridMaterial;
  82466. serialize(): any;
  82467. getClassName(): string;
  82468. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  82469. }
  82470. }
  82471. declare module BABYLON {
  82472. /** @hidden */
  82473. export var lavaPixelShader: {
  82474. name: string;
  82475. shader: string;
  82476. };
  82477. }
  82478. declare module BABYLON {
  82479. /** @hidden */
  82480. export var lavaVertexShader: {
  82481. name: string;
  82482. shader: string;
  82483. };
  82484. }
  82485. declare module BABYLON {
  82486. export class LavaMaterial extends BABYLON.PushMaterial {
  82487. private _diffuseTexture;
  82488. diffuseTexture: BABYLON.BaseTexture;
  82489. noiseTexture: BABYLON.BaseTexture;
  82490. fogColor: BABYLON.Color3;
  82491. speed: number;
  82492. movingSpeed: number;
  82493. lowFrequencySpeed: number;
  82494. fogDensity: number;
  82495. private _lastTime;
  82496. diffuseColor: BABYLON.Color3;
  82497. private _disableLighting;
  82498. disableLighting: boolean;
  82499. private _unlit;
  82500. unlit: boolean;
  82501. private _maxSimultaneousLights;
  82502. maxSimultaneousLights: number;
  82503. private _scaledDiffuse;
  82504. constructor(name: string, scene: BABYLON.Scene);
  82505. needAlphaBlending(): boolean;
  82506. needAlphaTesting(): boolean;
  82507. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82508. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82509. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82510. getAnimatables(): BABYLON.IAnimatable[];
  82511. getActiveTextures(): BABYLON.BaseTexture[];
  82512. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82513. dispose(forceDisposeEffect?: boolean): void;
  82514. clone(name: string): LavaMaterial;
  82515. serialize(): any;
  82516. getClassName(): string;
  82517. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  82518. }
  82519. }
  82520. declare module BABYLON {
  82521. /** @hidden */
  82522. export var mixPixelShader: {
  82523. name: string;
  82524. shader: string;
  82525. };
  82526. }
  82527. declare module BABYLON {
  82528. /** @hidden */
  82529. export var mixVertexShader: {
  82530. name: string;
  82531. shader: string;
  82532. };
  82533. }
  82534. declare module BABYLON {
  82535. export class MixMaterial extends BABYLON.PushMaterial {
  82536. /**
  82537. * Mix textures
  82538. */
  82539. private _mixTexture1;
  82540. mixTexture1: BABYLON.BaseTexture;
  82541. private _mixTexture2;
  82542. mixTexture2: BABYLON.BaseTexture;
  82543. /**
  82544. * Diffuse textures
  82545. */
  82546. private _diffuseTexture1;
  82547. diffuseTexture1: BABYLON.Texture;
  82548. private _diffuseTexture2;
  82549. diffuseTexture2: BABYLON.Texture;
  82550. private _diffuseTexture3;
  82551. diffuseTexture3: BABYLON.Texture;
  82552. private _diffuseTexture4;
  82553. diffuseTexture4: BABYLON.Texture;
  82554. private _diffuseTexture5;
  82555. diffuseTexture5: BABYLON.Texture;
  82556. private _diffuseTexture6;
  82557. diffuseTexture6: BABYLON.Texture;
  82558. private _diffuseTexture7;
  82559. diffuseTexture7: BABYLON.Texture;
  82560. private _diffuseTexture8;
  82561. diffuseTexture8: BABYLON.Texture;
  82562. /**
  82563. * Uniforms
  82564. */
  82565. diffuseColor: BABYLON.Color3;
  82566. specularColor: BABYLON.Color3;
  82567. specularPower: number;
  82568. private _disableLighting;
  82569. disableLighting: boolean;
  82570. private _maxSimultaneousLights;
  82571. maxSimultaneousLights: number;
  82572. constructor(name: string, scene: BABYLON.Scene);
  82573. needAlphaBlending(): boolean;
  82574. needAlphaTesting(): boolean;
  82575. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82576. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82577. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82578. getAnimatables(): BABYLON.IAnimatable[];
  82579. getActiveTextures(): BABYLON.BaseTexture[];
  82580. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82581. dispose(forceDisposeEffect?: boolean): void;
  82582. clone(name: string): MixMaterial;
  82583. serialize(): any;
  82584. getClassName(): string;
  82585. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  82586. }
  82587. }
  82588. declare module BABYLON {
  82589. /** @hidden */
  82590. export var normalPixelShader: {
  82591. name: string;
  82592. shader: string;
  82593. };
  82594. }
  82595. declare module BABYLON {
  82596. /** @hidden */
  82597. export var normalVertexShader: {
  82598. name: string;
  82599. shader: string;
  82600. };
  82601. }
  82602. declare module BABYLON {
  82603. export class NormalMaterial extends BABYLON.PushMaterial {
  82604. private _diffuseTexture;
  82605. diffuseTexture: BABYLON.BaseTexture;
  82606. diffuseColor: BABYLON.Color3;
  82607. private _disableLighting;
  82608. disableLighting: boolean;
  82609. private _maxSimultaneousLights;
  82610. maxSimultaneousLights: number;
  82611. constructor(name: string, scene: BABYLON.Scene);
  82612. needAlphaBlending(): boolean;
  82613. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): 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): NormalMaterial;
  82623. serialize(): any;
  82624. getClassName(): string;
  82625. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  82626. }
  82627. }
  82628. declare module BABYLON {
  82629. /** @hidden */
  82630. export var shadowOnlyPixelShader: {
  82631. name: string;
  82632. shader: string;
  82633. };
  82634. }
  82635. declare module BABYLON {
  82636. /** @hidden */
  82637. export var shadowOnlyVertexShader: {
  82638. name: string;
  82639. shader: string;
  82640. };
  82641. }
  82642. declare module BABYLON {
  82643. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  82644. private _activeLight;
  82645. private _needAlphaBlending;
  82646. constructor(name: string, scene: BABYLON.Scene);
  82647. shadowColor: BABYLON.Color3;
  82648. needAlphaBlending(): boolean;
  82649. needAlphaTesting(): boolean;
  82650. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82651. get activeLight(): BABYLON.IShadowLight;
  82652. set activeLight(light: BABYLON.IShadowLight);
  82653. private _getFirstShadowLightForMesh;
  82654. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82655. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82656. clone(name: string): ShadowOnlyMaterial;
  82657. serialize(): any;
  82658. getClassName(): string;
  82659. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  82660. }
  82661. }
  82662. declare module BABYLON {
  82663. /** @hidden */
  82664. export var simplePixelShader: {
  82665. name: string;
  82666. shader: string;
  82667. };
  82668. }
  82669. declare module BABYLON {
  82670. /** @hidden */
  82671. export var simpleVertexShader: {
  82672. name: string;
  82673. shader: string;
  82674. };
  82675. }
  82676. declare module BABYLON {
  82677. export class SimpleMaterial extends BABYLON.PushMaterial {
  82678. private _diffuseTexture;
  82679. diffuseTexture: BABYLON.BaseTexture;
  82680. diffuseColor: BABYLON.Color3;
  82681. private _disableLighting;
  82682. disableLighting: boolean;
  82683. private _maxSimultaneousLights;
  82684. maxSimultaneousLights: number;
  82685. constructor(name: string, scene: BABYLON.Scene);
  82686. needAlphaBlending(): boolean;
  82687. needAlphaTesting(): boolean;
  82688. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82689. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82690. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82691. getAnimatables(): BABYLON.IAnimatable[];
  82692. getActiveTextures(): BABYLON.BaseTexture[];
  82693. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82694. dispose(forceDisposeEffect?: boolean): void;
  82695. clone(name: string): SimpleMaterial;
  82696. serialize(): any;
  82697. getClassName(): string;
  82698. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  82699. }
  82700. }
  82701. declare module BABYLON {
  82702. /** @hidden */
  82703. export var skyPixelShader: {
  82704. name: string;
  82705. shader: string;
  82706. };
  82707. }
  82708. declare module BABYLON {
  82709. /** @hidden */
  82710. export var skyVertexShader: {
  82711. name: string;
  82712. shader: string;
  82713. };
  82714. }
  82715. declare module BABYLON {
  82716. /**
  82717. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  82718. * @see https://doc.babylonjs.com/extensions/sky
  82719. */
  82720. export class SkyMaterial extends BABYLON.PushMaterial {
  82721. /**
  82722. * Defines the overall luminance of sky in interval ]0, 1[.
  82723. */
  82724. luminance: number;
  82725. /**
  82726. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  82727. */
  82728. turbidity: number;
  82729. /**
  82730. * Defines the sky appearance (light intensity).
  82731. */
  82732. rayleigh: number;
  82733. /**
  82734. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  82735. */
  82736. mieCoefficient: number;
  82737. /**
  82738. * Defines the amount of haze particles following the Mie scattering theory.
  82739. */
  82740. mieDirectionalG: number;
  82741. /**
  82742. * Defines the distance of the sun according to the active scene camera.
  82743. */
  82744. distance: number;
  82745. /**
  82746. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  82747. * "inclined".
  82748. */
  82749. inclination: number;
  82750. /**
  82751. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  82752. * an object direction and a reference direction.
  82753. */
  82754. azimuth: number;
  82755. /**
  82756. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  82757. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  82758. */
  82759. sunPosition: BABYLON.Vector3;
  82760. /**
  82761. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  82762. * .sunPosition property.
  82763. */
  82764. useSunPosition: boolean;
  82765. /**
  82766. * Defines an offset vector used to get a horizon offset.
  82767. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  82768. */
  82769. cameraOffset: BABYLON.Vector3;
  82770. private _cameraPosition;
  82771. /**
  82772. * Instantiates a new sky material.
  82773. * This material allows to create dynamic and texture free
  82774. * effects for skyboxes by taking care of the atmosphere state.
  82775. * @see https://doc.babylonjs.com/extensions/sky
  82776. * @param name Define the name of the material in the scene
  82777. * @param scene Define the scene the material belong to
  82778. */
  82779. constructor(name: string, scene: BABYLON.Scene);
  82780. /**
  82781. * Specifies if the material will require alpha blending
  82782. * @returns a boolean specifying if alpha blending is needed
  82783. */
  82784. needAlphaBlending(): boolean;
  82785. /**
  82786. * Specifies if this material should be rendered in alpha test mode
  82787. * @returns false as the sky material doesn't need alpha testing.
  82788. */
  82789. needAlphaTesting(): boolean;
  82790. /**
  82791. * Get the texture used for alpha test purpose.
  82792. * @returns null as the sky material has no texture.
  82793. */
  82794. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82795. /**
  82796. * Get if the submesh is ready to be used and all its information available.
  82797. * Child classes can use it to update shaders
  82798. * @param mesh defines the mesh to check
  82799. * @param subMesh defines which submesh to check
  82800. * @param useInstances specifies that instances should be used
  82801. * @returns a boolean indicating that the submesh is ready or not
  82802. */
  82803. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82804. /**
  82805. * Binds the submesh to this material by preparing the effect and shader to draw
  82806. * @param world defines the world transformation matrix
  82807. * @param mesh defines the mesh containing the submesh
  82808. * @param subMesh defines the submesh to bind the material to
  82809. */
  82810. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82811. /**
  82812. * Get the list of animatables in the material.
  82813. * @returns the list of animatables object used in the material
  82814. */
  82815. getAnimatables(): BABYLON.IAnimatable[];
  82816. /**
  82817. * Disposes the material
  82818. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82819. */
  82820. dispose(forceDisposeEffect?: boolean): void;
  82821. /**
  82822. * Makes a duplicate of the material, and gives it a new name
  82823. * @param name defines the new name for the duplicated material
  82824. * @returns the cloned material
  82825. */
  82826. clone(name: string): SkyMaterial;
  82827. /**
  82828. * Serializes this material in a JSON representation
  82829. * @returns the serialized material object
  82830. */
  82831. serialize(): any;
  82832. /**
  82833. * Gets the current class name of the material e.g. "SkyMaterial"
  82834. * Mainly use in serialization.
  82835. * @returns the class name
  82836. */
  82837. getClassName(): string;
  82838. /**
  82839. * Creates a sky material from parsed material data
  82840. * @param source defines the JSON representation of the material
  82841. * @param scene defines the hosting scene
  82842. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  82843. * @returns a new sky material
  82844. */
  82845. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  82846. }
  82847. }
  82848. declare module BABYLON {
  82849. /** @hidden */
  82850. export var terrainPixelShader: {
  82851. name: string;
  82852. shader: string;
  82853. };
  82854. }
  82855. declare module BABYLON {
  82856. /** @hidden */
  82857. export var terrainVertexShader: {
  82858. name: string;
  82859. shader: string;
  82860. };
  82861. }
  82862. declare module BABYLON {
  82863. export class TerrainMaterial extends BABYLON.PushMaterial {
  82864. private _mixTexture;
  82865. mixTexture: BABYLON.BaseTexture;
  82866. private _diffuseTexture1;
  82867. diffuseTexture1: BABYLON.Texture;
  82868. private _diffuseTexture2;
  82869. diffuseTexture2: BABYLON.Texture;
  82870. private _diffuseTexture3;
  82871. diffuseTexture3: BABYLON.Texture;
  82872. private _bumpTexture1;
  82873. bumpTexture1: BABYLON.Texture;
  82874. private _bumpTexture2;
  82875. bumpTexture2: BABYLON.Texture;
  82876. private _bumpTexture3;
  82877. bumpTexture3: BABYLON.Texture;
  82878. diffuseColor: BABYLON.Color3;
  82879. specularColor: BABYLON.Color3;
  82880. specularPower: number;
  82881. private _disableLighting;
  82882. disableLighting: boolean;
  82883. private _maxSimultaneousLights;
  82884. maxSimultaneousLights: number;
  82885. constructor(name: string, scene: BABYLON.Scene);
  82886. needAlphaBlending(): boolean;
  82887. needAlphaTesting(): boolean;
  82888. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82889. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82890. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82891. getAnimatables(): BABYLON.IAnimatable[];
  82892. getActiveTextures(): BABYLON.BaseTexture[];
  82893. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82894. dispose(forceDisposeEffect?: boolean): void;
  82895. clone(name: string): TerrainMaterial;
  82896. serialize(): any;
  82897. getClassName(): string;
  82898. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  82899. }
  82900. }
  82901. declare module BABYLON {
  82902. /** @hidden */
  82903. export var triplanarPixelShader: {
  82904. name: string;
  82905. shader: string;
  82906. };
  82907. }
  82908. declare module BABYLON {
  82909. /** @hidden */
  82910. export var triplanarVertexShader: {
  82911. name: string;
  82912. shader: string;
  82913. };
  82914. }
  82915. declare module BABYLON {
  82916. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  82917. mixTexture: BABYLON.BaseTexture;
  82918. private _diffuseTextureX;
  82919. diffuseTextureX: BABYLON.BaseTexture;
  82920. private _diffuseTextureY;
  82921. diffuseTextureY: BABYLON.BaseTexture;
  82922. private _diffuseTextureZ;
  82923. diffuseTextureZ: BABYLON.BaseTexture;
  82924. private _normalTextureX;
  82925. normalTextureX: BABYLON.BaseTexture;
  82926. private _normalTextureY;
  82927. normalTextureY: BABYLON.BaseTexture;
  82928. private _normalTextureZ;
  82929. normalTextureZ: BABYLON.BaseTexture;
  82930. tileSize: number;
  82931. diffuseColor: BABYLON.Color3;
  82932. specularColor: BABYLON.Color3;
  82933. specularPower: number;
  82934. private _disableLighting;
  82935. disableLighting: boolean;
  82936. private _maxSimultaneousLights;
  82937. maxSimultaneousLights: number;
  82938. constructor(name: string, scene: BABYLON.Scene);
  82939. needAlphaBlending(): boolean;
  82940. needAlphaTesting(): boolean;
  82941. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82942. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82943. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82944. getAnimatables(): BABYLON.IAnimatable[];
  82945. getActiveTextures(): BABYLON.BaseTexture[];
  82946. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82947. dispose(forceDisposeEffect?: boolean): void;
  82948. clone(name: string): TriPlanarMaterial;
  82949. serialize(): any;
  82950. getClassName(): string;
  82951. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  82952. }
  82953. }
  82954. declare module BABYLON {
  82955. /** @hidden */
  82956. export var waterPixelShader: {
  82957. name: string;
  82958. shader: string;
  82959. };
  82960. }
  82961. declare module BABYLON {
  82962. /** @hidden */
  82963. export var waterVertexShader: {
  82964. name: string;
  82965. shader: string;
  82966. };
  82967. }
  82968. declare module BABYLON {
  82969. export class WaterMaterial extends BABYLON.PushMaterial {
  82970. renderTargetSize: BABYLON.Vector2;
  82971. private _bumpTexture;
  82972. bumpTexture: BABYLON.BaseTexture;
  82973. diffuseColor: BABYLON.Color3;
  82974. specularColor: BABYLON.Color3;
  82975. specularPower: number;
  82976. private _disableLighting;
  82977. disableLighting: boolean;
  82978. private _maxSimultaneousLights;
  82979. maxSimultaneousLights: number;
  82980. /**
  82981. * @param {number}: Represents the wind force
  82982. */
  82983. windForce: number;
  82984. /**
  82985. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  82986. */
  82987. windDirection: BABYLON.Vector2;
  82988. /**
  82989. * @param {number}: Wave height, represents the height of the waves
  82990. */
  82991. waveHeight: number;
  82992. /**
  82993. * @param {number}: Bump height, represents the bump height related to the bump map
  82994. */
  82995. bumpHeight: number;
  82996. /**
  82997. * @param {boolean}: Add a smaller moving bump to less steady waves.
  82998. */
  82999. private _bumpSuperimpose;
  83000. bumpSuperimpose: boolean;
  83001. /**
  83002. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83003. */
  83004. private _fresnelSeparate;
  83005. fresnelSeparate: boolean;
  83006. /**
  83007. * @param {boolean}: bump Waves modify the reflection.
  83008. */
  83009. private _bumpAffectsReflection;
  83010. bumpAffectsReflection: boolean;
  83011. /**
  83012. * @param {number}: The water color blended with the refraction (near)
  83013. */
  83014. waterColor: BABYLON.Color3;
  83015. /**
  83016. * @param {number}: The blend factor related to the water color
  83017. */
  83018. colorBlendFactor: number;
  83019. /**
  83020. * @param {number}: The water color blended with the reflection (far)
  83021. */
  83022. waterColor2: BABYLON.Color3;
  83023. /**
  83024. * @param {number}: The blend factor related to the water color (reflection, far)
  83025. */
  83026. colorBlendFactor2: number;
  83027. /**
  83028. * @param {number}: Represents the maximum length of a wave
  83029. */
  83030. waveLength: number;
  83031. /**
  83032. * @param {number}: Defines the waves speed
  83033. */
  83034. waveSpeed: number;
  83035. /**
  83036. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83037. * will avoid calculating useless pixels in the pixel shader of the water material.
  83038. */
  83039. disableClipPlane: boolean;
  83040. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83041. private _mesh;
  83042. private _refractionRTT;
  83043. private _reflectionRTT;
  83044. private _reflectionTransform;
  83045. private _lastTime;
  83046. private _lastDeltaTime;
  83047. private _useLogarithmicDepth;
  83048. private _waitingRenderList;
  83049. private _imageProcessingConfiguration;
  83050. private _imageProcessingObserver;
  83051. /**
  83052. * Gets a boolean indicating that current material needs to register RTT
  83053. */
  83054. get hasRenderTargetTextures(): boolean;
  83055. /**
  83056. * Constructor
  83057. */
  83058. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83059. get useLogarithmicDepth(): boolean;
  83060. set useLogarithmicDepth(value: boolean);
  83061. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83062. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83063. addToRenderList(node: any): void;
  83064. enableRenderTargets(enable: boolean): void;
  83065. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83066. get renderTargetsEnabled(): boolean;
  83067. needAlphaBlending(): boolean;
  83068. needAlphaTesting(): boolean;
  83069. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83070. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83071. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83072. private _createRenderTargets;
  83073. getAnimatables(): BABYLON.IAnimatable[];
  83074. getActiveTextures(): BABYLON.BaseTexture[];
  83075. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83076. dispose(forceDisposeEffect?: boolean): void;
  83077. clone(name: string): WaterMaterial;
  83078. serialize(): any;
  83079. getClassName(): string;
  83080. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83081. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83082. }
  83083. }
  83084. declare module BABYLON {
  83085. /** @hidden */
  83086. export var asciiartPixelShader: {
  83087. name: string;
  83088. shader: string;
  83089. };
  83090. }
  83091. declare module BABYLON {
  83092. /**
  83093. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83094. *
  83095. * It basically takes care rendering the font front the given font size to a texture.
  83096. * This is used later on in the postprocess.
  83097. */
  83098. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83099. private _font;
  83100. private _text;
  83101. private _charSize;
  83102. /**
  83103. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83104. */
  83105. get charSize(): number;
  83106. /**
  83107. * Create a new instance of the Ascii Art FontTexture class
  83108. * @param name the name of the texture
  83109. * @param font the font to use, use the W3C CSS notation
  83110. * @param text the caracter set to use in the rendering.
  83111. * @param scene the scene that owns the texture
  83112. */
  83113. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83114. /**
  83115. * Gets the max char width of a font.
  83116. * @param font the font to use, use the W3C CSS notation
  83117. * @return the max char width
  83118. */
  83119. private getFontWidth;
  83120. /**
  83121. * Gets the max char height of a font.
  83122. * @param font the font to use, use the W3C CSS notation
  83123. * @return the max char height
  83124. */
  83125. private getFontHeight;
  83126. /**
  83127. * Clones the current AsciiArtTexture.
  83128. * @return the clone of the texture.
  83129. */
  83130. clone(): AsciiArtFontTexture;
  83131. /**
  83132. * Parses a json object representing the texture and returns an instance of it.
  83133. * @param source the source JSON representation
  83134. * @param scene the scene to create the texture for
  83135. * @return the parsed texture
  83136. */
  83137. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83138. }
  83139. /**
  83140. * Option available in the Ascii Art Post Process.
  83141. */
  83142. export interface IAsciiArtPostProcessOptions {
  83143. /**
  83144. * The font to use following the w3c font definition.
  83145. */
  83146. font?: string;
  83147. /**
  83148. * The character set to use in the postprocess.
  83149. */
  83150. characterSet?: string;
  83151. /**
  83152. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83153. * This number is defined between 0 and 1;
  83154. */
  83155. mixToTile?: number;
  83156. /**
  83157. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83158. * This number is defined between 0 and 1;
  83159. */
  83160. mixToNormal?: number;
  83161. }
  83162. /**
  83163. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83164. *
  83165. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83166. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83167. */
  83168. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83169. /**
  83170. * The font texture used to render the char in the post process.
  83171. */
  83172. private _asciiArtFontTexture;
  83173. /**
  83174. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83175. * This number is defined between 0 and 1;
  83176. */
  83177. mixToTile: number;
  83178. /**
  83179. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83180. * This number is defined between 0 and 1;
  83181. */
  83182. mixToNormal: number;
  83183. /**
  83184. * Instantiates a new Ascii Art Post Process.
  83185. * @param name the name to give to the postprocess
  83186. * @camera the camera to apply the post process to.
  83187. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83188. */
  83189. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83190. }
  83191. }
  83192. declare module BABYLON {
  83193. /** @hidden */
  83194. export var digitalrainPixelShader: {
  83195. name: string;
  83196. shader: string;
  83197. };
  83198. }
  83199. declare module BABYLON {
  83200. /**
  83201. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  83202. *
  83203. * It basically takes care rendering the font front the given font size to a texture.
  83204. * This is used later on in the postprocess.
  83205. */
  83206. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  83207. private _font;
  83208. private _text;
  83209. private _charSize;
  83210. /**
  83211. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83212. */
  83213. get charSize(): number;
  83214. /**
  83215. * Create a new instance of the Digital Rain FontTexture class
  83216. * @param name the name of the texture
  83217. * @param font the font to use, use the W3C CSS notation
  83218. * @param text the caracter set to use in the rendering.
  83219. * @param scene the scene that owns the texture
  83220. */
  83221. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83222. /**
  83223. * Gets the max char width of a font.
  83224. * @param font the font to use, use the W3C CSS notation
  83225. * @return the max char width
  83226. */
  83227. private getFontWidth;
  83228. /**
  83229. * Gets the max char height of a font.
  83230. * @param font the font to use, use the W3C CSS notation
  83231. * @return the max char height
  83232. */
  83233. private getFontHeight;
  83234. /**
  83235. * Clones the current DigitalRainFontTexture.
  83236. * @return the clone of the texture.
  83237. */
  83238. clone(): DigitalRainFontTexture;
  83239. /**
  83240. * Parses a json object representing the texture and returns an instance of it.
  83241. * @param source the source JSON representation
  83242. * @param scene the scene to create the texture for
  83243. * @return the parsed texture
  83244. */
  83245. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  83246. }
  83247. /**
  83248. * Option available in the Digital Rain Post Process.
  83249. */
  83250. export interface IDigitalRainPostProcessOptions {
  83251. /**
  83252. * The font to use following the w3c font definition.
  83253. */
  83254. font?: string;
  83255. /**
  83256. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83257. * This number is defined between 0 and 1;
  83258. */
  83259. mixToTile?: number;
  83260. /**
  83261. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83262. * This number is defined between 0 and 1;
  83263. */
  83264. mixToNormal?: number;
  83265. }
  83266. /**
  83267. * DigitalRainPostProcess helps rendering everithing in digital rain.
  83268. *
  83269. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83270. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  83271. */
  83272. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  83273. /**
  83274. * The font texture used to render the char in the post process.
  83275. */
  83276. private _digitalRainFontTexture;
  83277. /**
  83278. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83279. * This number is defined between 0 and 1;
  83280. */
  83281. mixToTile: number;
  83282. /**
  83283. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83284. * This number is defined between 0 and 1;
  83285. */
  83286. mixToNormal: number;
  83287. /**
  83288. * Instantiates a new Digital Rain Post Process.
  83289. * @param name the name to give to the postprocess
  83290. * @camera the camera to apply the post process to.
  83291. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  83292. */
  83293. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  83294. }
  83295. }
  83296. declare module BABYLON {
  83297. /** @hidden */
  83298. export var brickProceduralTexturePixelShader: {
  83299. name: string;
  83300. shader: string;
  83301. };
  83302. }
  83303. declare module BABYLON {
  83304. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  83305. private _numberOfBricksHeight;
  83306. private _numberOfBricksWidth;
  83307. private _jointColor;
  83308. private _brickColor;
  83309. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83310. updateShaderUniforms(): void;
  83311. get numberOfBricksHeight(): number;
  83312. set numberOfBricksHeight(value: number);
  83313. get numberOfBricksWidth(): number;
  83314. set numberOfBricksWidth(value: number);
  83315. get jointColor(): BABYLON.Color3;
  83316. set jointColor(value: BABYLON.Color3);
  83317. get brickColor(): BABYLON.Color3;
  83318. set brickColor(value: BABYLON.Color3);
  83319. /**
  83320. * Serializes this brick procedural texture
  83321. * @returns a serialized brick procedural texture object
  83322. */
  83323. serialize(): any;
  83324. /**
  83325. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  83326. * @param parsedTexture defines parsed texture data
  83327. * @param scene defines the current scene
  83328. * @param rootUrl defines the root URL containing brick procedural texture information
  83329. * @returns a parsed Brick Procedural BABYLON.Texture
  83330. */
  83331. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  83332. }
  83333. }
  83334. declare module BABYLON {
  83335. /** @hidden */
  83336. export var cloudProceduralTexturePixelShader: {
  83337. name: string;
  83338. shader: string;
  83339. };
  83340. }
  83341. declare module BABYLON {
  83342. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  83343. private _skyColor;
  83344. private _cloudColor;
  83345. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83346. updateShaderUniforms(): void;
  83347. get skyColor(): BABYLON.Color4;
  83348. set skyColor(value: BABYLON.Color4);
  83349. get cloudColor(): BABYLON.Color4;
  83350. set cloudColor(value: BABYLON.Color4);
  83351. /**
  83352. * Serializes this cloud procedural texture
  83353. * @returns a serialized cloud procedural texture object
  83354. */
  83355. serialize(): any;
  83356. /**
  83357. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  83358. * @param parsedTexture defines parsed texture data
  83359. * @param scene defines the current scene
  83360. * @param rootUrl defines the root URL containing cloud procedural texture information
  83361. * @returns a parsed Cloud Procedural BABYLON.Texture
  83362. */
  83363. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  83364. }
  83365. }
  83366. declare module BABYLON {
  83367. /** @hidden */
  83368. export var fireProceduralTexturePixelShader: {
  83369. name: string;
  83370. shader: string;
  83371. };
  83372. }
  83373. declare module BABYLON {
  83374. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  83375. private _time;
  83376. private _speed;
  83377. private _autoGenerateTime;
  83378. private _fireColors;
  83379. private _alphaThreshold;
  83380. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83381. updateShaderUniforms(): void;
  83382. render(useCameraPostProcess?: boolean): void;
  83383. static get PurpleFireColors(): BABYLON.Color3[];
  83384. static get GreenFireColors(): BABYLON.Color3[];
  83385. static get RedFireColors(): BABYLON.Color3[];
  83386. static get BlueFireColors(): BABYLON.Color3[];
  83387. get autoGenerateTime(): boolean;
  83388. set autoGenerateTime(value: boolean);
  83389. get fireColors(): BABYLON.Color3[];
  83390. set fireColors(value: BABYLON.Color3[]);
  83391. get time(): number;
  83392. set time(value: number);
  83393. get speed(): BABYLON.Vector2;
  83394. set speed(value: BABYLON.Vector2);
  83395. get alphaThreshold(): number;
  83396. set alphaThreshold(value: number);
  83397. /**
  83398. * Serializes this fire procedural texture
  83399. * @returns a serialized fire procedural texture object
  83400. */
  83401. serialize(): any;
  83402. /**
  83403. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  83404. * @param parsedTexture defines parsed texture data
  83405. * @param scene defines the current scene
  83406. * @param rootUrl defines the root URL containing fire procedural texture information
  83407. * @returns a parsed Fire Procedural BABYLON.Texture
  83408. */
  83409. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  83410. }
  83411. }
  83412. declare module BABYLON {
  83413. /** @hidden */
  83414. export var grassProceduralTexturePixelShader: {
  83415. name: string;
  83416. shader: string;
  83417. };
  83418. }
  83419. declare module BABYLON {
  83420. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  83421. private _grassColors;
  83422. private _groundColor;
  83423. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83424. updateShaderUniforms(): void;
  83425. get grassColors(): BABYLON.Color3[];
  83426. set grassColors(value: BABYLON.Color3[]);
  83427. get groundColor(): BABYLON.Color3;
  83428. set groundColor(value: BABYLON.Color3);
  83429. /**
  83430. * Serializes this grass procedural texture
  83431. * @returns a serialized grass procedural texture object
  83432. */
  83433. serialize(): any;
  83434. /**
  83435. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  83436. * @param parsedTexture defines parsed texture data
  83437. * @param scene defines the current scene
  83438. * @param rootUrl defines the root URL containing grass procedural texture information
  83439. * @returns a parsed Grass Procedural BABYLON.Texture
  83440. */
  83441. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  83442. }
  83443. }
  83444. declare module BABYLON {
  83445. /** @hidden */
  83446. export var marbleProceduralTexturePixelShader: {
  83447. name: string;
  83448. shader: string;
  83449. };
  83450. }
  83451. declare module BABYLON {
  83452. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  83453. private _numberOfTilesHeight;
  83454. private _numberOfTilesWidth;
  83455. private _amplitude;
  83456. private _jointColor;
  83457. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83458. updateShaderUniforms(): void;
  83459. get numberOfTilesHeight(): number;
  83460. set numberOfTilesHeight(value: number);
  83461. get amplitude(): number;
  83462. set amplitude(value: number);
  83463. get numberOfTilesWidth(): number;
  83464. set numberOfTilesWidth(value: number);
  83465. get jointColor(): BABYLON.Color3;
  83466. set jointColor(value: BABYLON.Color3);
  83467. /**
  83468. * Serializes this marble procedural texture
  83469. * @returns a serialized marble procedural texture object
  83470. */
  83471. serialize(): any;
  83472. /**
  83473. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  83474. * @param parsedTexture defines parsed texture data
  83475. * @param scene defines the current scene
  83476. * @param rootUrl defines the root URL containing marble procedural texture information
  83477. * @returns a parsed Marble Procedural BABYLON.Texture
  83478. */
  83479. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  83480. }
  83481. }
  83482. declare module BABYLON {
  83483. /** @hidden */
  83484. export var normalMapProceduralTexturePixelShader: {
  83485. name: string;
  83486. shader: string;
  83487. };
  83488. }
  83489. declare module BABYLON {
  83490. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  83491. private _baseTexture;
  83492. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83493. updateShaderUniforms(): void;
  83494. render(useCameraPostProcess?: boolean): void;
  83495. resize(size: any, generateMipMaps: any): void;
  83496. get baseTexture(): BABYLON.Texture;
  83497. set baseTexture(texture: BABYLON.Texture);
  83498. /**
  83499. * Serializes this normal map procedural texture
  83500. * @returns a serialized normal map procedural texture object
  83501. */
  83502. serialize(): any;
  83503. /**
  83504. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  83505. * @param parsedTexture defines parsed texture data
  83506. * @param scene defines the current scene
  83507. * @param rootUrl defines the root URL containing normal map procedural texture information
  83508. * @returns a parsed Normal Map Procedural BABYLON.Texture
  83509. */
  83510. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  83511. }
  83512. }
  83513. declare module BABYLON {
  83514. /** @hidden */
  83515. export var perlinNoiseProceduralTexturePixelShader: {
  83516. name: string;
  83517. shader: string;
  83518. };
  83519. }
  83520. declare module BABYLON {
  83521. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  83522. time: number;
  83523. timeScale: number;
  83524. translationSpeed: number;
  83525. private _currentTranslation;
  83526. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83527. updateShaderUniforms(): void;
  83528. render(useCameraPostProcess?: boolean): void;
  83529. resize(size: any, generateMipMaps: any): void;
  83530. /**
  83531. * Serializes this perlin noise procedural texture
  83532. * @returns a serialized perlin noise procedural texture object
  83533. */
  83534. serialize(): any;
  83535. /**
  83536. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  83537. * @param parsedTexture defines parsed texture data
  83538. * @param scene defines the current scene
  83539. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  83540. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  83541. */
  83542. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  83543. }
  83544. }
  83545. declare module BABYLON {
  83546. /** @hidden */
  83547. export var roadProceduralTexturePixelShader: {
  83548. name: string;
  83549. shader: string;
  83550. };
  83551. }
  83552. declare module BABYLON {
  83553. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  83554. private _roadColor;
  83555. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83556. updateShaderUniforms(): void;
  83557. get roadColor(): BABYLON.Color3;
  83558. set roadColor(value: BABYLON.Color3);
  83559. /**
  83560. * Serializes this road procedural texture
  83561. * @returns a serialized road procedural texture object
  83562. */
  83563. serialize(): any;
  83564. /**
  83565. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  83566. * @param parsedTexture defines parsed texture data
  83567. * @param scene defines the current scene
  83568. * @param rootUrl defines the root URL containing road procedural texture information
  83569. * @returns a parsed Road Procedural BABYLON.Texture
  83570. */
  83571. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  83572. }
  83573. }
  83574. declare module BABYLON {
  83575. /** @hidden */
  83576. export var starfieldProceduralTexturePixelShader: {
  83577. name: string;
  83578. shader: string;
  83579. };
  83580. }
  83581. declare module BABYLON {
  83582. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  83583. private _time;
  83584. private _alpha;
  83585. private _beta;
  83586. private _zoom;
  83587. private _formuparam;
  83588. private _stepsize;
  83589. private _tile;
  83590. private _brightness;
  83591. private _darkmatter;
  83592. private _distfading;
  83593. private _saturation;
  83594. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83595. updateShaderUniforms(): void;
  83596. get time(): number;
  83597. set time(value: number);
  83598. get alpha(): number;
  83599. set alpha(value: number);
  83600. get beta(): number;
  83601. set beta(value: number);
  83602. get formuparam(): number;
  83603. set formuparam(value: number);
  83604. get stepsize(): number;
  83605. set stepsize(value: number);
  83606. get zoom(): number;
  83607. set zoom(value: number);
  83608. get tile(): number;
  83609. set tile(value: number);
  83610. get brightness(): number;
  83611. set brightness(value: number);
  83612. get darkmatter(): number;
  83613. set darkmatter(value: number);
  83614. get distfading(): number;
  83615. set distfading(value: number);
  83616. get saturation(): number;
  83617. set saturation(value: number);
  83618. /**
  83619. * Serializes this starfield procedural texture
  83620. * @returns a serialized starfield procedural texture object
  83621. */
  83622. serialize(): any;
  83623. /**
  83624. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  83625. * @param parsedTexture defines parsed texture data
  83626. * @param scene defines the current scene
  83627. * @param rootUrl defines the root URL containing startfield procedural texture information
  83628. * @returns a parsed Starfield Procedural BABYLON.Texture
  83629. */
  83630. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  83631. }
  83632. }
  83633. declare module BABYLON {
  83634. /** @hidden */
  83635. export var woodProceduralTexturePixelShader: {
  83636. name: string;
  83637. shader: string;
  83638. };
  83639. }
  83640. declare module BABYLON {
  83641. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  83642. private _ampScale;
  83643. private _woodColor;
  83644. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83645. updateShaderUniforms(): void;
  83646. get ampScale(): number;
  83647. set ampScale(value: number);
  83648. get woodColor(): BABYLON.Color3;
  83649. set woodColor(value: BABYLON.Color3);
  83650. /**
  83651. * Serializes this wood procedural texture
  83652. * @returns a serialized wood procedural texture object
  83653. */
  83654. serialize(): any;
  83655. /**
  83656. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  83657. * @param parsedTexture defines parsed texture data
  83658. * @param scene defines the current scene
  83659. * @param rootUrl defines the root URL containing wood procedural texture information
  83660. * @returns a parsed Wood Procedural BABYLON.Texture
  83661. */
  83662. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  83663. }
  83664. }